mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-23 01:56:36 +03:00
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
|
|
"""
|
|
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
|
|
See the file 'LICENSE' for copying permission
|
|
"""
|
|
|
|
import re
|
|
|
|
from lib.core.common import isDBMSVersionAtLeast
|
|
from lib.core.common import randomStr
|
|
from lib.core.convert import getOrds
|
|
from plugins.generic.syntax import Syntax as GenericSyntax
|
|
|
|
class Syntax(GenericSyntax):
|
|
@staticmethod
|
|
def escape(expression, quote=True):
|
|
"""
|
|
>>> from lib.core.common import Backend
|
|
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CODE(97)||CODE(98)||CODE(99)||CODE(100)||CODE(101)||CODE(102)||CODE(103)||CODE(104) FROM foobar"
|
|
True
|
|
"""
|
|
|
|
def escaper(value):
|
|
return "||".join("CODE(%d)" % _ for _ in getOrds(value))
|
|
|
|
retVal = expression
|
|
|
|
if isDBMSVersionAtLeast("11.70"):
|
|
excluded = {}
|
|
for _ in re.findall(r"DBINFO\([^)]+\)", expression):
|
|
excluded[_] = randomStr()
|
|
expression = expression.replace(_, excluded[_])
|
|
|
|
retVal = Syntax._escape(expression, quote, escaper)
|
|
|
|
for _ in excluded.items():
|
|
retVal = retVal.replace(_[1], _[0])
|
|
|
|
return retVal
|