diff --git a/lib/core/dump.py b/lib/core/dump.py index 5d7a38c01..33adf333b 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -614,7 +614,7 @@ class Dump(object): if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value: try: mimetype = magic.from_buffer(value, mime=True) - if any(mimetype.startswith(_) for _ in ("application", "image")): + if any(mimetype.startswith(_) for _ in (b"application", b"image")): if not os.path.isdir(dumpDbPath): os.makedirs(dumpDbPath) diff --git a/lib/core/settings.py b/lib/core/settings.py index 9df30172c..722955904 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.3.5.39" +VERSION = "1.3.5.40" 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) diff --git a/lib/core/subprocessng.py b/lib/core/subprocessng.py index 2ffecc88e..3bd103055 100644 --- a/lib/core/subprocessng.py +++ b/lib/core/subprocessng.py @@ -12,6 +12,7 @@ import time from lib.core.compat import buffer from lib.core.settings import IS_WIN +from thirdparty import six if IS_WIN: try: @@ -97,7 +98,7 @@ class Popen(subprocess.Popen): except ValueError: return self._close('stdin') except (subprocess.pywintypes.error, Exception) as ex: - if ex[0] in (109, errno.ESHUTDOWN): + if (ex[0] if six.PY2 else ex.errno) in (109, errno.ESHUTDOWN): return self._close('stdin') raise @@ -118,7 +119,7 @@ class Popen(subprocess.Popen): except (ValueError, NameError): return self._close(which) except (subprocess.pywintypes.error, Exception) as ex: - if ex[0] in (109, errno.ESHUTDOWN): + if (ex[0] if six.PY2 else ex.errno) in (109, errno.ESHUTDOWN): return self._close(which) raise @@ -136,7 +137,7 @@ class Popen(subprocess.Popen): try: written = os.write(self.stdin.fileno(), input) except OSError as ex: - if ex[0] == errno.EPIPE: # broken pipe + if (ex[0] if six.PY2 else ex.errno) == errno.EPIPE: # broken pipe return self._close('stdin') raise diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index 41c9db016..c12d678f5 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -598,7 +598,7 @@ class Metasploit: except select.error as ex: # Reference: https://github.com/andymccurdy/redis-py/pull/743/commits/2b59b25bb08ea09e98aede1b1f23a270fc085a9f - if ex[0] == errno.EINTR: + if (ex[0] if six.PY2 else ex.errno) == errno.EINTR: continue else: return proc.returncode diff --git a/lib/utils/sqlalchemy.py b/lib/utils/sqlalchemy.py index 6e6c9961b..71cec4dad 100644 --- a/lib/utils/sqlalchemy.py +++ b/lib/utils/sqlalchemy.py @@ -77,7 +77,7 @@ class SQLAlchemy(GenericConnector): except SqlmapFilePathException: raise except Exception as ex: - raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % ex[0]) + raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % ex.msg) self.printConnected() else: diff --git a/plugins/generic/connector.py b/plugins/generic/connector.py index f80723564..ca52a3be0 100644 --- a/plugins/generic/connector.py +++ b/plugins/generic/connector.py @@ -31,14 +31,12 @@ class Connector: def printConnected(self): if self.hostname and self.port: - infoMsg = "connection to %s server %s" % (conf.dbms, self.hostname) - infoMsg += ":%d established" % self.port + infoMsg = "connection to %s server '%s:%d' established" % (conf.dbms, self.hostname, self.port) logger.info(infoMsg) def closed(self): if self.hostname and self.port: - infoMsg = "connection to %s server %s" % (conf.dbms, self.hostname) - infoMsg += ":%d closed" % self.port + infoMsg = "connection to %s server '%s:%d' closed" % (conf.dbms, self.hostname, self.port) logger.info(infoMsg) self.connector = None