mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-03 19:55:47 +03:00
Where things could go kaboom (changing terminal coloring)
This commit is contained in:
parent
a424e4ab59
commit
57be1856a6
|
@ -884,11 +884,7 @@ def setColor(message, bold=False):
|
||||||
retVal = colored(message, color=None, on_color=None, attrs=("bold",))
|
retVal = colored(message, color=None, on_color=None, attrs=("bold",))
|
||||||
elif level:
|
elif level:
|
||||||
level = getattr(logging, level, None) if isinstance(level, basestring) else level
|
level = getattr(logging, level, None) if isinstance(level, basestring) else level
|
||||||
_ = LOGGER_HANDLER.level_map.get(level)
|
retVal = LOGGER_HANDLER.colorize(message, level)
|
||||||
if _:
|
|
||||||
background, foreground, bold = _
|
|
||||||
retVal = colored(message, color=foreground, on_color="on_%s" % background if background else None, attrs=("bold",) if bold else None)
|
|
||||||
|
|
||||||
kb.stickyLevel = level if message and message[-1] != "\n" else None
|
kb.stickyLevel = level if message and message[-1] != "\n" else None
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
|
@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
|
||||||
from lib.core.enums import OS
|
from lib.core.enums import OS
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.2.7.4"
|
VERSION = "1.2.7.5"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||||
|
|
35
thirdparty/ansistrm/ansistrm.py
vendored
35
thirdparty/ansistrm/ansistrm.py
vendored
|
@ -1,6 +1,8 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
|
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
|
||||||
|
# (Note: 2018 modifications by @stamparm)
|
||||||
#
|
#
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -127,9 +129,9 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
||||||
|
|
||||||
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
|
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
|
||||||
|
|
||||||
def colorize(self, message, record):
|
def colorize(self, message, levelno):
|
||||||
if record.levelno in self.level_map and self.is_tty:
|
if levelno in self.level_map and self.is_tty:
|
||||||
bg, fg, bold = self.level_map[record.levelno]
|
bg, fg, bold = self.level_map[levelno]
|
||||||
params = []
|
params = []
|
||||||
|
|
||||||
if bg in self.color_map:
|
if bg in self.color_map:
|
||||||
|
@ -148,11 +150,32 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
||||||
else:
|
else:
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
|
||||||
message = "%s%s" % (prefix, ''.join((self.csi, ';'.join(params),
|
match = re.search(r"\[([A-Z]+)\]", message)
|
||||||
'm', message, self.reset)))
|
if match:
|
||||||
|
level = match.group(1)
|
||||||
|
if message.startswith("\x1b[1m"):
|
||||||
|
message = message.replace("\x1b[1m", "")
|
||||||
|
reset = self.reset + "\x1b[1m"
|
||||||
|
params.append('1')
|
||||||
|
else:
|
||||||
|
reset = self.reset
|
||||||
|
message = message.replace(level, ''.join((self.csi, ';'.join(params), 'm', level, reset)), 1)
|
||||||
|
else:
|
||||||
|
message = "%s%s" % (prefix, ''.join((self.csi, ';'.join(params), 'm', message, self.reset)))
|
||||||
|
|
||||||
|
match = re.search(r"\A\s*\[([\d:]+)\]", message)
|
||||||
|
if match:
|
||||||
|
time = match.group(1)
|
||||||
|
if not message.endswith(self.reset):
|
||||||
|
reset = self.reset
|
||||||
|
elif message.startswith("\x1b[1m"): # bold
|
||||||
|
reset = self.reset + "\x1b[1m"
|
||||||
|
else:
|
||||||
|
reset = self.reset
|
||||||
|
message = message.replace(time, ''.join((self.csi, str(self.color_map["cyan"] + 30), 'm', time, reset)), 1)
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
message = logging.StreamHandler.format(self, record)
|
message = logging.StreamHandler.format(self, record)
|
||||||
return self.colorize(message, record)
|
return self.colorize(message, record.levelno)
|
||||||
|
|
|
@ -28,7 +28,7 @@ c7443613a0a2505b1faec931cee2a6ef lib/controller/handler.py
|
||||||
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
|
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
|
||||||
0adf547455a76dc71e6a599e52da1ed9 lib/core/agent.py
|
0adf547455a76dc71e6a599e52da1ed9 lib/core/agent.py
|
||||||
fd8f239e259afaf5f24bcf34a0ad187f lib/core/bigarray.py
|
fd8f239e259afaf5f24bcf34a0ad187f lib/core/bigarray.py
|
||||||
6c3ba41569f9403aef6cd9312fe9b96e lib/core/common.py
|
ab2f7ecb7d3dff9afd05675031942e8e lib/core/common.py
|
||||||
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
|
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
|
||||||
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
|
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
|
||||||
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
|
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
|
||||||
|
@ -48,7 +48,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
|
||||||
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
|
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
|
||||||
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
|
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
|
||||||
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
|
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
|
||||||
af78e555614c7e1bf89c37271831b486 lib/core/settings.py
|
9f27c2f2abae2c21eb623f16abfeccf9 lib/core/settings.py
|
||||||
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
|
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
|
||||||
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
|
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
|
||||||
95f04c1c1d8c3998d86e1bdf0e12771c lib/core/target.py
|
95f04c1c1d8c3998d86e1bdf0e12771c lib/core/target.py
|
||||||
|
@ -285,7 +285,7 @@ fd1bff6caefe5007444f7a0fabbc8ce9 tamper/space2mysqlblank.py
|
||||||
929a2586dbb7b758a454eb09e13e5a73 tamper/versionedkeywords.py
|
929a2586dbb7b758a454eb09e13e5a73 tamper/versionedkeywords.py
|
||||||
3aff4d344ebd4f38e033e73b63f84447 tamper/versionedmorekeywords.py
|
3aff4d344ebd4f38e033e73b63f84447 tamper/versionedmorekeywords.py
|
||||||
ed1acafbac707bfa71c72f76b81c1bdd tamper/xforwardedfor.py
|
ed1acafbac707bfa71c72f76b81c1bdd tamper/xforwardedfor.py
|
||||||
368165b45dadcdff4422bc010700832a thirdparty/ansistrm/ansistrm.py
|
b743632abd4eee8654f98dcfdb753246 thirdparty/ansistrm/ansistrm.py
|
||||||
d41d8cd98f00b204e9800998ecf8427e thirdparty/ansistrm/__init__.py
|
d41d8cd98f00b204e9800998ecf8427e thirdparty/ansistrm/__init__.py
|
||||||
8e775c25bc9e84891ad6fcb4f0005c23 thirdparty/beautifulsoup/beautifulsoup.py
|
8e775c25bc9e84891ad6fcb4f0005c23 thirdparty/beautifulsoup/beautifulsoup.py
|
||||||
cb2e1fe7c404dff41a2ae9132828f532 thirdparty/beautifulsoup/__init__.py
|
cb2e1fe7c404dff41a2ae9132828f532 thirdparty/beautifulsoup/__init__.py
|
||||||
|
|
Loading…
Reference in New Issue
Block a user