sqlmap源码阅读_listTamperingFunctions和_setTamperingFunctions

sqlmap里面的tamper介绍

tamper是什么?中文是做手脚,篡改的意思。
一是指放在tamper目录下的一系例*.py文件,这些文件都定义了一个叫做tamper的函数。这些tamper会对字符串做一些处理,变种,用来绕过WAF,或者绕过防御,从而方便渗透测试。

例如:
sqlmap --url “example.com” --tamper=“base64encode.py”
在这里插入图片描述

使用方法

sqlmap --list-tamper 罗列出有哪些tamper脚步
在这里插入图片描述

sqlmap --tamper 使用指定的脚本

tamper的分类

有些tamper脚本是针对url的,有些tamper是针对指定数据库的,有些tamper是通用型的。

代码流程

list-tamper

–list-tamper命令行参数的解析。
在这里插入图片描述

_listTamperingFunctions()


def _listTamperingFunctions():
    """
    Lists available tamper functions
    """

    if conf.listTampers:
        infoMsg = "listing available tamper scripts\n"
        logger.info(infoMsg)

        for script in sorted(glob.glob(os.path.join(paths.SQLMAP_TAMPER_PATH, "*.py"))):
            content = openFile(script, "rb").read()
            match = re.search(r'(?s)__priority__.+"""(.+)"""', content)
            if match:
                comment = match.group(1).strip()
                dataToStdout("* %s - %s\n" % (setColor(os.path.basename(script), "yellow"), re.sub(r" *\n *", " ", comment.split("\n\n")[0].strip())))

其中我不太理解的地方有,需要学习下:
glob.glob() 这里是一个文件名匹配
match = re.search(r'(?s)__priority__.+"""(.+)"""', content) 这个语句,是正则表达式匹配,用来搜索注释语句。

获取文件路径
paths是从lib.core.data中导入的数据
paths.SQLMAP_TAMPER_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "tamper")

tamper

–tamper 参数解析
在这里插入图片描述
_setTamperingFunctions函数

posted @ 2022-03-06 10:37  叶常落  阅读(35)  评论(0编辑  收藏  举报