心 空

  • Tools
Ricky Hao
  1. 首页
  2. SQLLAB
  3. 正文

Less-18~19 Header Injection

29 8 月, 2015 1833点热度 0人点赞 0条评论

这是Header 注入。
意思是,从服务器要求的Header头里面找到可以注入的注入点。
从源代码可以看出,服务器将Header里面的user-agent的值没有经过过滤就带入了insert into语句,这就造成了注入。

$uagent = $_SERVER['HTTP_USER_AGENT'];
...
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";

首先,抓包。
还有一个问题就是,insert into语句要在登陆成功后才能执行,所以必须输入正确的用户和密码再抓包。
红框框出来的就是我们可以利用的地方。

1.png

将其改成下图的形式。

2.png

首先,

1','2'        

用来填补insert into所需要的数据,也可以替换成其他select语句。
之后的

(select username from users where id=1 

这是为了可以使用后面的

and left(version(),1)=5 

这样就可以猜出数据库版本号和密码啊什么的的了。因为若是不对,and后面的语句会返回0,然后连上前面的where就是

where id =0

自然不存在就会报错了。

还有一点就是,mysql_query()函数每次只能执行一条语句,所以不要再尝试在insert into后面加上分号;来企图执行其他语句了。不说了,都是泪。。。
PS:吴神说 insert into 最后可以加 and ?可是我怎么加都不行啊。。。而且 insert into 也不能加 where 。。

Less-19

User-Agent: 1',(select password from users where id =1 and left(version(),1)=5))#
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可
标签: sql sqllab
最后更新:29 8 月, 2015

Ricky

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

COPYRIGHT © 2025 心 空. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang