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

Skip to content

Commit 7a17988

Browse files
committed
Fixes #3637
1 parent 5ae78b1 commit 7a17988

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,9 +1800,11 @@ def getFileType(filePath):
18001800
"""
18011801

18021802
try:
1803-
desc = getUnicode(magic.from_file(filePath) or "")
1803+
desc = magic.from_file(filePath) or magic.MAGIC_UNKNOWN_FILETYPE
18041804
except:
18051805
desc = magic.MAGIC_UNKNOWN_FILETYPE
1806+
finally:
1807+
desc = getText(desc)
18061808

18071809
if desc == magic.MAGIC_UNKNOWN_FILETYPE:
18081810
content = openFile(filePath, "rb", encoding=None).read()

lib/core/dump.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.common import dataToDumpFile
1919
from lib.core.common import dataToStdout
2020
from lib.core.common import getSafeExString
21+
from lib.core.common import getText
2122
from lib.core.common import isListLike
2223
from lib.core.common import isMultiThreadMode
2324
from lib.core.common import normalizeUnicode
@@ -613,8 +614,8 @@ def dbTableValues(self, tableValues):
613614

614615
if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value:
615616
try:
616-
mimetype = magic.from_buffer(value, mime=True)
617-
if any(mimetype.startswith(_) for _ in (b"application", b"image")):
617+
mimetype = getText(magic.from_buffer(value, mime=True))
618+
if any(mimetype.startswith(_) for _ in ("application", "image")):
618619
if not os.path.isdir(dumpDbPath):
619620
os.makedirs(dumpDbPath)
620621

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty import six
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.58"
21+
VERSION = "1.3.5.59"
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)

thirdparty/magic/magic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,4 @@ def magic_load(cookie, filename):
223223
MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff
224224
MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran
225225
MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens
226-
MAGIC_UNKNOWN_FILETYPE = "unknown"
226+
MAGIC_UNKNOWN_FILETYPE = b"unknown"

0 commit comments

Comments
 (0)