2024-12-24 21:32

shichengkun_branch
sck 2 months ago
parent 0567c1655a
commit 8d2bd8e457

@ -9,24 +9,35 @@ import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
__priority__ = PRIORITY.HIGHEST # 设置优先级为最高
def dependencies():
pass
def tamper(payload, **kwargs):
"""
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'
这个函数用于篡改tamper输入的payload以绕过某些安全防护措施
参数
payload要篡改的原始payload
**kwargs其他可选参数在本函数中未使用
功能
将payload中的<int> UNION替换为<int>e0UNION以尝试绕过安全防护
要求
* 适用于MySQL和MsSQL数据库
注意
* 参考文档https://media.blackhat.com/us-13/US-13-Salgado-SQLi-Optimization-and-Obfuscation-Techniques-Slides.pdf
* 该函数假设输入的payload是有效的并且不进行任何错误处理
示例
>>> tamper('1 UNION ALL SELECT')
'1e0UNION ALL SELECT'
"""
# 使用正则表达式替换payload中的数字和UNION之间的空格为'e0'
# \g<1>表示匹配的第一个括号中的内容,\g<2>表示第二个括号中的内容
return re.sub(r"(?i)(\d+)\s+(UNION )", r"\g<1>e0\g<2>", payload) if payload else payload

@ -7,23 +7,31 @@ See the file 'LICENSE' for copying permission
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
__priority__ = PRIORITY.LOWEST# 设置优先级为最低
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces apostrophe character (') with its UTF-8 full width counterpart (e.g. ' -> %EF%BC%87)
这个函数用于篡改tamper输入的payload将其中的单引号字符'替换为其UTF-8全角字符对应物。
References:
参数
payload要篡改的原始payload
**kwargs其他可选参数在本函数中未使用
功能
将payload中的单引号'替换为UTF-8编码的全角单引号%EF%BC%87用于绕过某些安全防护措施。
参考链接
* http://www.utf8-chartable.de/unicode-utf8-table.pl?start=65280&number=128
* https://web.archive.org/web/20130614183121/http://lukasz.pilorz.net/testy/unicode_conversion/
* https://web.archive.org/web/20131121094431/sla.ckers.org/forum/read.php?13,11562,11850
* https://web.archive.org/web/20070624194958/http://lukasz.pilorz.net/testy/full_width_utf/index.phps
>>> tamper("1 AND '1'='1")
'1 AND %EF%BC%871%EF%BC%87=%EF%BC%871'
示例
>>> tamper("1 AND '1'='1")
'1 AND %EF%BC%871%EF%BC%87=%EF%BC%871'
"""
# 替换payload中的单引号为UTF-8全角单引号
return payload.replace('\'', "%EF%BC%87") if payload else payload

@ -7,17 +7,29 @@ See the file 'LICENSE' for copying permission
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOWEST
__priority__ = PRIORITY.LOWEST# 设置优先级为最低
def dependencies():
"""
这个函数用于定义依赖关系但在当前脚本中未实现任何功能
通常这个函数用于检查当前函数所需的依赖是否满足
"""
pass
def tamper(payload, **kwargs):
"""
Replaces apostrophe character (') with its illegal double unicode counterpart (e.g. ' -> %00%27)
这个函数用于篡改tamper输入的payload将其中的单引号字符'替换为其非法的双Unicode编码对应物。
参数
payload要篡改的原始payload
**kwargs其他可选参数在本函数中未使用
功能
将payload中的单引号')替换为%00%27这是一种非法的Unicode编码方式用于绕过某些安全防护措施。
>>> tamper("1 AND '1'='1")
'1 AND %00%271%00%27=%00%271'
示例
>>> tamper("1 AND '1'='1")
'1 AND %00%271%00%27=%00%271'
"""
return payload.replace('\'', "%00%27") if payload else payload
return payload.replace('\'', "%00%27") if payload else payload # 替换payload中的单引号为%00%27

@ -15,23 +15,30 @@ __priority__ = PRIORITY.LOWEST
def dependencies():
singleTimeWarnMessage("tamper script '%s' is only meant to be run against %s" % (os.path.basename(__file__).split(".")[0], DBMS.ACCESS))
# 显示警告信息指出该tamper脚本仅适用于Microsoft Access数据库
def tamper(payload, **kwargs):
"""
Appends (Access) NULL byte character (%00) at the end of payload
这个函数用于篡改tamper输入的payload通过在末尾添加一个NULL字节%00
参数
payload要篡改的原始payload
**kwargs其他可选参数在本函数中未使用
功能
在payload的末尾添加一个NULL字节%00这在对付某些弱Web应用防火墙时非常有用特别是当后端数据库管理系统是Microsoft Access时
Requirement:
* Microsoft Access
要求
* 仅适用于Microsoft Access数据库
Notes:
* Useful to bypass weak web application firewalls when the back-end
database management system is Microsoft Access - further uses are
also possible
注意
* 这种技术除了可以绕过Web应用防火墙外还有其他可能的用途
Reference: http://projects.webappsec.org/w/page/13246949/Null-Byte-Injection
参考链接
* http://projects.webappsec.org/w/page/13246949/Null-Byte-Injection
>>> tamper('1 AND 1=1')
'1 AND 1=1%00'
示例
>>> tamper('1 AND 1=1')
'1 AND 1=1%00'
"""
return "%s%%00" % payload if payload else payload
return "%s%%00" % payload if payload else payload # 如果payload不为空则在其末尾添加NULL字节%00

Loading…
Cancel
Save