Skip to content

Commit e2f48a9

Browse files
committed
Implementing switch --no-logging (#4484)
1 parent 582bb2f commit e2f48a9

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

lib/core/dump.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,19 @@ def _write(self, data, newline=True, console=True, content_type=None):
7979
elif console:
8080
dataToStdout(text)
8181

82-
multiThreadMode = kb.multiThreadMode
83-
if multiThreadMode:
84-
self._lock.acquire()
82+
if self._outputFP:
83+
multiThreadMode = kb.multiThreadMode
84+
if multiThreadMode:
85+
self._lock.acquire()
8586

86-
try:
87-
self._outputFP.write(text)
88-
except IOError as ex:
89-
errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex)
90-
raise SqlmapGenericException(errMsg)
87+
try:
88+
self._outputFP.write(text)
89+
except IOError as ex:
90+
errMsg = "error occurred while writing to log file ('%s')" % getSafeExString(ex)
91+
raise SqlmapGenericException(errMsg)
9192

92-
if multiThreadMode:
93-
self._lock.release()
93+
if multiThreadMode:
94+
self._lock.release()
9495

9596
kb.dataOutputFlag = True
9697

@@ -102,6 +103,10 @@ def flush(self):
102103
pass
103104

104105
def setOutputFile(self):
106+
if conf.noLogging:
107+
self._outputFP = None
108+
return
109+
105110
self._outputFile = os.path.join(conf.outputPath, "log")
106111
try:
107112
self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb")

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
"dependencies": "boolean",
244244
"disableColoring": "boolean",
245245
"listTampers": "boolean",
246+
"noLogging": "boolean",
246247
"offline": "boolean",
247248
"purge": "boolean",
248249
"resultsFile": "string",

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.6.3.18"
23+
VERSION = "1.6.3.19"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ def cmdLineParser(argv=None):
745745
miscellaneous.add_argument("--list-tampers", dest="listTampers", action="store_true",
746746
help="Display list of available tamper scripts")
747747

748+
miscellaneous.add_argument("--no-logging", dest="noLogging", action="store_true",
749+
help="Disable logging to a file")
750+
748751
miscellaneous.add_argument("--offline", dest="offline", action="store_true",
749752
help="Work in offline mode (only use session data)")
750753

sqlmap.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,14 @@ dependencies = False
833833
# Valid: True or False
834834
disableColoring = False
835835

836-
# Display list of available tamper scripts
836+
# Display list of available tamper scripts.
837837
# Valid: True or False
838838
listTampers = False
839839

840+
# Disable logging to a file.
841+
# Valid: True or False
842+
noLogging = False
843+
840844
# Work in offline mode (only use session data)
841845
# Valid: True or False
842846
offline = False

0 commit comments

Comments
 (0)