mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 20:51:31 +00:00
Minor drei update
This commit is contained in:
@@ -8,6 +8,7 @@ See the file 'LICENSE' for copying permission
|
||||
import binascii
|
||||
|
||||
from lib.core.common import getBytes
|
||||
from lib.core.common import getOrds
|
||||
from lib.core.common import getUnicode
|
||||
from plugins.generic.syntax import Syntax as GenericSyntax
|
||||
|
||||
@@ -15,11 +16,16 @@ class Syntax(GenericSyntax):
|
||||
@staticmethod
|
||||
def escape(expression, quote=True):
|
||||
"""
|
||||
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar")
|
||||
'SELECT 0x6162636465666768 FROM foobar'
|
||||
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT 0x6162636465666768 FROM foobar"
|
||||
True
|
||||
>>> Syntax.escape(u"SELECT 'abcd\xebfgh' FROM foobar") == "SELECT CONVERT(0x61626364c3ab666768 USING utf8) FROM foobar"
|
||||
True
|
||||
"""
|
||||
|
||||
def escaper(value):
|
||||
return "0x%s" % getUnicode(binascii.hexlify(getBytes(value)))
|
||||
if all(_ < 128 for _ in getOrds(value)):
|
||||
return "0x%s" % getUnicode(binascii.hexlify(getBytes(value)))
|
||||
else:
|
||||
return "CONVERT(0x%s USING utf8)" % getUnicode(binascii.hexlify(getBytes(value)))
|
||||
|
||||
return Syntax._escape(expression, quote, escaper)
|
||||
|
||||
Reference in New Issue
Block a user