SIGN IN SIGN UP
sqlmapproject / sqlmap UNCLAIMED

Automatic SQL injection and database takeover tool

36950 0 0 Python
2019-05-08 12:47:52 +02:00
#!/usr/bin/env python
"""
2026-01-01 19:12:07 +01:00
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
2017-10-11 14:50:46 +02:00
See the file 'LICENSE' for copying permission
"""
2010-12-10 10:54:17 +00:00
from lib.core.common import isDBMSVersionAtLeast
2019-05-03 13:20:15 +02:00
from lib.core.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
2013-01-18 15:40:37 +01:00
def escape(expression, quote=True):
2013-03-11 14:58:05 +01:00
"""
2016-12-19 23:47:39 +01:00
>>> from lib.core.common import Backend
2013-03-11 14:58:05 +01:00
>>> Backend.setVersion('2.0')
['2.0']
2019-05-02 12:39:16 +02:00
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT 'abcdefgh' FROM foobar"
True
2013-03-11 14:58:05 +01:00
>>> Backend.setVersion('2.1')
['2.1']
2019-05-02 12:39:16 +02:00
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT ASCII_CHAR(97)||ASCII_CHAR(98)||ASCII_CHAR(99)||ASCII_CHAR(100)||ASCII_CHAR(101)||ASCII_CHAR(102)||ASCII_CHAR(103)||ASCII_CHAR(104) FROM foobar"
True
2013-03-11 14:58:05 +01:00
"""
def escaper(value):
2019-05-09 15:47:23 +02:00
return "||".join("ASCII_CHAR(%d)" % _ for _ in getOrds(value))
retVal = expression
2013-01-24 15:12:52 +01:00
if isDBMSVersionAtLeast("2.1"):
retVal = Syntax._escape(expression, quote, escaper)
2013-01-20 22:47:26 +01:00
return retVal