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

Skip to content

Commit 0795760

Browse files
committed
Minor fix
1 parent 75edb84 commit 0795760

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

lib/core/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,13 @@ def dataToTrafficFile(data):
730730
if not conf.trafficFile:
731731
return
732732

733-
conf.trafficFP.write(data)
734-
conf.trafficFP.flush()
733+
try:
734+
conf.trafficFP.write(data)
735+
conf.trafficFP.flush()
736+
except IOError, ex:
737+
errMsg = "something went wrong while trying "
738+
errMsg += "to write to the traffic file '%s' ('%s')" % (conf.trafficFile, ex)
739+
raise SqlmapGenericException, errMsg
735740

736741
def dataToDumpFile(dumpFile, data):
737742
dumpFile.write(data)

lib/core/target.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ def _createTargetDirs():
426426
if not os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
427427
try:
428428
os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755)
429-
except OSError, msg:
429+
except OSError, ex:
430430
tempDir = tempfile.mkdtemp(prefix='output')
431431
warnMsg = "unable to create default root output directory "
432-
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, msg)
432+
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, ex)
433433
warnMsg += "using temporary directory '%s' instead" % tempDir
434434
logger.warn(warnMsg)
435435

@@ -440,10 +440,10 @@ def _createTargetDirs():
440440
if not os.path.isdir(conf.outputPath):
441441
try:
442442
os.makedirs(conf.outputPath, 0755)
443-
except OSError, msg:
443+
except OSError, ex:
444444
tempDir = tempfile.mkdtemp(prefix='output')
445445
warnMsg = "unable to create output directory "
446-
warnMsg += "'%s' (%s). " % (conf.outputPath, msg)
446+
warnMsg += "'%s' (%s). " % (conf.outputPath, ex)
447447
warnMsg += "using temporary directory '%s' instead" % tempDir
448448
logger.warn(warnMsg)
449449

@@ -453,12 +453,12 @@ def _createTargetDirs():
453453
with open(os.path.join(conf.outputPath, "target.txt"), "w+") as f:
454454
_ = kb.originalUrls.get(conf.url) or conf.url or conf.hostname
455455
f.write(_.encode(UNICODE_ENCODING))
456-
except IOError, msg:
457-
if "denied" in str(msg):
456+
except IOError, ex:
457+
if "denied" in str(ex):
458458
errMsg = "you don't have enough permissions "
459459
else:
460460
errMsg = "something went wrong while trying "
461-
errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, msg)
461+
errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, ex)
462462

463463
raise SqlmapMissingPrivileges, errMsg
464464

0 commit comments

Comments
 (0)