From 1e9ae795bb74ffb92242205f50855f08bae06c25 Mon Sep 17 00:00:00 2001 From: LoRexxar Date: Mon, 14 Sep 2020 15:18:41 +0800 Subject: [PATCH] fix logger display --- core/cast.py | 2 +- core/cli.py | 2 +- core/detection.py | 2 +- utils/file.py | 2 +- utils/log.py | 2 +- utils/utils.py | 5 +---- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/cast.py b/core/cast.py index 9bdb5d4a..23515335 100644 --- a/core/cast.py +++ b/core/cast.py @@ -157,7 +157,7 @@ def block_code(self, block_position): """ if block_position == 2: if self.line is None or self.line == 0: - logger.critical("[AST] Line exception: {0}".format(self.line)) + logger.error("[AST] Line exception: {0}".format(self.line)) return False line_rule = '{0}p'.format(self.line) code = File(self.file_path).lines(line_rule) diff --git a/core/cli.py b/core/cli.py index 36164594..2ed869aa 100644 --- a/core/cli.py +++ b/core/cli.py @@ -194,7 +194,7 @@ def start(target, formatter, output, special_rules, a_sid=None, language=None, t language=main_language, framework=main_framework, file_count=file_count, extension_count=len(files), files=files, tamper_name=tamper_name, is_unconfirm=is_unconfirm) except KeyboardInterrupt as e: - logger.critical("[!] KeyboardInterrupt, exit...") + logger.error("[!] KeyboardInterrupt, exit...") exit() except Exception: result = { diff --git a/core/detection.py b/core/detection.py index e2202b3d..1d7e3580 100644 --- a/core/detection.py +++ b/core/detection.py @@ -49,7 +49,7 @@ def language(self): language_extensions = {} xml_languages = self._read_xml('languages.xml') if xml_languages is None: - logger.critical('languages read failed!!!') + logger.error('languages read failed!!!') languages = None for language in xml_languages: l_name = language.get('name').lower() diff --git a/utils/file.py b/utils/file.py index 8be11a4a..f0b9e5b1 100644 --- a/utils/file.py +++ b/utils/file.py @@ -496,7 +496,7 @@ def files(self, absolute_path, level=1): self.file_info(directory, filename) except OSError as e: logger.error("[PICKUP] {}".format(traceback.format_exc())) - logger.critical('[PICKUP] {msg}'.format(msg=e)) + logger.error('[PICKUP] {msg}'.format(msg=e)) exit() def file_info(self, path, filename): diff --git a/utils/log.py b/utils/log.py index 6324d0b2..480ff91e 100644 --- a/utils/log.py +++ b/utils/log.py @@ -34,7 +34,7 @@ def log(loglevel, log_name): handler = colorlog.StreamHandler() handler.setFormatter( colorlog.ColoredFormatter( - fmt='%(log_color)s[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] %(message)s', + fmt='[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] %(message)s', datefmt="%H:%M:%S", log_colors={ 'DEBUG': 'cyan', diff --git a/utils/utils.py b/utils/utils.py index da412a8f..e40fbfbe 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -414,10 +414,7 @@ def secure_filename(filename): _filename_utf8_strip_re = re.compile(u"[^\u4e00-\u9fa5A-Za-z0-9_.\-\+]") _windows_device_files = ('CON', 'AUX', 'COM1', 'COM2', 'COM3', 'COM4', 'LPT1', 'LPT2', 'LPT3', 'PRN', 'NUL') - try: - text_type = unicode # Python 2 - except NameError: - text_type = str # Python 3 + text_type = str # Python 3 if isinstance(filename, text_type): from unicodedata import normalize