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

Skip to content

Commit 47073f4

Browse files
committed
Implementation of an Issue #131
1 parent 93d35fe commit 47073f4

3 files changed

Lines changed: 30 additions & 22 deletions

File tree

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ def cmdLineParser():
655655
parser.add_option("--cpu-throttle", dest="cpuThrottle", type="int",
656656
help=SUPPRESS_HELP)
657657

658+
parser.add_option("--force-dns", dest="forceDns", action="store_true",
659+
help=SUPPRESS_HELP)
660+
658661
parser.add_option("--smoke-test", dest="smokeTest", action="store_true",
659662
help=SUPPRESS_HELP)
660663

lib/request/inject.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -395,24 +395,25 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
395395
if query and not 'COUNT(*)' in query:
396396
query = query.replace("DISTINCT ", "")
397397

398-
if inband and isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION):
399-
kb.technique = PAYLOAD.TECHNIQUE.UNION
400-
value = __goInband(forgeCaseExpression if expected == EXPECTED.BOOL else query, unpack, dump)
401-
count += 1
402-
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
403-
404-
if error and isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) and not found:
405-
kb.technique = PAYLOAD.TECHNIQUE.ERROR
406-
value = errorUse(forgeCaseExpression if expected == EXPECTED.BOOL else query, dump)
407-
count += 1
408-
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
409-
410-
if found and conf.dnsName:
411-
_ = "".join(filter(None, (key if isTechniqueAvailable(value) else None for key, value in {"E":PAYLOAD.TECHNIQUE.ERROR, "U":PAYLOAD.TECHNIQUE.UNION}.items())))
412-
warnMsg = "option '--dns-domain' will be ignored "
413-
warnMsg += "as faster techniques are usable "
414-
warnMsg += "(%s) " % _
415-
singleTimeWarnMessage(warnMsg)
398+
if not conf.forceDns:
399+
if inband and isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION):
400+
kb.technique = PAYLOAD.TECHNIQUE.UNION
401+
value = __goInband(forgeCaseExpression if expected == EXPECTED.BOOL else query, unpack, dump)
402+
count += 1
403+
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
404+
405+
if error and isTechniqueAvailable(PAYLOAD.TECHNIQUE.ERROR) and not found:
406+
kb.technique = PAYLOAD.TECHNIQUE.ERROR
407+
value = errorUse(forgeCaseExpression if expected == EXPECTED.BOOL else query, dump)
408+
count += 1
409+
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
410+
411+
if found and conf.dnsName:
412+
_ = "".join(filter(None, (key if isTechniqueAvailable(value) else None for key, value in {"E":PAYLOAD.TECHNIQUE.ERROR, "U":PAYLOAD.TECHNIQUE.UNION}.items())))
413+
warnMsg = "option '--dns-domain' will be ignored "
414+
warnMsg += "as faster techniques are usable "
415+
warnMsg += "(%s) " % _
416+
singleTimeWarnMessage(warnMsg)
416417

417418
if blind and isTechniqueAvailable(PAYLOAD.TECHNIQUE.BOOLEAN) and not found:
418419
kb.technique = PAYLOAD.TECHNIQUE.BOOLEAN

lib/techniques/dns/test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from lib.core.data import conf
1111
from lib.core.data import kb
1212
from lib.core.data import logger
13+
from lib.core.exception import sqlmapNotVulnerableException
1314
from lib.core.settings import FROM_DUMMY_TABLE
1415
from lib.techniques.dns.use import dnsUse
1516

@@ -21,10 +22,13 @@ def dnsTest(payload):
2122
kb.dnsTest = dnsUse(payload, "SELECT %d%s" % (randInt, FROM_DUMMY_TABLE.get(Backend.getIdentifiedDbms(), ""))) == str(randInt)
2223

2324
if not kb.dnsTest:
24-
errMsg = "data retrieval through DNS channel failed. Turning off DNS exfiltration support"
25-
logger.error(errMsg)
26-
27-
conf.dnsName = None
25+
errMsg = "data retrieval through DNS channel failed"
26+
if not conf.forceDns:
27+
conf.dnsName = None
28+
errMsg += ". Turning off DNS exfiltration support"
29+
logger.error(errMsg)
30+
else:
31+
raise sqlmapNotVulnerableException, errMsg
2832
else:
2933
infoMsg = "data retrieval through DNS channel was successful"
3034
logger.info(infoMsg)

0 commit comments

Comments
 (0)