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/space2plus.py

65 lines
1.7 KiB

4 months ago
#!/usr/bin/env python
"""
Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
2 months ago
# 导入xrange和PRIORITY
4 months ago
from lib.core.compat import xrange
from lib.core.enums import PRIORITY
2 months ago
# 定义优先级为LOW
4 months ago
__priority__ = PRIORITY.LOW
2 months ago
# 定义依赖函数
4 months ago
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces space character (' ') with plus ('+')
Notes:
* Is this any useful? The plus get's url-encoded by sqlmap engine invalidating the query afterwards
* This tamper script works against all databases
>>> tamper('SELECT id FROM users')
'SELECT+id+FROM+users'
"""
retVal = payload
2 months ago
# 如果payload不为空
4 months ago
if payload:
retVal = ""
quote, doublequote, firstspace = False, False, False
2 months ago
# 遍历payload的每个字符
4 months ago
for i in xrange(len(payload)):
2 months ago
# 如果第一个字符不是空格
4 months ago
if not firstspace:
2 months ago
# 如果当前字符是空格
4 months ago
if payload[i].isspace():
firstspace = True
retVal += "+"
continue
2 months ago
# 如果当前字符是单引号
4 months ago
elif payload[i] == '\'':
quote = not quote
2 months ago
# 如果当前字符是双引号
4 months ago
elif payload[i] == '"':
doublequote = not doublequote
2 months ago
# 如果当前字符是空格,并且不在双引号和单引号中
4 months ago
elif payload[i] == " " and not doublequote and not quote:
retVal += "+"
continue
2 months ago
# 将当前字符添加到retVal中
4 months ago
retVal += payload[i]
return retVal