2020from lib .core .common import extractRegexResult
2121from lib .core .common import getConsoleWidth
2222from lib .core .common import getUnicode
23+ from lib .core .common import incrementCounter
2324from lib .core .common import initTechnique
2425from lib .core .common import isNumPosStrValue
2526from lib .core .common import listToStrValue
4445from lib .request .connect import Connect as Request
4546from lib .utils .resume import resume
4647
47- reqCount = 0
48-
4948def __oneShotUnionUse (expression , unpack = True , limited = False ):
50- global reqCount
51-
5249 retVal = conf .hashDB .retrieve (expression ) if not any ([conf .flushSession , conf .freshQueries ]) else None
5350
5451 threadData = getCurrentThreadData ()
@@ -59,13 +56,9 @@ def __oneShotUnionUse(expression, unpack=True, limited=False):
5956 trimcheck = "%s(?P<result>.*?)</" % (kb .chars .start )
6057
6158 # Prepare expression with delimiters
62- injExpression = agent .concatQuery (expression , unpack )
63- injExpression = unescaper .unescape (injExpression )
59+ injExpression = unescaper .unescape (agent .concatQuery (expression , unpack ))
6460
65- if conf .limitStart or conf .limitStop :
66- where = PAYLOAD .WHERE .NEGATIVE
67- else :
68- where = None
61+ where = PAYLOAD .WHERE .NEGATIVE if conf .limitStart or conf .limitStop else None
6962
7063 # Forge the inband SQL injection request
7164 vector = kb .injection .data [PAYLOAD .TECHNIQUE .UNION ].vector
@@ -75,7 +68,7 @@ def __oneShotUnionUse(expression, unpack=True, limited=False):
7568 # Perform the request
7669 page , headers = Request .queryPage (payload , content = True , raise404 = False )
7770
78- reqCount += 1
71+ incrementCounter ( PAYLOAD . TECHNIQUE . UNION )
7972
8073 # Parse the returned page to get the exact union-based
8174 # sql injection output
@@ -129,8 +122,7 @@ def __configUnionCols(columns):
129122 if not colsStart .isdigit () or not colsStop .isdigit ():
130123 raise sqlmapSyntaxException , "--union-cols must be a range of integers"
131124
132- conf .uColsStart = int (colsStart )
133- conf .uColsStop = int (colsStop )
125+ conf .uColsStart , conf .uColsStop = int (colsStart ), int (colsStop )
134126
135127 if conf .uColsStart > conf .uColsStop :
136128 errMsg = "--union-cols range has to be from lower to "
@@ -149,15 +141,13 @@ def unionUse(expression, unpack=True, dump=False):
149141
150142 initTechnique (PAYLOAD .TECHNIQUE .UNION )
151143
152- global reqCount
153-
154144 count = None
155145 origExpr = expression
156146 startLimit = 0
157147 stopLimit = None
158148 test = True
159149 value = ""
160- reqCount = 0
150+
161151 width = getConsoleWidth ()
162152 start = time .time ()
163153
@@ -362,7 +352,7 @@ def unionThread():
362352 duration = calculateDeltaSeconds (start )
363353
364354 if not kb .bruteMode :
365- debugMsg = "performed %d queries in %d seconds" % (reqCount , duration )
355+ debugMsg = "performed %d queries in %d seconds" % (kb . counters [ PAYLOAD . TECHNIQUE . UNION ] , duration )
366356 logger .debug (debugMsg )
367357
368358 return value
0 commit comments