# 基于Http Header的SQL注入

**URL:** <https://forum.90sec.com/t/topic/3804>\
**Category:** 交流讨论\
**Created:** [2012 年6 月 27 日 10:33 UTC](https://forum.90sec.com/t/topic/3804 "2012-06-27T10:33:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

作者： ![talaso](https://forum.90sec.com/letter_avatar_proxy/v4/letter/t/ba9def/32.png) [@talaso](https://forum.90sec.com/u/talaso)\
发布日期： [2012 年6 月 27 日 10:33 UTC](https://forum.90sec.com/t/topic/3804/1 "2012-06-27T10:33:58Z")

</div>

_本帖最后由 talaso 于 2012-6-27 18:37 编辑_

通常HTTP消息包括客户机向服务器的请求消息和服务器向客户机的响应消息。这两种类型的消息由一个起始行，一个或者多个头域，一个只是头域结束的空行和可选的消息体组成。HTTP的头域包括通用头，请求头，响应头和实体头四个部分。每个头域由一个域名，冒号（:）和域值三部分组成。域名是大小写无关的，域值前可以添加任何数量的空格符，头域可以被扩展为多行，在每行开始处，使用至少一个空格或制表符。GET / HTTP/1.1  
Connection: Keep-Alive  
Keep-Alive: 300  
Accept:_/_  
Host: host  
Accept-Language: en-us  
Accept-Encoding: gzip, deflate  
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;  
rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0E)  
Cookie: guest\_id=v1%3A1328019064; pid=v1%3A1328839311134如何执行一个HTTP头的SQL注入？  
需要下载插件[cookie管理插件](https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/)  
打开cookie管理器，然后单击目标网站  
[17.png](https://forum.90sec.com/discuz-migration/attachments/9ebbca4ec8aceeb45af765f93e921e57b68afeba71f467af20c9fe99ccdd62df)  
编辑目标网站的cookie，来验证目标网站是否存在http头的SQL注入，我们编辑变量language\_id的字段内容，添加单引号’刷新页面来判断。  
[26.png](https://forum.90sec.com/discuz-migration/attachments/70044f34dc43def6dd5607d46332da01662e5a89b0eb291da192b904c431a9aa)  
刷新页面，判断是否存在SQL注入漏洞  
[34.png](https://forum.90sec.com/discuz-migration/attachments/c3f085b6d98cbcd480f2665b80419e6baa46ef06cca748720439e45c8ad3cc2a)  
ok，下载插件[tamper-data](https://addons.mozilla.org/en-US/firefox/addon/tamper-data/)来修改请求的数据内容。  
[43.png](https://forum.90sec.com/discuz-migration/attachments/ea9123cff9f430c90f8eb7ce6386f8c683f7e68a7bf87f148eace2a2ca62449d)  
输入一个SQL注入语句  
[201206222114084908.png](https://forum.90sec.com/discuz-migration/attachments/7e976b35e46d388f3cb797c108b42937b1fcda4f98657b472e9e27945ebde08a)  
如果我们输入order by 5– ，会报以下错误。  
[201206222115121220.png](https://forum.90sec.com/discuz-migration/attachments/013716fc438f686d1677485939bfd05c8499d19b217fe25e61b60feb4ca5756e)  
所以可以判断得出用户表列为4，再使用cookie管理器，添加以下代码在language\_id字段里面：-1+UNION+ALL+SELECT+1,2,3,4或者输入下面的语句得到数据库用户或版本信息等。version()  
user()  
concat(database())  
group\_concat用SqlMap注入起来会更简单，后续会带来SqlMap的相关文章 ：）  
[201206222118172782.png](https://forum.90sec.com/discuz-migration/attachments/0f05acbdb035fab156ef9b718213831f49baa945bfbbcc7e522321f1ec3dc01d)

原文地址:[http://www.freebuf.com/articles/4588.html](http://www.freebuf.com/articles/4588.html)

---

<div class="post-metadata">

作者： ![jjf012](https://forum.90sec.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jjf012](https://forum.90sec.com/u/jjf012)\
发布日期： [2012 年6 月 27 日 10:36 UTC](https://forum.90sec.com/t/topic/3804/2 "2012-06-27T10:36:30Z")

</div>

{:4\_51:}感谢楼主分享。  
ps:sqlmap只要调高level数就能注入了？

---

<div class="post-metadata">

作者： ![Yaseng](https://forum.90sec.com/user_avatar/forum.90sec.com/yaseng/32/11405_2.png) [@Yaseng](https://forum.90sec.com/u/Yaseng)\
发布日期： [2012 年6 月 27 日 10:53 UTC](https://forum.90sec.com/t/topic/3804/3 "2012-06-27T10:53:11Z")

</div>

\*\*回复 [1#](http://www.90sec.org/redirect.php?goto=findpost&pid=32886&ptid=2841) _talaso_ \*\*

```
是基于 cookies 吧 没太看懂 ...

```

---

<div class="post-metadata">

作者： ![leo108](https://forum.90sec.com/user_avatar/forum.90sec.com/leo108/32/11465_2.png) [@leo108](https://forum.90sec.com/u/leo108)\
发布日期： [2012 年6 月 27 日 10:55 UTC](https://forum.90sec.com/t/topic/3804/4 "2012-06-27T10:55:40Z")

</div>

cookie注入而已……

---

<div class="post-metadata">

作者： ![ghcshell](https://forum.90sec.com/user_avatar/forum.90sec.com/ghcshell/32/11462_2.png) [@ghcshell](https://forum.90sec.com/u/ghcshell)\
发布日期： [2012 年6 月 27 日 11:07 UTC](https://forum.90sec.com/t/topic/3804/5 "2012-06-27T11:07:58Z")

</div>

mssql 注入 order+by+5-- 这个没成功过

---

<div class="post-metadata">

作者： ![talaso](https://forum.90sec.com/letter_avatar_proxy/v4/letter/t/ba9def/32.png) [@talaso](https://forum.90sec.com/u/talaso)\
发布日期： [2012 年6 月 27 日 11:09 UTC](https://forum.90sec.com/t/topic/3804/6 "2012-06-27T11:09:52Z")

</div>

\*\*回复 [4#](http://www.90sec.org/redirect.php?goto=findpost&pid=32891&ptid=2841) _leo108_ \*\*

```
cookie注入 最终执行的还是注入SQL语句 达到查询数据库的目的

```

---

<div class="post-metadata">

作者： ![talaso](https://forum.90sec.com/letter_avatar_proxy/v4/letter/t/ba9def/32.png) [@talaso](https://forum.90sec.com/u/talaso)\
发布日期： [2012 年6 月 27 日 11:10 UTC](https://forum.90sec.com/t/topic/3804/7 "2012-06-27T11:10:47Z")

</div>

只不过为了 区分 习惯叫cookie注入了

---

<div class="post-metadata">

作者： ![v0dga](https://forum.90sec.com/letter_avatar_proxy/v4/letter/v/d07c76/32.png) [@v0dga](https://forum.90sec.com/u/v0dga)\
发布日期： [2012 年6 月 27 日 11:58 UTC](https://forum.90sec.com/t/topic/3804/8 "2012-06-27T11:58:44Z")

</div>

调高level就可以cookie注入

---

<div class="post-metadata">

作者： ![798146410](https://forum.90sec.com/letter_avatar_proxy/v4/letter/7/43a26b/32.png) [@798146410](https://forum.90sec.com/u/798146410)\
发布日期： [2012 年6 月 28 日 10:55 UTC](https://forum.90sec.com/t/topic/3804/9 "2012-06-28T10:55:18Z")

</div>

谢谢分享{:4\_79:}
