mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-08 23:59:06 +00:00
Minor DREI updates
This commit is contained in:
@@ -52,7 +52,6 @@ from lib.core.convert import base64unpickle
|
||||
from lib.core.convert import hexdecode
|
||||
from lib.core.convert import htmlunescape
|
||||
from lib.core.convert import stdoutencode
|
||||
from lib.core.convert import unicodeencode
|
||||
from lib.core.convert import utf8encode
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
@@ -894,14 +893,14 @@ def setColor(message, color=None, bold=False, level=None):
|
||||
retVal = message
|
||||
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
|
||||
|
||||
if isinstance(level, unicode):
|
||||
level = unicodeencode(level)
|
||||
|
||||
if message and getattr(LOGGER_HANDLER, "is_tty", False): # colorizing handler
|
||||
if bold or color:
|
||||
retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None)
|
||||
elif level:
|
||||
level = getattr(logging, level, None) if isinstance(level, six.string_types) else level
|
||||
try:
|
||||
level = getattr(logging, level, None)
|
||||
except UnicodeError:
|
||||
level = None
|
||||
retVal = LOGGER_HANDLER.colorize(message, level)
|
||||
|
||||
return retVal
|
||||
@@ -989,7 +988,7 @@ def dataToOutFile(filename, data):
|
||||
|
||||
try:
|
||||
with open(retVal, "w+b") as f: # has to stay as non-codecs because data is raw ASCII encoded data
|
||||
f.write(unicodeencode(data))
|
||||
f.write(getBytes(data))
|
||||
except UnicodeEncodeError as ex:
|
||||
_ = normalizeUnicode(filename)
|
||||
if filename != _:
|
||||
@@ -2431,7 +2430,7 @@ def getUnicode(value, encoding=None, noneToNull=False):
|
||||
except UnicodeDecodeError:
|
||||
return six.text_type(str(value), errors="ignore") # encoding ignored for non-basestring instances
|
||||
|
||||
def getBytes(value):
|
||||
def getBytes(value, encoding=UNICODE_ENCODING):
|
||||
"""
|
||||
Returns byte representation of provided Unicode value
|
||||
|
||||
@@ -2446,11 +2445,11 @@ def getBytes(value):
|
||||
for char in xrange(0xF0000, 0xF00FF + 1):
|
||||
value = value.replace(unichr(char), "%s%02x" % (SAFE_HEX_MARKER, char - 0xF0000))
|
||||
|
||||
retVal = value.encode(UNICODE_ENCODING)
|
||||
retVal = value.encode(encoding)
|
||||
|
||||
retVal = re.sub(r"%s([0-9a-f]{2})" % SAFE_HEX_MARKER, lambda _: _.group(1).decode("hex"), retVal)
|
||||
else:
|
||||
retVal = value.encode(UNICODE_ENCODING)
|
||||
retVal = value.encode(encoding)
|
||||
retVal = re.sub(r"\\x([0-9a-f]{2})", lambda _: _.group(1).decode("hex"), retVal)
|
||||
|
||||
return retVal
|
||||
@@ -4171,7 +4170,7 @@ def findPageForms(content, url, raise_=False, addToTargets=False):
|
||||
|
||||
class _(io.BytesIO):
|
||||
def __init__(self, content, url):
|
||||
io.BytesIO.__init__(self, unicodeencode(content, kb.pageEncoding) if isinstance(content, unicode) else content)
|
||||
io.BytesIO.__init__(self, getBytes(content, kb.pageEncoding))
|
||||
self._url = url
|
||||
|
||||
def geturl(self):
|
||||
|
||||
@@ -17,6 +17,7 @@ from lib.core.common import Backend
|
||||
from lib.core.common import checkFile
|
||||
from lib.core.common import dataToDumpFile
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.common import getBytes
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import isListLike
|
||||
@@ -26,7 +27,6 @@ from lib.core.common import openFile
|
||||
from lib.core.common import prioritySortColumns
|
||||
from lib.core.common import randomInt
|
||||
from lib.core.common import safeCSValue
|
||||
from lib.core.common import unicodeencode
|
||||
from lib.core.common import unsafeSQLIdentificatorNaming
|
||||
from lib.core.compat import xrange
|
||||
from lib.core.data import conf
|
||||
@@ -422,8 +422,8 @@ class Dump(object):
|
||||
except:
|
||||
warnFile = True
|
||||
|
||||
_ = unicodeencode(re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(db)))
|
||||
dumpDbPath = os.path.join(conf.dumpPath, "%s-%s" % (_, hashlib.md5(unicodeencode(db)).hexdigest()[:8]))
|
||||
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(db))
|
||||
dumpDbPath = os.path.join(conf.dumpPath, "%s-%s" % (_, hashlib.md5(getBytes(db)).hexdigest()[:8]))
|
||||
|
||||
if not os.path.isdir(dumpDbPath):
|
||||
try:
|
||||
@@ -456,8 +456,8 @@ class Dump(object):
|
||||
|
||||
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, normalizeUnicode(unsafeSQLIdentificatorNaming(table)))
|
||||
if len(_) < len(table) or IS_WIN and table.upper() in WINDOWS_RESERVED_NAMES:
|
||||
_ = unicodeencode(re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(table)))
|
||||
dumpFileName = os.path.join(dumpDbPath, "%s-%s.%s" % (_, hashlib.md5(unicodeencode(table)).hexdigest()[:8], conf.dumpFormat.lower()))
|
||||
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(table))
|
||||
dumpFileName = os.path.join(dumpDbPath, "%s-%s.%s" % (_, hashlib.md5(getBytes(table)).hexdigest()[:8], conf.dumpFormat.lower()))
|
||||
else:
|
||||
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (_, conf.dumpFormat.lower()))
|
||||
else:
|
||||
|
||||
@@ -17,7 +17,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.4.27"
|
||||
VERSION = "1.3.4.28"
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user