Implementing switch --no-logging (#4484)

This commit is contained in:
Miroslav Stampar 2022-03-25 19:10:46 +01:00
parent 582bb2fec9
commit e2f48a9346
5 changed files with 25 additions and 12 deletions

View File

@ -79,18 +79,19 @@ class Dump(object):
elif console: elif console:
dataToStdout(text) dataToStdout(text)
multiThreadMode = kb.multiThreadMode if self._outputFP:
if multiThreadMode: multiThreadMode = kb.multiThreadMode
self._lock.acquire() if multiThreadMode:
self._lock.acquire()
try: try:
self._outputFP.write(text) self._outputFP.write(text)
except IOError as ex: except IOError as ex:
errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex) errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex)
raise SqlmapGenericException(errMsg) raise SqlmapGenericException(errMsg)
if multiThreadMode: if multiThreadMode:
self._lock.release() self._lock.release()
kb.dataOutputFlag = True kb.dataOutputFlag = True
@ -102,6 +103,10 @@ class Dump(object):
pass pass
def setOutputFile(self): def setOutputFile(self):
if conf.noLogging:
self._outputFP = None
return
self._outputFile = os.path.join(conf.outputPath, "log") self._outputFile = os.path.join(conf.outputPath, "log")
try: try:
self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb") self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb")

View File

@ -243,6 +243,7 @@ optDict = {
"dependencies": "boolean", "dependencies": "boolean",
"disableColoring": "boolean", "disableColoring": "boolean",
"listTampers": "boolean", "listTampers": "boolean",
"noLogging": "boolean",
"offline": "boolean", "offline": "boolean",
"purge": "boolean", "purge": "boolean",
"resultsFile": "string", "resultsFile": "string",

View File

@ -20,7 +20,7 @@ from thirdparty import six
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.6.3.18" VERSION = "1.6.3.19"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -745,6 +745,9 @@ def cmdLineParser(argv=None):
miscellaneous.add_argument("--list-tampers", dest="listTampers", action="store_true", miscellaneous.add_argument("--list-tampers", dest="listTampers", action="store_true",
help="Display list of available tamper scripts") 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", miscellaneous.add_argument("--offline", dest="offline", action="store_true",
help="Work in offline mode (only use session data)") help="Work in offline mode (only use session data)")

View File

@ -833,10 +833,14 @@ dependencies = False
# Valid: True or False # Valid: True or False
disableColoring = False disableColoring = False
# Display list of available tamper scripts # Display list of available tamper scripts.
# Valid: True or False # Valid: True or False
listTampers = False listTampers = False
# Disable logging to a file.
# Valid: True or False
noLogging = False
# Work in offline mode (only use session data) # Work in offline mode (only use session data)
# Valid: True or False # Valid: True or False
offline = False offline = False