sqlmap/plugins/generic/syntax.py

37 lines
886 B
Python
Raw Normal View History

#!/usr/bin/env python2
"""
2013-01-18 18:07:51 +04:00
Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/)
2010-10-15 03:18:29 +04:00
See the file 'doc/COPYING' for copying permission
"""
import re
from lib.core.exception import SqlmapUndefinedMethod
class Syntax:
"""
This class defines generic syntax functionalities for plugins.
"""
def __init__(self):
pass
@staticmethod
def _escape(expression, quote=True, escaper=None):
retVal = expression
if quote:
for item in re.findall(r"'[^']*'+", expression, re.S):
retVal = retVal.replace(item, escaper(item[1:-1]))
else:
retVal = escaper(expression)
return retVal
@staticmethod
2013-01-18 19:10:34 +04:00
def escape(expression, quote=True):
2011-04-30 17:20:05 +04:00
errMsg = "'escape' method must be defined "
2013-01-18 18:40:37 +04:00
errMsg += "inside the specific DBMS plugin"
raise SqlmapUndefinedMethod(errMsg)