Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/lib/techniques/dns/test.py
2992 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
from lib.core.common import Backend
9
from lib.core.common import randomInt
10
from lib.core.data import conf
11
from lib.core.data import kb
12
from lib.core.data import logger
13
from lib.core.dicts import FROM_DUMMY_TABLE
14
from lib.core.exception import SqlmapNotVulnerableException
15
from lib.techniques.dns.use import dnsUse
16
17
def 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
35