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

Skip to content

Commit 1af81c0

Browse files
committed
Implementation of an Issue #149
1 parent f358ab2 commit 1af81c0

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/core/option.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
from lib.core.exception import sqlmapUnsupportedDBMSException
7878
from lib.core.exception import sqlmapUserQuitException
7979
from lib.core.log import FORMATTER
80+
from lib.core.log import LOGGER_HANDLER
8081
from lib.core.optiondict import optDict
8182
from lib.core.purge import purge
8283
from lib.core.settings import CODECS_LIST_PAGE
@@ -1995,7 +1996,11 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
19951996
based upon command line and configuration file options.
19961997
"""
19971998

1998-
coloramainit()
1999+
if not inputOptions.disableColoring:
2000+
coloramainit()
2001+
else:
2002+
if hasattr(LOGGER_HANDLER, "disable_coloring"):
2003+
LOGGER_HANDLER.disable_coloring = True
19992004
__setConfAttributes()
20002005
__setKnowledgeBaseAttributes()
20012006
__mergeOptions(inputOptions, overrideOptions)

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
"checkPayload": "boolean",
193193
"cleanup": "boolean",
194194
"dependencies": "boolean",
195+
"disableColoring": "boolean",
195196
"googlePage": "integer",
196197
"mobile": "boolean",
197198
"pageRank": "boolean",

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ def cmdLineParser():
619619
action="store_true",
620620
help="Check for missing sqlmap dependencies")
621621

622+
miscellaneous.add_option("--disable-coloring", dest="disableColoring",
623+
action="store_true",
624+
help="Disable console output coloring")
625+
622626
miscellaneous.add_option("--gpage", dest="googlePage", type="int",
623627
help="Use Google dork results from specified page number")
624628

sqlmap.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ cleanup = False
660660
# Valid: True or False
661661
dependencies = False
662662

663+
# Disable console output coloring.
664+
# Valid: True or False
665+
disableColoring = False
666+
663667
# Use Google dork results from specified page number.
664668
# Valid: integer
665669
# Default: 1

thirdparty/ansistrm/ansistrm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ class ColorizingStreamHandler(logging.StreamHandler):
3939
}
4040
csi = '\x1b['
4141
reset = '\x1b[0m'
42+
disable_coloring = False
4243

4344
@property
4445
def is_tty(self):
4546
isatty = getattr(self.stream, 'isatty', None)
46-
return isatty and isatty()
47+
return isatty and isatty() and not self.disable_coloring
4748

4849
def emit(self, record):
4950
try:

0 commit comments

Comments
 (0)