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

Skip to content

Commit faf7814

Browse files
committed
fix for a fuzz "bug" reported by [email protected]
1 parent 08d6bb4 commit faf7814

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

lib/core/common.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def getForcedDbms():
366366

367367
@staticmethod
368368
def getDbms():
369-
return aliasToDbmsEnum(kb.dbms)
369+
return aliasToDbmsEnum(kb.dbms) if kb.get('dbms') else None
370370

371371
@staticmethod
372372
def getErrorParsedDBMSes():
@@ -388,11 +388,13 @@ def getErrorParsedDBMSes():
388388
def getIdentifiedDbms():
389389
dbms = None
390390

391-
if Backend.getForcedDbms() is not None:
391+
if not kb:
392+
pass
393+
elif Backend.getForcedDbms() is not None:
392394
dbms = Backend.getForcedDbms()
393395
elif Backend.getDbms() is not None:
394396
dbms = kb.dbms
395-
elif conf.dbms is not None:
397+
elif conf.get('dbms'):
396398
dbms = conf.dbms
397399
elif len(Backend.getErrorParsedDBMSes()) > 0:
398400
dbms = Backend.getErrorParsedDBMSes()[0]
@@ -2422,7 +2424,7 @@ def unhandledExceptionMessage():
24222424
errMsg += "Python version: %s\n" % PYVERSION
24232425
errMsg += "Operating system: %s\n" % PLATFORM
24242426
errMsg += "Command line: %s\n" % " ".join(sys.argv)
2425-
errMsg += "Technique: %s\n" % (enumValueToNameLookup(PAYLOAD.TECHNIQUE, kb.technique) if kb.technique else None)
2427+
errMsg += "Technique: %s\n" % (enumValueToNameLookup(PAYLOAD.TECHNIQUE, kb.technique) if kb and kb.technique else None)
24262428
errMsg += "Back-end DBMS: %s" % ("%s (fingerprinted)" % Backend.getDbms() if Backend.getDbms() is not None else "%s (identified)" % Backend.getIdentifiedDbms())
24272429
return maskSensitiveData(errMsg)
24282430

@@ -2433,7 +2435,7 @@ def maskSensitiveData(msg):
24332435

24342436
retVal = msg
24352437

2436-
for item in filter(lambda x: x, [conf.hostname, conf.googleDork, conf.aCred, conf.tbl, conf.db, conf.col, conf.user, conf.cookie]):
2438+
for item in filter(lambda x: conf.get(x), ['hostname', 'googleDork', 'aCred', 'tbl', 'db', 'col', 'user', 'cookie']):
24372439
regex = SENSITIVE_DATA_REGEX % item
24382440
while extractRegexResult(regex, retVal):
24392441
value = extractRegexResult(regex, retVal)

lib/parse/configfile.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
import codecs
1111

12-
from ConfigParser import NoSectionError
12+
from ConfigParser import MissingSectionHeaderError
1313

1414
from lib.core.common import checkFile
1515
from lib.core.common import UnicodeRawConfigParser
1616
from lib.core.data import conf
1717
from lib.core.data import logger
1818
from lib.core.exception import sqlmapMissingMandatoryOptionException
19+
from lib.core.exception import sqlmapSyntaxException
1920
from lib.core.optiondict import optDict
2021
from lib.core.settings import UNICODE_ENCODING
2122

@@ -60,11 +61,17 @@ def configFileParser(configFile):
6061

6162
checkFile(configFile)
6263
configFP = codecs.open(configFile, "rb", UNICODE_ENCODING)
63-
config = UnicodeRawConfigParser()
64-
config.readfp(configFP)
64+
65+
try:
66+
config = UnicodeRawConfigParser()
67+
config.readfp(configFP)
68+
except MissingSectionHeaderError:
69+
errMsg = "you've provided a non-valid configuration file"
70+
raise sqlmapSyntaxException, errMsg
6571

6672
if not config.has_section("Target"):
67-
raise NoSectionError, "Target in the configuration file is mandatory"
73+
errMsg = "missing a mandatory section 'Target' in the configuration file"
74+
raise sqlmapMissingMandatoryOptionException, errMsg
6875

6976
condition = not config.has_option("Target", "url")
7077
condition &= not config.has_option("Target", "logFile")

0 commit comments

Comments
 (0)