Adding char escaper to ClickHouse support (#5229)

This commit is contained in:
Miroslav Stampar 2023-02-04 00:00:21 +01:00
parent 30ba167cc1
commit 46495f70f8
2 changed files with 8 additions and 4 deletions

View File

@ -20,7 +20,7 @@ from thirdparty import six
from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.7.2.3"
VERSION = "1.7.2.4"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -1,18 +1,22 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2023 sqlmap developers (http://sqlmap.org/)
Copyright (c) 2006-2023 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
from lib.core.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=True):
"""
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == u"SELECT 'abcdefgh' FROM foobar"
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT char(97)||char(98)||char(99)||char(100)||char(101)||char(102)||char(103)||char(104) FROM foobar"
True
"""
return expression
def escaper(value):
return "||".join("char(%d)" % _ for _ in getOrds(value))
return Syntax._escape(expression, quote, escaper)