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

Skip to content

Commit 953b581

Browse files
committed
Implementation for an Issue #496
1 parent 6b826ef commit 953b581

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
16011601
kb.errorIsNone = True
16021602
kb.fileReadMode = False
16031603
kb.forcedDbms = None
1604+
kb.forcePartialUnion = False
16041605
kb.headersFp = {}
16051606
kb.heuristicDbms = None
16061607
kb.heuristicMode = False

lib/request/inject.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,18 @@ def getValue(expression, blind=True, union=True, error=True, time=True, fromUser
361361
count += 1
362362
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
363363

364+
if not found and not expected and kb.injection.data[PAYLOAD.TECHNIQUE.UNION].where == PAYLOAD.WHERE.ORIGINAL:
365+
warnMsg = "something went wrong with full UNION "
366+
warnMsg += "technique (most probably because of "
367+
warnMsg += "limitation on retrieved number of entries). "
368+
warnMsg += "Falling back to partial UNION technique"
369+
singleTimeWarnMessage(warnMsg)
370+
371+
kb.forcePartialUnion = True
372+
value = _goUnion(query, unpack, dump)
373+
found = (value is not None) or (value is None and expectingNone)
374+
kb.forcePartialUnion = False
375+
364376
if error and any(isTechniqueAvailable(_) for _ in (PAYLOAD.TECHNIQUE.ERROR, PAYLOAD.TECHNIQUE.QUERY)) and not found:
365377
kb.technique = PAYLOAD.TECHNIQUE.ERROR if isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) else PAYLOAD.TECHNIQUE.QUERY
366378
value = errorUse(forgeCaseExpression if expected == EXPECTED.BOOL else query, dump)

lib/techniques/union/use.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def unionUse(expression, unpack=True, dump=False):
184184
" FROM " in expression.upper() and ((Backend.getIdentifiedDbms() \
185185
not in FROM_DUMMY_TABLE) or (Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE \
186186
and not expression.upper().endswith(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]))) \
187-
and not re.search(SQL_SCALAR_REGEX, expression, re.I):
187+
and not re.search(SQL_SCALAR_REGEX, expression, re.I)\
188+
or kb.forcePartialUnion:
188189
expression, limitCond, topLimit, startLimit, stopLimit = agent.limitCondition(expression, dump)
189190

190191
if limitCond:

0 commit comments

Comments
 (0)