StringIO is bad m'kay (python3 this and that)

This commit is contained in:
Miroslav Stampar
2019-03-26 14:37:01 +01:00
parent 4b75ca15e8
commit 8d89389c36
9 changed files with 23 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ import getpass
import hashlib
import httplib
import inspect
import io
import json
import keyword
import locale
@@ -40,7 +41,6 @@ import unicodedata
from ConfigParser import DEFAULTSECT
from ConfigParser import RawConfigParser
from StringIO import StringIO
from difflib import SequenceMatcher
from math import sqrt
from optparse import OptionValueError
@@ -158,7 +158,6 @@ from lib.core.settings import REFLECTED_REPLACEMENT_REGEX
from lib.core.settings import REFLECTED_REPLACEMENT_TIMEOUT
from lib.core.settings import REFLECTED_VALUE_MARKER
from lib.core.settings import REFLECTIVE_MISS_THRESHOLD
from lib.core.settings import SAFE_VARIABLE_MARKER
from lib.core.settings import SENSITIVE_DATA_REGEX
from lib.core.settings import SENSITIVE_OPTIONS
from lib.core.settings import STDIN_PIPE_DASH
@@ -2079,7 +2078,7 @@ def parseXmlFile(xmlFile, handler):
"""
try:
with contextlib.closing(StringIO(readCachedFileContent(xmlFile))) as stream:
with contextlib.closing(io.StringIO(readCachedFileContent(xmlFile))) as stream:
parse(stream, handler)
except (SAXParseException, UnicodeError) as ex:
errMsg = "something appears to be wrong with "
@@ -3322,7 +3321,7 @@ def openFile(filename, mode='r', encoding=UNICODE_ENCODING, errors="replace", bu
if filename not in kb.cache.content:
kb.cache.content[filename] = sys.stdin.read()
return contextlib.closing(StringIO(readCachedFileContent(filename)))
return contextlib.closing(io.StringIO(readCachedFileContent(filename)))
else:
try:
return codecs.open(filename, mode, encoding, errors, buffering)
@@ -4107,9 +4106,9 @@ def findPageForms(content, url, raise_=False, addToTargets=False):
set([(u'/input.php', 'POST', u'id=1', None, None)])
"""
class _(StringIO):
class _(io.BytesIO):
def __init__(self, content, url):
StringIO.__init__(self, unicodeencode(content, kb.pageEncoding) if isinstance(content, unicode) else content)
io.BytesIO.__init__(self, unicodeencode(content, kb.pageEncoding) if isinstance(content, unicode) else content)
self._url = url
def geturl(self):

View File

@@ -13,9 +13,9 @@ finally:
import pickle as picklePy
import base64
import io
import json
import re
import StringIO
import sys
from lib.core.settings import IS_WIN
@@ -84,7 +84,7 @@ def base64unpickle(value, unsafe=False):
self.load_reduce()
def loads(str):
f = StringIO.StringIO(str)
f = io.BytesIO(str)
if unsafe:
unpickler = picklePy.Unpickler(f)
unpickler.dispatch[picklePy.REDUCE] = _

View File

@@ -125,7 +125,6 @@ from lib.core.settings import SQLMAP_ENVIRONMENT_PREFIX
from lib.core.settings import SUPPORTED_DBMS
from lib.core.settings import SUPPORTED_OS
from lib.core.settings import TIME_DELAY_CANDIDATES
from lib.core.settings import UNICODE_ENCODING
from lib.core.settings import UNION_CHAR_REGEX
from lib.core.settings import UNKNOWN_DBMS_VERSION
from lib.core.settings import URI_INJECTABLE_REGEX

View File

@@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
from lib.core.enums import OS
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.3.49"
VERSION = "1.3.3.50"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)