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

Skip to content

Commit ad612bf

Browse files
committed
Patch for Windows banner display
1 parent 9dd5cd8 commit ad612bf

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
from lib.utils.sqlalchemy import _sqlalchemy
152152
from thirdparty.clientform.clientform import ParseResponse
153153
from thirdparty.clientform.clientform import ParseError
154+
from thirdparty.colorama.initialise import init as coloramainit
154155
from thirdparty.magic import magic
155156
from thirdparty.odict.odict import OrderedDict
156157
from thirdparty.termcolor.termcolor import colored
@@ -1068,11 +1069,14 @@ def banner():
10681069
This function prints sqlmap banner with its version
10691070
"""
10701071

1071-
10721072
if not any(_ in sys.argv for _ in ("--version", "--pickled-options")):
10731073
_ = BANNER
1074-
if not getattr(LOGGER_HANDLER, "is_tty", False):
1074+
1075+
if not getattr(LOGGER_HANDLER, "is_tty", False) or "--disable-coloring" in sys.argv:
10751076
_ = re.sub("\033.+?m", "", _)
1077+
elif IS_WIN:
1078+
coloramainit()
1079+
10761080
dataToStdout(_, forceOutput=True)
10771081

10781082
def parsePasswordHash(password):

lib/core/option.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151
from lib.utils.deps import checkDependencies
152152
from lib.utils.search import search
153153
from lib.utils.purge import purge
154-
from thirdparty.colorama.initialise import init as coloramainit
155154
from thirdparty.keepalive import keepalive
156155
from thirdparty.oset.pyoset import oset
157156
from thirdparty.socks import socks
@@ -2532,9 +2531,6 @@ def _resolveCrossReferences():
25322531
lib.controller.checks.setVerbosity = setVerbosity
25332532

25342533
def initOptions(inputOptions=AttribDict(), overrideOptions=False):
2535-
if IS_WIN:
2536-
coloramainit()
2537-
25382534
_setConfAttributes()
25392535
_setKnowledgeBaseAttributes()
25402536
_mergeOptions(inputOptions, overrideOptions)

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.revision import getRevisionNumber
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.0.4.22"
22+
VERSION = "1.0.4.23"
2323
REVISION = getRevisionNumber()
2424
STABLE = VERSION.count('.') <= 2
2525
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")

thirdparty/colorama/initialise.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ def reset_all():
2121

2222

2323
def init(autoreset=False, convert=None, strip=None, wrap=True):
24+
global wrapped_stdout, wrapped_stderr
25+
global orig_stdout, orig_stderr
26+
27+
if orig_stdout is not None:
28+
return
2429

2530
if not wrap and any([autoreset, convert, strip]):
2631
raise ValueError('wrap=False conflicts with any other arg=True')
2732

28-
global wrapped_stdout, wrapped_stderr
29-
global orig_stdout, orig_stderr
30-
3133
orig_stdout = sys.stdout
3234
orig_stderr = sys.stderr
3335

@@ -49,10 +51,15 @@ def init(autoreset=False, convert=None, strip=None, wrap=True):
4951

5052

5153
def deinit():
54+
global orig_stdout
55+
global orig_stderr
56+
5257
if orig_stdout is not None:
5358
sys.stdout = orig_stdout
59+
orig_stdout = None
5460
if orig_stderr is not None:
5561
sys.stderr = orig_stderr
62+
orig_stderr = None
5663

5764

5865
@contextlib.contextmanager

0 commit comments

Comments
 (0)