You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqlmap/src/sqlmap-master/tamper/lowercase.py

53 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python
"""
Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
import re # 导入正则表达式模块,用于匹配字符串中的模式
from lib.core.data import kb # 从核心库导入知识库包含SQL关键字等信息
from lib.core.enums import PRIORITY # 从核心库导入优先级枚举
# 设置优先级为普通
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def tamper(payload, **kwargs):
"""
这个函数用于篡改tamper输入的payload将其中的关键字字符转换为小写形式例如'SELECT' -> 'select')。
参数:
payload要篡改的原始payload。
**kwargs其他可选参数在本函数中未使用
测试情况:
* Microsoft SQL Server 2005
* MySQL 4, 5.0 和 5.5
* Oracle 10g
* PostgreSQL 8.3, 8.4, 9.0
注意:
* 这个篡改方法对于绕过那些具有写得不好的允许正则表达式的非常弱的定制Web应用防火墙很有用。
示例:
>>> tamper('INSERT')
'insert'
"""
retVal = payload # 初始化返回值为输入的payload
if payload: # 如果payload不为空
# 遍历payload中所有匹配单词边界的字母或下划线模式的字符串
for match in re.finditer(r"\b[A-Za-z_]+\b", retVal):
word = match.group() # 获取匹配的单词
# 如果匹配的单词是SQL关键字则将其转换为小写
if word.upper() in kb.keywords:
retVal = retVal.replace(word, word.lower())
return retVal