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

Skip to content

Commit 1151af5

Browse files
committed
More fix for save/resume of --technique
1 parent 28a4ae8 commit 1151af5

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

lib/controller/checks.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,13 @@ def checkSqlInjection(place, parameter, value):
203203
logger.debug(debugMsg)
204204
continue
205205

206-
if len(kb.injections) > 0:
207-
for resumedInj in kb.injections:
208-
if resumedInj.place == place and resumedInj.parameter \
209-
== parameter and stype in resumedInj.data:
210-
debugMsg = "skipping test '%s' because this " % title
211-
debugMsg += "technique has already been detected "
212-
debugMsg += "in a previous run"
213-
logger.debug(debugMsg)
214-
215-
proceed = False
216-
break
206+
if len(kb.tested) > 0 and stype in kb.tested:
207+
debugMsg = "skipping test '%s' because this " % title
208+
debugMsg += "technique has already been detected "
209+
debugMsg += "in a previous run"
210+
logger.debug(debugMsg)
211+
212+
proceed = False
217213

218214
if not proceed:
219215
continue

lib/controller/controller.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from lib.core.exception import sqlmapValueException
4444
from lib.core.exception import sqlmapUserQuitException
4545
from lib.core.session import setInjection
46+
from lib.core.session import setTestedTechniques
4647
from lib.core.settings import EMPTY_FORM_FIELDS_REGEX
4748
from lib.core.settings import IGNORE_PARAMETERS
4849
from lib.core.settings import REFERER_ALIASES
@@ -317,18 +318,10 @@ def start():
317318
# TODO: consider the following line in __setRequestParams()
318319
# __testableParameters = True
319320

320-
proceed = False
321+
if len(kb.tested) > 0 and kb.tested == conf.tech:
322+
testSqlInj = False
321323

322-
if len(kb.injections) > 0:
323-
for resumedInj in kb.injections:
324-
for tech in conf.tech:
325-
if tech not in resumedInj.data:
326-
proceed = True
327-
break
328-
else:
329-
proceed = True
330-
331-
if proceed:
324+
if testSqlInj:
332325
if not conf.string and not conf.regexp:
333326
# NOTE: this is not needed anymore, leaving only to display
334327
# a warning message to the user in case the page is not stable
@@ -436,6 +429,8 @@ def start():
436429
warnMsg += "injectable"
437430
logger.warn(warnMsg)
438431

432+
setTestedTechniques()
433+
439434
if len(kb.injections) == 0 or (len(kb.injections) == 1 and kb.injections[0].place is None):
440435
if not conf.realTest:
441436
errMsg = "all parameters are not injectable."

lib/core/session.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ def unSafeFormatString(value):
4141
retVal = retVal.replace("__LEFT_SQUARE_BRACKET__", "[").replace("__RIGHT_SQUARE_BRACKET__", "]")
4242
return retVal
4343

44+
def setTestedTechniques():
45+
"""
46+
Save information retrieved about dynamic markings to the
47+
session file.
48+
"""
49+
50+
condition = (
51+
( not kb.resumedQueries
52+
or ( kb.resumedQueries.has_key(conf.url) and
53+
not kb.resumedQueries[conf.url].has_key("Tested techniques")) )
54+
or ( kb.resumedQueries[conf.url].has_key("Tested techniques")
55+
and base64unpickle(kb.resumedQueries[conf.url]["Tested techniques"][:-1]) != conf.tech
56+
) )
57+
58+
if condition:
59+
dataToSessionFile("[%s][%s][%s][Tested techniques][%s]\n" % (conf.url, None, None, base64pickle(conf.tech)))
60+
4461
def setInjection(inj):
4562
"""
4663
Save information retrieved about injection place and parameter in the
@@ -51,7 +68,7 @@ def setInjection(inj):
5168
or ( kb.resumedQueries.has_key(conf.url) and
5269
not kb.resumedQueries[conf.url].has_key("Injection data"))
5370
or ( kb.resumedQueries[conf.url].has_key("Injection data")
54-
and intersect(base64unpickle(kb.resumedQueries[conf.url]["Injection data"][:-1]).data.keys(),\
71+
and intersect(base64unpickle(kb.resumedQueries[conf.url]["Injection data"][:-1]).data.keys(), \
5572
inj.data.keys()) != inj.data.keys()
5673
) )
5774

@@ -165,7 +182,12 @@ def setXpCmdshellAvailability(available):
165182
dataToSessionFile("[%s][%s][%s][xp_cmdshell availability][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), str(available).lower()))
166183

167184
def resumeConfKb(expression, url, value):
168-
if expression == "Injection data" and url == conf.url:
185+
if expression == "Tested techniques" and url == conf.url:
186+
kb.tested.extend(base64unpickle(value[:-1]))
187+
kb.tested = list(set(kb.tested))
188+
kb.tested.sort()
189+
190+
elif expression == "Injection data" and url == conf.url:
169191
injection = base64unpickle(value[:-1])
170192

171193
if injection.place in conf.paramDict and \

0 commit comments

Comments
 (0)