Skip to content

Commit 688150c

Browse files
committed
Patch related to the #3453
1 parent ea4052e commit 688150c

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

lib/core/convert.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,29 @@ def filterNone(values): # Cross-referenced function
101101
def isListLike(value): # Cross-referenced function
102102
raise NotImplementedError
103103

104+
def shellExec(cmd): # Cross-referenced function
105+
raise NotImplementedError
106+
104107
def stdoutEncode(value):
105108
value = value or ""
106109

110+
if IS_WIN and kb.get("codePage", -1) is None:
111+
output = shellExec("chcp")
112+
match = re.search(r": (\d{3,})", output or "")
113+
114+
if match:
115+
try:
116+
candidate = "cp%s" % match.group(1)
117+
codecs.lookup(candidate)
118+
except LookupError:
119+
pass
120+
else:
121+
kb.codePage = candidate
122+
123+
kb.codePage = kb.codePage or ""
124+
107125
if isinstance(value, six.text_type) and PYVERSION < "3.6":
108-
encoding = sys.stdout.encoding or UNICODE_ENCODING
126+
encoding = kb.get("codePage") or sys.stdout.encoding or UNICODE_ENCODING
109127

110128
while True:
111129
try:

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
18721872
kb.chars.stop = "%s%s%s" % (KB_CHARS_BOUNDARY_CHAR, randomStr(length=3, alphabet=KB_CHARS_LOW_FREQUENCY_ALPHABET), KB_CHARS_BOUNDARY_CHAR)
18731873
kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = ("%s%s%s" % (KB_CHARS_BOUNDARY_CHAR, _, KB_CHARS_BOUNDARY_CHAR) for _ in randomStr(length=4, lowercase=True))
18741874

1875+
kb.codePage = None
18751876
kb.columnExistsChoice = None
18761877
kb.commonOutputs = None
18771878
kb.connErrorChoice = None

lib/core/patch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from lib.core.common import isListLike
2525
from lib.core.common import singleTimeWarnMessage
2626
from lib.core.common import readInput
27+
from lib.core.common import shellExec
2728
from lib.core.convert import stdoutEncode
2829
from lib.core.option import _setHTTPHandlers
2930
from lib.core.option import setVerbosity
@@ -63,6 +64,7 @@ def resolveCrossReferences():
6364
lib.core.common.getPageTemplate = getPageTemplate
6465
lib.core.convert.filterNone = filterNone
6566
lib.core.convert.isListLike = isListLike
67+
lib.core.convert.shellExec = shellExec
6668
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
6769
lib.core.option._pympTempLeakPatch = pympTempLeakPatch
6870
lib.request.connect.setHTTPHandlers = _setHTTPHandlers

lib/core/settings.py

Lines changed: 1 addition & 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.123"
21+
VERSION = "1.3.5.124"
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)

0 commit comments

Comments
 (0)