2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2010-03-23 01:57:57 +03:00
|
|
|
|
|
|
|
"""
|
2018-01-02 02:48:10 +03:00
|
|
|
Copyright (c) 2006-2018 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2010-03-23 01:57:57 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
from plugins.generic.syntax import Syntax as GenericSyntax
|
|
|
|
|
|
|
|
class Syntax(GenericSyntax):
|
|
|
|
def __init__(self):
|
|
|
|
GenericSyntax.__init__(self)
|
|
|
|
|
|
|
|
@staticmethod
|
2013-01-18 18:40:37 +04:00
|
|
|
def escape(expression, quote=True):
|
2013-03-11 17:58:05 +04:00
|
|
|
"""
|
|
|
|
>>> 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'
|
|
|
|
"""
|
|
|
|
|
2013-01-20 16:45:58 +04:00
|
|
|
def escaper(value):
|
|
|
|
return "+".join("%s(%d)" % ("CHAR" if ord(value[i]) < 256 else "NCHAR", ord(value[i])) for i in xrange(len(value)))
|
2010-03-23 01:57:57 +03:00
|
|
|
|
2013-01-20 16:45:58 +04:00
|
|
|
return Syntax._escape(expression, quote, escaper)
|