Skip to content

Commit 2546022

Browse files
committed
Minor update
1 parent 688150c commit 2546022

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
from lib.core.settings import INFERENCE_UNKNOWN_CHAR
134134
from lib.core.settings import IP_ADDRESS_REGEX
135135
from lib.core.settings import ISSUES_PAGE
136+
from lib.core.settings import IS_TTY
136137
from lib.core.settings import IS_WIN
137138
from lib.core.settings import LARGE_OUTPUT_THRESHOLD
138139
from lib.core.settings import LOCALHOST
@@ -928,7 +929,7 @@ def setColor(message, color=None, bold=False, level=None, istty=None):
928929
retVal = message
929930
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
930931

931-
if message and getattr(LOGGER_HANDLER, "is_tty", False) or istty: # colorizing handler
932+
if message and IS_TTY or istty: # colorizing handler
932933
if bold or color:
933934
retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None)
934935
elif level:
@@ -1064,7 +1065,7 @@ def readInput(message, default=None, checkBatch=True, boolean=False):
10641065
elif answer is None and retVal:
10651066
retVal = "%s,%s" % (retVal, getUnicode(item, UNICODE_ENCODING))
10661067

1067-
if message and getattr(LOGGER_HANDLER, "is_tty", False):
1068+
if message and IS_TTY:
10681069
message = "\r%s" % message
10691070

10701071
if retVal:
@@ -1256,7 +1257,7 @@ def banner():
12561257
if not any(_ in sys.argv for _ in ("--version", "--api")) and not conf.get("disableBanner"):
12571258
_ = BANNER
12581259

1259-
if not getattr(LOGGER_HANDLER, "is_tty", False) or "--disable-coloring" in sys.argv:
1260+
if not IS_TTY or "--disable-coloring" in sys.argv:
12601261
_ = clearColors(_)
12611262
elif IS_WIN:
12621263
coloramainit()
@@ -2168,7 +2169,7 @@ def clearConsoleLine(forceOutput=False):
21682169
Clears current console line
21692170
"""
21702171

2171-
if getattr(LOGGER_HANDLER, "is_tty", False):
2172+
if IS_TTY:
21722173
dataToStdout("\r%s\r" % (" " * (getConsoleWidth() - 1)), forceOutput)
21732174

21742175
kb.prependFlag = False

lib/core/convert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from lib.core.data import conf
2121
from lib.core.data import kb
2222
from lib.core.settings import INVALID_UNICODE_PRIVATE_AREA
23+
from lib.core.settings import IS_TTY
2324
from lib.core.settings import IS_WIN
2425
from lib.core.settings import NULL
2526
from lib.core.settings import PICKLE_PROTOCOL
@@ -107,7 +108,7 @@ def shellExec(cmd): # Cross-referenced function
107108
def stdoutEncode(value):
108109
value = value or ""
109110

110-
if IS_WIN and kb.get("codePage", -1) is None:
111+
if IS_WIN and IS_TTY and kb.get("codePage", -1) is None:
111112
output = shellExec("chcp")
112113
match = re.search(r": (\d{3,})", output or "")
113114

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.124"
21+
VERSION = "1.3.5.125"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -233,6 +233,9 @@
233233
PYVERSION = sys.version.split()[0]
234234
IS_WIN = PLATFORM == "nt"
235235

236+
# Check if running in terminal
237+
IS_TTY = os.isatty(sys.stdout.fileno())
238+
236239
# DBMS system databases
237240
MSSQL_SYSTEM_DBS = ("Northwind", "master", "model", "msdb", "pubs", "tempdb")
238241
MYSQL_SYSTEM_DBS = ("information_schema", "mysql", "performance_schema", "sys")

0 commit comments

Comments
 (0)