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

Skip to content

Commit c00ea7f

Browse files
committed
Store and resume also UNION char to session file (--union-char)
1 parent 025361c commit c00ea7f

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

lib/core/session.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def setTimeBased(place, parameter, payload):
215215
if condition:
216216
dataToSessionFile("[%s][%s][%s][Time-based blind injection][%s]\n" % (conf.url, place, safeFormatString(conf.parameters[place]), payload))
217217

218-
def setUnion(comment=None, count=None, position=None, negative=False, falseCond=False, payload=None):
218+
def setUnion(comment=None, count=None, position=None, negative=False, falseCond=False, char=None, payload=None):
219219
"""
220220
@param comment: union comment to save in session file
221221
@type comment: C{str}
@@ -284,6 +284,16 @@ def setUnion(comment=None, count=None, position=None, negative=False, falseCond=
284284

285285
kb.unionFalseCond = True
286286

287+
if char:
288+
condition = (
289+
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
290+
( not kb.resumedQueries[conf.url].has_key("Union char")
291+
) )
292+
)
293+
294+
if condition:
295+
dataToSessionFile("[%s][%s][%s][Union char][%s]\n" % (conf.url, kb.injection.place, safeFormatString(conf.parameters[kb.injection.place]), char))
296+
287297
if payload:
288298
condition = (
289299
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
@@ -568,6 +578,12 @@ def resumeConfKb(expression, url, value):
568578
logMsg = "resuming union false condition from session file"
569579
logger.info(logMsg)
570580

581+
elif expression == "Union char" and url == conf.url:
582+
conf.uChar = value[:-1]
583+
584+
logMsg = "resuming union char %s from session file" % conf.uChar
585+
logger.info(logMsg)
586+
571587
elif expression == "Union payload" and url == conf.url:
572588
kb.unionTest = value[:-1]
573589

lib/techniques/inband/union/test.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,24 @@ def unionTest():
138138
infoMsg += "'%s' with %s technique" % (kb.injection.parameter, technique)
139139
logger.info(infoMsg)
140140

141-
validPayload = None
142141
comment = queries[kb.dbms].comment.query
143-
144142
validPayload = __unionTestByCharBruteforce(comment)
145143

146144
if validPayload:
145+
validPayload = agent.removePayloadDelimiters(validPayload, False)
146+
setUnion(char=conf.uChar)
147147
setUnion(comment=comment)
148+
setUnion(payload=validPayload)
148149

149-
if isinstance(kb.unionPosition, int):
150-
infoMsg = "the target url is affected by an exploitable "
150+
if kb.unionTest is not None:
151+
infoMsg = "the target url is affected by an exploitable "
151152
infoMsg += "inband sql injection vulnerability "
152153
infoMsg += "on parameter '%s' with %d columns" % (kb.injection.parameter, kb.unionCount)
153154
logger.info(infoMsg)
154155
else:
155-
infoMsg = "the target url is not affected by an exploitable "
156+
infoMsg = "the target url is not affected by an exploitable "
156157
infoMsg += "inband sql injection vulnerability "
157158
infoMsg += "on parameter '%s'" % kb.injection.parameter
158159
logger.info(infoMsg)
159160

160-
validPayload = agent.removePayloadDelimiters(validPayload, False)
161-
setUnion(payload=validPayload)
162-
163161
return kb.unionTest

0 commit comments

Comments
 (0)