This commit is contained in:
Miroslav Stampar 2019-05-08 17:21:40 +02:00
parent 5ae78b1d85
commit 7a179889a3
4 changed files with 8 additions and 5 deletions

View File

@ -1800,9 +1800,11 @@ def getFileType(filePath):
""" """
try: try:
desc = getUnicode(magic.from_file(filePath) or "") desc = magic.from_file(filePath) or magic.MAGIC_UNKNOWN_FILETYPE
except: except:
desc = magic.MAGIC_UNKNOWN_FILETYPE desc = magic.MAGIC_UNKNOWN_FILETYPE
finally:
desc = getText(desc)
if desc == magic.MAGIC_UNKNOWN_FILETYPE: if desc == magic.MAGIC_UNKNOWN_FILETYPE:
content = openFile(filePath, "rb", encoding=None).read() content = openFile(filePath, "rb", encoding=None).read()

View File

@ -18,6 +18,7 @@ from lib.core.common import checkFile
from lib.core.common import dataToDumpFile from lib.core.common import dataToDumpFile
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import getSafeExString from lib.core.common import getSafeExString
from lib.core.common import getText
from lib.core.common import isListLike from lib.core.common import isListLike
from lib.core.common import isMultiThreadMode from lib.core.common import isMultiThreadMode
from lib.core.common import normalizeUnicode from lib.core.common import normalizeUnicode
@ -613,8 +614,8 @@ class Dump(object):
if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value: if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value:
try: try:
mimetype = magic.from_buffer(value, mime=True) mimetype = getText(magic.from_buffer(value, mime=True))
if any(mimetype.startswith(_) for _ in (b"application", b"image")): if any(mimetype.startswith(_) for _ in ("application", "image")):
if not os.path.isdir(dumpDbPath): if not os.path.isdir(dumpDbPath):
os.makedirs(dumpDbPath) os.makedirs(dumpDbPath)

View File

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

View File

@ -223,4 +223,4 @@ MAGIC_NO_CHECK_ASCII = 0x020000 # Don't check for ascii files
MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff
MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran
MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens
MAGIC_UNKNOWN_FILETYPE = "unknown" MAGIC_UNKNOWN_FILETYPE = b"unknown"