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

Skip to content

Commit a4e9d3e

Browse files
committed
Some more drei updates
1 parent cc9711e commit a4e9d3e

8 files changed

Lines changed: 27 additions & 18 deletions

File tree

lib/core/common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
from thirdparty.colorama.initialise import init as coloramainit
182182
from thirdparty.magic import magic
183183
from thirdparty.odict import OrderedDict
184+
from thirdparty.six import unichr as _unichr
184185
from thirdparty.six.moves import configparser as _configparser
185186
from thirdparty.six.moves import http_client as _http_client
186187
from thirdparty.six.moves import input as _input
@@ -2425,7 +2426,7 @@ def goGoodSamaritan(prevValue, originalCharset):
24252426
# Split the original charset into common chars (commonCharset)
24262427
# and other chars (otherCharset)
24272428
for ordChar in originalCharset:
2428-
if chr(ordChar) not in predictionSet:
2429+
if _unichr(ordChar) not in predictionSet:
24292430
otherCharset.append(ordChar)
24302431
else:
24312432
commonCharset.append(ordChar)
@@ -3502,11 +3503,11 @@ def decodeIntToUnicode(value):
35023503
elif Backend.isDbms(DBMS.MSSQL):
35033504
retVal = getUnicode(raw, "UTF-16-BE")
35043505
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.ORACLE):
3505-
retVal = six.unichr(value)
3506+
retVal = _unichr(value)
35063507
else:
35073508
retVal = getUnicode(raw, conf.encoding)
35083509
else:
3509-
retVal = getUnicode(chr(value))
3510+
retVal = _unichr(value)
35103511
except:
35113512
retVal = INFERENCE_UNKNOWN_CHAR
35123513

lib/core/convert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from lib.core.settings import SAFE_HEX_MARKER
2727
from lib.core.settings import UNICODE_ENCODING
2828
from thirdparty import six
29+
from thirdparty.six import unichr as _unichr
2930

3031
def base64pickle(value):
3132
"""
@@ -83,7 +84,7 @@ def htmlunescape(value):
8384
retVal = retVal.replace(code, value)
8485

8586
try:
86-
retVal = re.sub(r"&#x([^ ;]+);", lambda match: six.unichr(int(match.group(1), 16)), retVal)
87+
retVal = re.sub(r"&#x([^ ;]+);", lambda match: _unichr(int(match.group(1), 16)), retVal)
8788
except ValueError:
8889
pass
8990
return retVal
@@ -245,7 +246,7 @@ def getBytes(value, encoding=UNICODE_ENCODING, errors="strict", unsafe=True):
245246
if INVALID_UNICODE_PRIVATE_AREA:
246247
if unsafe:
247248
for char in xrange(0xF0000, 0xF00FF + 1):
248-
value = value.replace(six.unichr(char), "%s%02x" % (SAFE_HEX_MARKER, char - 0xF0000))
249+
value = value.replace(_unichr(char), "%s%02x" % (SAFE_HEX_MARKER, char - 0xF0000))
249250

250251
retVal = value.encode(encoding, errors)
251252

lib/core/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
from lib.core.enums import DBMS
1616
from lib.core.enums import DBMS_DIRECTORY_NAME
1717
from lib.core.enums import OS
18-
from thirdparty import six
18+
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.92"
21+
VERSION = "1.3.5.93"
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)
@@ -840,7 +840,7 @@
840840
def _reversible(ex):
841841
if isinstance(ex, UnicodeDecodeError):
842842
if INVALID_UNICODE_PRIVATE_AREA:
843-
return (u"".join(six.unichr(int('000f00%2x' % (_ if isinstance(_, int) else ord(_)), 16)) for _ in ex.object[ex.start:ex.end]), ex.end)
843+
return (u"".join(_unichr(int('000f00%2x' % (_ if isinstance(_, int) else ord(_)), 16)) for _ in ex.object[ex.start:ex.end]), ex.end)
844844
else:
845845
return (u"".join(INVALID_UNICODE_CHAR_FORMAT % (_ if isinstance(_, int) else ord(_)) for _ in ex.object[ex.start:ex.end]), ex.end)
846846

lib/request/basic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from thirdparty import six
5353
from thirdparty.chardet import detect
5454
from thirdparty.odict import OrderedDict
55+
from thirdparty.six import unichr as _unichr
5556

5657
def forgeHeaders(items=None, base=None):
5758
"""
@@ -353,14 +354,14 @@ def decodePage(page, contentEncoding, contentType):
353354
def _(match):
354355
retVal = match.group(0)
355356
try:
356-
retVal = six.unichr(int(match.group(1)))
357+
retVal = _unichr(int(match.group(1)))
357358
except (ValueError, OverflowError):
358359
pass
359360
return retVal
360361
page = re.sub(r"&#(\d+);", _, page)
361362

362363
# e.g. &zeta;
363-
page = re.sub(r"&([^;]+);", lambda _: six.unichr(htmlEntities[_.group(1)]) if htmlEntities.get(_.group(1), 0) > 255 else _.group(0), page)
364+
page = re.sub(r"&([^;]+);", lambda _: _unichr(htmlEntities[_.group(1)]) if htmlEntities.get(_.group(1), 0) > 255 else _.group(0), page)
364365

