Implementation of an Issue #149

This commit is contained in:
Miroslav Stampar 2012-08-15 22:31:25 +02:00
parent f358ab2e73
commit 1af81c0de4
5 changed files with 17 additions and 2 deletions

View File

@ -77,6 +77,7 @@ from lib.core.exception import sqlmapSyntaxException
from lib.core.exception import sqlmapUnsupportedDBMSException from lib.core.exception import sqlmapUnsupportedDBMSException
from lib.core.exception import sqlmapUserQuitException from lib.core.exception import sqlmapUserQuitException
from lib.core.log import FORMATTER from lib.core.log import FORMATTER
from lib.core.log import LOGGER_HANDLER
from lib.core.optiondict import optDict from lib.core.optiondict import optDict
from lib.core.purge import purge from lib.core.purge import purge
from lib.core.settings import CODECS_LIST_PAGE from lib.core.settings import CODECS_LIST_PAGE
@ -1995,7 +1996,11 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
based upon command line and configuration file options. based upon command line and configuration file options.
""" """
coloramainit() if not inputOptions.disableColoring:
coloramainit()
else:
if hasattr(LOGGER_HANDLER, "disable_coloring"):
LOGGER_HANDLER.disable_coloring = True
__setConfAttributes() __setConfAttributes()
__setKnowledgeBaseAttributes() __setKnowledgeBaseAttributes()
__mergeOptions(inputOptions, overrideOptions) __mergeOptions(inputOptions, overrideOptions)

View File

@ -192,6 +192,7 @@ optDict = {
"checkPayload": "boolean", "checkPayload": "boolean",
"cleanup": "boolean", "cleanup": "boolean",
"dependencies": "boolean", "dependencies": "boolean",
"disableColoring": "boolean",
"googlePage": "integer", "googlePage": "integer",
"mobile": "boolean", "mobile": "boolean",
"pageRank": "boolean", "pageRank": "boolean",

View File

@ -619,6 +619,10 @@ def cmdLineParser():
action="store_true", action="store_true",
help="Check for missing sqlmap dependencies") help="Check for missing sqlmap dependencies")
miscellaneous.add_option("--disable-coloring", dest="disableColoring",
action="store_true",
help="Disable console output coloring")
miscellaneous.add_option("--gpage", dest="googlePage", type="int", miscellaneous.add_option("--gpage", dest="googlePage", type="int",
help="Use Google dork results from specified page number") help="Use Google dork results from specified page number")

View File

@ -660,6 +660,10 @@ cleanup = False
# Valid: True or False # Valid: True or False
dependencies = False dependencies = False
# Disable console output coloring.
# Valid: True or False
disableColoring = False
# Use Google dork results from specified page number. # Use Google dork results from specified page number.
# Valid: integer # Valid: integer
# Default: 1 # Default: 1

View File

@ -39,11 +39,12 @@ class ColorizingStreamHandler(logging.StreamHandler):
} }
csi = '\x1b[' csi = '\x1b['
reset = '\x1b[0m' reset = '\x1b[0m'
disable_coloring = False
@property @property
def is_tty(self): def is_tty(self):
isatty = getattr(self.stream, 'isatty', None) isatty = getattr(self.stream, 'isatty', None)
return isatty and isatty() return isatty and isatty() and not self.disable_coloring
def emit(self, record): def emit(self, record):
try: try: