mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-07 05:01:30 +00:00
Unescaping is renamed to escaping
This commit is contained in:
@@ -36,4 +36,4 @@ class MySQLMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Take
|
||||
Miscellaneous.__init__(self)
|
||||
Takeover.__init__(self)
|
||||
|
||||
unescaper[DBMS.MYSQL] = Syntax.unescape
|
||||
unescaper[DBMS.MYSQL] = Syntax.escape
|
||||
|
||||
@@ -17,7 +17,7 @@ class Syntax(GenericSyntax):
|
||||
GenericSyntax.__init__(self)
|
||||
|
||||
@staticmethod
|
||||
def unescape(expression, quote=True):
|
||||
def escape(expression, quote=True):
|
||||
if quote:
|
||||
unescaped = expression
|
||||
for item in re.findall(r"'[^']+'", expression, re.S):
|
||||
@@ -29,31 +29,3 @@ class Syntax(GenericSyntax):
|
||||
unescaped = "0x%s" % binascii.hexlify(expression)
|
||||
|
||||
return unescaped
|
||||
|
||||
@staticmethod
|
||||
def escape(expression):
|
||||
while True:
|
||||
index = expression.find("CHAR(")
|
||||
if index == -1:
|
||||
break
|
||||
|
||||
firstIndex = index
|
||||
index = expression[firstIndex:].find(")")
|
||||
|
||||
if index == -1:
|
||||
raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression)
|
||||
|
||||
lastIndex = firstIndex + index + 1
|
||||
old = expression[firstIndex:lastIndex]
|
||||
oldUpper = old.upper()
|
||||
oldUpper = oldUpper.lstrip("CHAR(").rstrip(")")
|
||||
oldUpper = oldUpper.split(",")
|
||||
|
||||
escaped = "'%s'" % "".join(chr(int(char)) for char in oldUpper)
|
||||
expression = expression.replace(old, escaped)
|
||||
|
||||
original = expression
|
||||
for item in re.findall(r"0x[0-9a-fA-F]+", original, re.S):
|
||||
expression = expression.replace(item, "'%s'" % binascii.unhexlify(item[2:]))
|
||||
|
||||
return expression
|
||||
|
||||
Reference in New Issue
Block a user