mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-02 02:43:35 +03:00
minor code refactoring
This commit is contained in:
parent
f8c04ce020
commit
676b95b30a
|
@ -33,7 +33,6 @@ from lib.core.common import trimAlphaNum
|
||||||
from lib.core.common import wasLastRequestDBMSError
|
from lib.core.common import wasLastRequestDBMSError
|
||||||
from lib.core.common import wasLastRequestHTTPError
|
from lib.core.common import wasLastRequestHTTPError
|
||||||
from lib.core.common import DynamicContentItem
|
from lib.core.common import DynamicContentItem
|
||||||
from lib.core.common import configUnion
|
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
@ -57,6 +56,7 @@ from lib.core.settings import UPPER_RATIO_BOUND
|
||||||
from lib.core.unescaper import unescaper
|
from lib.core.unescaper import unescaper
|
||||||
from lib.request.connect import Connect as Request
|
from lib.request.connect import Connect as Request
|
||||||
from lib.request.templates import getPageTemplate
|
from lib.request.templates import getPageTemplate
|
||||||
|
from lib.techniques.inband.union.use import configUnion
|
||||||
from lib.techniques.inband.union.test import unionTest
|
from lib.techniques.inband.union.test import unionTest
|
||||||
|
|
||||||
def unescape(string, dbms):
|
def unescape(string, dbms):
|
||||||
|
|
|
@ -2089,38 +2089,3 @@ def openFile(filename, mode='r'):
|
||||||
('w' in mode or 'a' in mode or '+' in mode) else "read")
|
('w' in mode or 'a' in mode or '+' in mode) else "read")
|
||||||
errMsg += "and that it's not locked by another process."
|
errMsg += "and that it's not locked by another process."
|
||||||
raise sqlmapFilePathException, errMsg
|
raise sqlmapFilePathException, errMsg
|
||||||
|
|
||||||
def __configUnionChar(char):
|
|
||||||
if char.isdigit() or char == "NULL":
|
|
||||||
conf.uChar = char
|
|
||||||
elif not char.startswith("'") or not char.endswith("'"):
|
|
||||||
conf.uChar = "'%s'" % char
|
|
||||||
|
|
||||||
def __configUnionCols(columns):
|
|
||||||
if "-" not in columns or len(columns.split("-")) != 2:
|
|
||||||
raise sqlmapSyntaxException, "--union-cols must be a range with hyphon (e.g. 1-10)"
|
|
||||||
|
|
||||||
columns = columns.replace(" ", "")
|
|
||||||
conf.uColsStart, conf.uColsStop = columns.split("-")
|
|
||||||
|
|
||||||
if not conf.uColsStart.isdigit() or not conf.uColsStop.isdigit():
|
|
||||||
raise sqlmapSyntaxException, "--union-cols must be a range of integers"
|
|
||||||
|
|
||||||
conf.uColsStart = int(conf.uColsStart)
|
|
||||||
conf.uColsStop = int(conf.uColsStop)
|
|
||||||
|
|
||||||
if conf.uColsStart > conf.uColsStop:
|
|
||||||
errMsg = "--union-cols range has to be from lower to "
|
|
||||||
errMsg += "higher number of columns"
|
|
||||||
raise sqlmapSyntaxException, errMsg
|
|
||||||
|
|
||||||
def configUnion(char, columns):
|
|
||||||
if isinstance(conf.uChar, basestring):
|
|
||||||
__configUnionChar(conf.uChar)
|
|
||||||
elif isinstance(char, basestring):
|
|
||||||
__configUnionChar(char)
|
|
||||||
|
|
||||||
if isinstance(conf.uCols, basestring):
|
|
||||||
__configUnionCols(conf.uCols)
|
|
||||||
elif isinstance(columns, basestring):
|
|
||||||
__configUnionCols(columns)
|
|
||||||
|
|
|
@ -234,3 +234,38 @@ def unionUse(expression, direct=False, unescape=True, resetCounter=False, nullCh
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def __configUnionChar(char):
|
||||||
|
if char.isdigit() or char == "NULL":
|
||||||
|
conf.uChar = char
|
||||||
|
elif not char.startswith("'") or not char.endswith("'"):
|
||||||
|
conf.uChar = "'%s'" % char
|
||||||
|
|
||||||
|
def __configUnionCols(columns):
|
||||||
|
if "-" not in columns or len(columns.split("-")) != 2:
|
||||||
|
raise sqlmapSyntaxException, "--union-cols must be a range with hyphon (e.g. 1-10)"
|
||||||
|
|
||||||
|
columns = columns.replace(" ", "")
|
||||||
|
conf.uColsStart, conf.uColsStop = columns.split("-")
|
||||||
|
|
||||||
|
if not conf.uColsStart.isdigit() or not conf.uColsStop.isdigit():
|
||||||
|
raise sqlmapSyntaxException, "--union-cols must be a range of integers"
|
||||||
|
|
||||||
|
conf.uColsStart = int(conf.uColsStart)
|
||||||
|
conf.uColsStop = int(conf.uColsStop)
|
||||||
|
|
||||||
|
if conf.uColsStart > conf.uColsStop:
|
||||||
|
errMsg = "--union-cols range has to be from lower to "
|
||||||
|
errMsg += "higher number of columns"
|
||||||
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
|
def configUnion(char, columns):
|
||||||
|
if isinstance(conf.uChar, basestring):
|
||||||
|
__configUnionChar(conf.uChar)
|
||||||
|
elif isinstance(char, basestring):
|
||||||
|
__configUnionChar(char)
|
||||||
|
|
||||||
|
if isinstance(conf.uCols, basestring):
|
||||||
|
__configUnionCols(conf.uCols)
|
||||||
|
elif isinstance(columns, basestring):
|
||||||
|
__configUnionCols(columns)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user