Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 676b95b

Browse files
committed
minor code refactoring
1 parent f8c04ce commit 676b95b

3 files changed

Lines changed: 36 additions & 36 deletions

File tree

lib/controller/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from lib.core.common import wasLastRequestDBMSError
3434
from lib.core.common import wasLastRequestHTTPError
3535
from lib.core.common import DynamicContentItem
36-
from lib.core.common import configUnion
3736
from lib.core.data import conf
3837
from lib.core.data import kb
3938
from lib.core.data import logger
@@ -57,6 +56,7 @@
5756
from lib.core.unescaper import unescaper
5857
from lib.request.connect import Connect as Request
5958
from lib.request.templates import getPageTemplate
59+
from lib.techniques.inband.union.use import configUnion
6060
from lib.techniques.inband.union.test import unionTest
6161

6262
def unescape(string, dbms):

lib/core/common.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,38 +2089,3 @@ def openFile(filename, mode='r'):
20892089
('w' in mode or 'a' in mode or '+' in mode) else "read")
20902090
errMsg += "and that it's not locked by another process."
20912091
raise sqlmapFilePathException, errMsg
2092-
2093-
def __configUnionChar(char):
2094-
if char.isdigit() or char == "NULL":
2095-
conf.uChar = char
2096-
elif not char.startswith("'") or not char.endswith("'"):
2097-
conf.uChar = "'%s'" % char
2098-
2099-
def __configUnionCols(columns):
2100-
if "-" not in columns or len(columns.split("-")) != 2:
2101-
raise sqlmapSyntaxException, "--union-cols must be a range with hyphon (e.g. 1-10)"
2102-
2103-
columns = columns.replace(" ", "")
2104-
conf.uColsStart, conf.uColsStop = columns.split("-")
2105-
2106-
if not conf.uColsStart.isdigit() or not conf.uColsStop.isdigit():
2107-
raise sqlmapSyntaxException, "--union-cols must be a range of integers"
2108-
2109-
conf.uColsStart = int(conf.uColsStart)
2110-
conf.uColsStop = int(conf.uColsStop)
2111-
2112-
if conf.uColsStart > conf.uColsStop:
2113-
errMsg = "--union-cols range has to be from lower to "
2114-
errMsg += "higher number of columns"
2115-
raise sqlmapSyntaxException, errMsg
2116-
2117-
def configUnion(char, columns):
2118-
if isinstance(conf.uChar, basestring):
2119-
__configUnionChar(conf.uChar)
2120-
elif isinstance(char, basestring):
2121-
__configUnionChar(char)
2122-
2123-
if isinstance(conf.uCols, basestring):
2124-
__configUnionCols(conf.uCols)
2125-
elif isinstance(columns, basestring):
2126-
__configUnionCols(columns)

lib/techniques/inband/union/use.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,38 @@ def unionUse(expression, direct=False, unescape=True, resetCounter=False, nullCh
234234
logger.debug(debugMsg)
235235

236236
return value
237+
238+
def __configUnionChar(char):
239+
if char.isdigit() or char == "NULL":
240+
conf.uChar = char
241+
elif not char.startswith("'") or not char.endswith("'"):
242+
conf.uChar = "'%s'" % char
243+
244+
def __configUnionCols(columns):
245+
if "-" not in columns or len(columns.split("-")) != 2:
246+
raise sqlmapSyntaxException, "--union-cols must be a range with hyphon (e.g. 1-10)"
247+
248+
columns = columns.replace(" ", "")
249+
conf.uColsStart, conf.uColsStop = columns.split("-")
250+
251+
if not conf.uColsStart.isdigit() or not conf.uColsStop.isdigit():
252+
raise sqlmapSyntaxException, "--union-cols must be a range of integers"
253+
254+
conf.uColsStart = int(conf.uColsStart)
255+
conf.uColsStop = int(conf.uColsStop)
256+
257+
if conf.uColsStart > conf.uColsStop:
258+
errMsg = "--union-cols range has to be from lower to "
259+
errMsg += "higher number of columns"
260+
raise sqlmapSyntaxException, errMsg
261+
262+
def configUnion(char, columns):
263+
if isinstance(conf.uChar, basestring):
264+
__configUnionChar(conf.uChar)
265+
elif isinstance(char, basestring):
266+
__configUnionChar(char)
267+
268+
if isinstance(conf.uCols, basestring):
269+
__configUnionCols(conf.uCols)
270+
elif isinstance(columns, basestring):
271+
__configUnionCols(columns)

0 commit comments

Comments
 (0)