1#!/usr/bin/env python 2 3""" 4Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) 5See the file 'LICENSE' for copying permission 6""" 7 8from lib.core.common import Backend 9from lib.core.common import randomInt 10from lib.core.data import conf 11from lib.core.data import kb 12from lib.core.data import logger 13from lib.core.dicts import FROM_DUMMY_TABLE 14from lib.core.exception import SqlmapNotVulnerableException 15from lib.techniques.dns.use import dnsUse 16 17def dnsTest(payload): 18 logger.info("testing for data retrieval through DNS channel") 19 20 randInt = randomInt() 21 kb.dnsTest = dnsUse(payload, "SELECT %d%s" % (randInt, FROM_DUMMY_TABLE.get(Backend.getIdentifiedDbms(), ""))) == str(randInt) 22 23 if not kb.dnsTest: 24 errMsg = "data retrieval through DNS channel failed" 25 if not conf.forceDns: 26 conf.dnsDomain = None 27 errMsg += ". Turning off DNS exfiltration support" 28 logger.error(errMsg) 29 else: 30 raise SqlmapNotVulnerableException(errMsg) 31 else: 32 infoMsg = "data retrieval through DNS channel was successful" 33 logger.info(infoMsg) 34