365366
return page
366367

lib/request/connect.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class WebSocketException(Exception):
124124
from lib.request.methodrequest import MethodRequest
125125
from thirdparty import six
126126
from thirdparty.odict import OrderedDict
127+
from thirdparty.six import unichr as _unichr
127128
from thirdparty.six.moves import http_client as _http_client
128129
from thirdparty.six.moves import urllib as _urllib
129130
from thirdparty.socks.socks import ProxyError
@@ -245,7 +246,8 @@ def getPage(**kwargs):
245246
elif conf.dummy or conf.murphyRate and randomInt() % conf.murphyRate == 0:
246247
if conf.murphyRate:
247248
time.sleep(randomInt() % (MAX_MURPHY_SLEEP_TIME + 1))
248-
return getUnicode(randomStr(int(randomInt()), alphabet=[chr(_) for _ in xrange(256)]), {}, int(randomInt())), None, None if not conf.murphyRate else randomInt(3)
249+
250+
return randomStr(int(randomInt()), alphabet=[_unichr(_) for _ in xrange(256)]), None, None if not conf.murphyRate else randomInt(3)
249251

250252
threadData = getCurrentThreadData()
251253
with kb.locks.request:
@@ -1043,7 +1045,7 @@ def _adjustParameter(paramString, parameter, newValue):
10431045

10441046
match = re.search(r"String\.fromCharCode\(([\d+, ]+)\)", token.value)
10451047
if match:
1046-
token.value = "".join(chr(int(_)) for _ in match.group(1).replace(' ', "").split(','))
1048+
token.value = "".join(_unichr(int(_)) for _ in match.group(1).replace(' ', "").split(','))
10471049

10481050
if not token:
10491051
if conf.csrfUrl and conf.csrfToken and conf.csrfUrl != conf.url and code == _http_client.OK:

lib/utils/pivotdumptable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from lib.core.settings import NULL
3434
from lib.core.unescaper import unescaper
3535
from lib.request import inject
36-
from thirdparty import six
36+
from thirdparty.six import unichr as _unichr
3737

3838
def pivotDumpTable(table, colList, count=None, blind=True, alias=None):
3939
lengths = {}
@@ -143,7 +143,7 @@ def _(column, pivotValue):
143143
if column == colList[0]:
144144
if isNoneValue(value):
145145
try:
146-
for pivotValue in filterNone((" " if pivotValue == " " else None, "%s%s" % (pivotValue[0], six.unichr(ord(pivotValue[1]) + 1)) if len(pivotValue) > 1 else None, six.unichr(ord(pivotValue[0]) + 1))):
146+
for pivotValue in filterNone((" " if pivotValue == " " else None, "%s%s" % (pivotValue[0], _unichr(ord(pivotValue[1]) + 1)) if len(pivotValue) > 1 else None, _unichr(ord(pivotValue[0]) + 1))):
147147
value = _(column, pivotValue)
148148
if not isNoneValue(value):
149149
break

lib/utils/purge.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import string
1414

1515
from lib.core.common import getSafeExString
16+
from lib.core.common import openFile
1617
from lib.core.compat import xrange
1718
from lib.core.data import logger
19+
from thirdparty.six import unichr as _unichr
1820

1921
def purge(directory):
2022
"""
@@ -47,8 +49,8 @@ def purge(directory):
4749
for filepath in filepaths:
4850
try:
4951
filesize = os.path.getsize(filepath)
50-
with open(filepath, "w+b") as f:
51-
f.write("".join(chr(random.randint(0, 255)) for _ in xrange(filesize)))
52+
with openFile(filepath, "w+b") as f:
53+
f.write("".join(_unichr(random.randint(0, 255)) for _ in xrange(filesize)))
5254
except:
5355
pass
5456

thirdparty/clientform/clientform.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ def _show_debug_messages():
9595

9696
try:
9797
from thirdparty import six
98+
from thirdparty.six import unichr as _unichr
9899
from thirdparty.six.moves import cStringIO as _cStringIO
99100
from thirdparty.six.moves import html_entities as _html_entities
100101
from thirdparty.six.moves import urllib as _urllib
101102
except ImportError:
102103
import six
104+
from six import unichr as _unichr
103105
from six.moves import cStringIO as _cStringIO
104106
from six.moves import html_entities as _html_entities
105107
from six.moves import urllib as _urllib
@@ -250,7 +252,7 @@ def unescape_charref(data, encoding):
250252
name, base= name[1:], 16
251253
elif not name.isdigit():
252254
base = 16
253-
uc = six.unichr(int(name, base))
255+
uc = _unichr(int(name, base))
254256
if encoding is None:
255257
return uc
256258
else:
@@ -274,7 +276,7 @@ def get_entitydefs():
274276
entitydefs["&%s;" % name] = uc
275277
else:
276278
for name, codepoint in _html_entities.name2codepoint.items():
277-
entitydefs["&%s;" % name] = six.unichr(codepoint)
279+
entitydefs["&%s;" % name] = _unichr(codepoint)
278280
return entitydefs
279281

280282

0 commit comments

Comments
 (0)