2019-03-21 16:00:09 +03:00
|
|
|
#!/usr/bin/env python2
|
2012-07-10 06:00:21 +04:00
|
|
|
|
|
|
|
"""
|
2019-01-05 23:38:52 +03:00
|
|
|
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2012-07-10 06:00:21 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from lib.core.enums import CUSTOM_LOGGING
|
|
|
|
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.PAYLOAD, "PAYLOAD")
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_OUT, "TRAFFIC OUT")
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_IN, "TRAFFIC IN")
|
|
|
|
|
|
|
|
LOGGER = logging.getLogger("sqlmapLog")
|
2012-07-10 16:08:37 +04:00
|
|
|
|
2012-12-12 17:22:24 +04:00
|
|
|
LOGGER_HANDLER = None
|
2012-07-10 16:08:37 +04:00
|
|
|
try:
|
2013-01-16 19:33:04 +04:00
|
|
|
from thirdparty.ansistrm.ansistrm import ColorizingStreamHandler
|
|
|
|
|
2013-02-07 18:19:07 +04:00
|
|
|
disableColor = False
|
2013-02-07 01:04:54 +04:00
|
|
|
|
|
|
|
for argument in sys.argv:
|
|
|
|
if "disable-col" in argument:
|
2013-02-07 18:19:07 +04:00
|
|
|
disableColor = True
|
2013-02-07 01:04:54 +04:00
|
|
|
break
|
|
|
|
|
2013-02-07 18:19:07 +04:00
|
|
|
if disableColor:
|
2013-02-07 01:04:54 +04:00
|
|
|
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)
|
|
|
|
else:
|
|
|
|
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
|
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("PAYLOAD")] = (None, "cyan", False)
|
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC OUT")] = (None, "magenta", False)
|
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC IN")] = ("magenta", None, False)
|
2012-07-10 16:08:37 +04:00
|
|
|
except ImportError:
|
|
|
|
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)
|
|
|
|
|
2012-07-10 06:00:21 +04:00
|
|
|
FORMATTER = logging.Formatter("\r[%(asctime)s] [%(levelname)s] %(message)s", "%H:%M:%S")
|
|
|
|
|
|
|
|
LOGGER_HANDLER.setFormatter(FORMATTER)
|
|
|
|
LOGGER.addHandler(LOGGER_HANDLER)
|
2015-01-26 10:59:10 +03:00
|
|
|
LOGGER.setLevel(logging.INFO)
|