Skip to content

Commit f8eed1f

Browse files
committed
Minor update
1 parent f82f1f9 commit f8eed1f

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

lib/core/convert.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def base64decode(value):
2727
'foobar'
2828
"""
2929

30-
return base64.b64decode(value)
30+
return base64.b64decode(unicodeencode(value))
3131

3232
def base64encode(value):
3333
"""
@@ -37,7 +37,7 @@ def base64encode(value):
3737
'Zm9vYmFy'
3838
"""
3939

40-
return base64.b64encode(value)
40+
return base64.b64encode(unicodeencode(value))
4141

4242
def base64pickle(value):
4343
"""
@@ -89,7 +89,14 @@ def hexdecode(value):
8989
"""
9090

9191
value = value.lower()
92-
return (value[2:] if value.startswith("0x") else value).decode("hex")
92+
value = value[2:] if value.startswith("0x") else value
93+
94+
if six.PY2:
95+
retVal = value.decode("hex")
96+
else:
97+
retVal = bytes.fromhex(value)
98+
99+
return retVal
93100

94101
def hexencode(value, encoding=None):
95102
"""
@@ -99,7 +106,14 @@ def hexencode(value, encoding=None):
99106
'666f6f626172'
100107
"""
101108

102-
return unicodeencode(value, encoding).encode("hex")
109+
retVal = unicodeencode(value, encoding)
110+
111+
if six.PY2:
112+
retVal = retVal.encode("hex")
113+
else:
114+
retVal = retVal.hex()
115+
116+
return retVal
103117

104118
def unicodeencode(value, encoding=None):
105119
"""
@@ -110,11 +124,13 @@ def unicodeencode(value, encoding=None):
110124
"""
111125

112126
retVal = value
113-
if isinstance(value, unicode):
127+
128+
if isinstance(value, six.text_type):
114129
try:
115130
retVal = value.encode(encoding or UNICODE_ENCODING)
116131
except UnicodeEncodeError:
117-
retVal = value.encode(UNICODE_ENCODING, "replace")
132+
retVal = value.encode(encoding or UNICODE_ENCODING, "replace")
133+
118134
return retVal
119135

120136
def utf8encode(value):
@@ -164,13 +180,11 @@ def stdoutencode(data):
164180
retVal = None
165181

166182
try:
167-
data = data or ""
183+
retVal = unicodeencode(data or "", sys.stdout.encoding)
168184

169185
# Reference: http://bugs.python.org/issue1602
170186
if IS_WIN:
171-
output = data.encode(sys.stdout.encoding, "replace")
172-
173-
if '?' in output and '?' not in data:
187+
if '?' in retVal and '?' not in retVal:
174188
warnMsg = "cannot properly display Unicode characters "
175189
warnMsg += "inside Windows OS command prompt "
176190
warnMsg += "(http://bugs.python.org/issue1602). All "
@@ -180,11 +194,8 @@ def stdoutencode(data):
180194
warnMsg += "corresponding output files. "
181195
singleTimeWarnMessage(warnMsg)
182196

183-
retVal = output
184-
else:
185-
retVal = data.encode(sys.stdout.encoding)
186197
except:
187-
retVal = data.encode(UNICODE_ENCODING) if isinstance(data, unicode) else data
198+
retVal = unicodeencode(data or "")
188199

189200
return retVal
190201

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

1919
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
20-
VERSION = "1.3.3.74"
20+
VERSION = "1.3.3.75"
2121
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2222
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2323
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)