diff --git a/lib/core/dump.py b/lib/core/dump.py index 520ab4779..79a7976f2 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -79,18 +79,19 @@ class Dump(object): elif console: dataToStdout(text) - multiThreadMode = kb.multiThreadMode - if multiThreadMode: - self._lock.acquire() + if self._outputFP: + multiThreadMode = kb.multiThreadMode + if multiThreadMode: + self._lock.acquire() - try: - self._outputFP.write(text) - except IOError as ex: - errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex) - raise SqlmapGenericException(errMsg) + try: + self._outputFP.write(text) + except IOError as ex: + errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex) + raise SqlmapGenericException(errMsg) - if multiThreadMode: - self._lock.release() + if multiThreadMode: + self._lock.release() kb.dataOutputFlag = True @@ -102,6 +103,10 @@ class Dump(object): pass def setOutputFile(self): + if conf.noLogging: + self._outputFP = None + return + self._outputFile = os.path.join(conf.outputPath, "log") try: self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb") diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index a8626de30..ef5d413f6 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -243,6 +243,7 @@ optDict = { "dependencies": "boolean", "disableColoring": "boolean", "listTampers": "boolean", + "noLogging": "boolean", "offline": "boolean", "purge": "boolean", "resultsFile": "string", diff --git a/lib/core/settings.py b/lib/core/settings.py index e68bb0bd9..bed5e4e30 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from thirdparty import six from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.6.3.18" +VERSION = "1.6.3.19" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index b1c5a2166..6409fea28 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -745,6 +745,9 @@ def cmdLineParser(argv=None): miscellaneous.add_argument("--list-tampers", dest="listTampers", action="store_true", help="Display list of available tamper scripts") + miscellaneous.add_argument("--no-logging", dest="noLogging", action="store_true", + help="Disable logging to a file") + miscellaneous.add_argument("--offline", dest="offline", action="store_true", help="Work in offline mode (only use session data)") diff --git a/sqlmap.conf b/sqlmap.conf index cc724d3a0..9504b7b46 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -833,10 +833,14 @@ dependencies = False # Valid: True or False disableColoring = False -# Display list of available tamper scripts +# Display list of available tamper scripts. # Valid: True or False listTampers = False +# Disable logging to a file. +# Valid: True or False +noLogging = False + # Work in offline mode (only use session data) # Valid: True or False offline = False