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

Skip to content

Commit 62fc2e1

Browse files
committed
Fixes #2911
1 parent ef8b2d7 commit 62fc2e1

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

lib/core/dump.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from lib.core.settings import MIN_BINARY_DISK_DUMP_SIZE
4747
from lib.core.settings import TRIM_STDOUT_DUMP_SIZE
4848
from lib.core.settings import UNICODE_ENCODING
49+
from lib.core.settings import UNSAFE_DUMP_FILEPATH_REPLACEMENT
4950
from lib.core.settings import WINDOWS_RESERVED_NAMES
5051
from thirdparty.magic import magic
5152

@@ -418,7 +419,7 @@ def dbTableValues(self, tableValues):
418419
except:
419420
warnFile = True
420421

421-
_ = unicodeencode(re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(db)))
422+
_ = unicodeencode(re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(db)))
422423
dumpDbPath = os.path.join(conf.dumpPath, "%s-%s" % (_, hashlib.md5(unicodeencode(db)).hexdigest()[:8]))
423424

424425
if not os.path.isdir(dumpDbPath):
@@ -441,7 +442,7 @@ def dbTableValues(self, tableValues):
441442

442443
dumpDbPath = tempDir
443444

444-
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower()))
445+
dumpFileName = os.path.join(dumpDbPath, re.sub(r'[\\/]', UNSAFE_DUMP_FILEPATH_REPLACEMENT, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())))
445446
if not checkFile(dumpFileName, False):
446447
try:
447448
openFile(dumpFileName, "w+b").close()
@@ -450,9 +451,9 @@ def dbTableValues(self, tableValues):
450451
except:
451452
warnFile = True
452453

453-
_ = re.sub(r"[^\w]", "_", normalizeUnicode(unsafeSQLIdentificatorNaming(table)))
454+
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, normalizeUnicode(unsafeSQLIdentificatorNaming(table)))
454455
if len(_) < len(table) or IS_WIN and table.upper() in WINDOWS_RESERVED_NAMES:
455-
_ = unicodeencode(re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(table)))
456+
_ = unicodeencode(re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, unsafeSQLIdentificatorNaming(table)))
456457
dumpFileName = os.path.join(dumpDbPath, "%s-%s.%s" % (_, hashlib.md5(unicodeencode(table)).hexdigest()[:8], conf.dumpFormat.lower()))
457458
else:
458459
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (_, conf.dumpFormat.lower()))
@@ -613,7 +614,7 @@ def dbTableValues(self, tableValues):
613614
if not os.path.isdir(dumpDbPath):
614615
os.makedirs(dumpDbPath, 0755)
615616

616-
_ = re.sub(r"[^\w]", "_", normalizeUnicode(unsafeSQLIdentificatorNaming(column)))
617+
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, normalizeUnicode(unsafeSQLIdentificatorNaming(column)))
617618
filepath = os.path.join(dumpDbPath, "%s-%d.bin" % (_, randomInt(8)))
618619
warnMsg = "writing binary ('%s') content to file '%s' " % (mimetype, filepath)
619620
logger.warn(warnMsg)

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.2.1"
22+
VERSION = "1.2.2.2"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -424,6 +424,9 @@
424424
# Maximum integer value
425425
MAX_INT = sys.maxint
426426

427+
# Replacement for unsafe characters in dump table filenames
428+
UNSAFE_DUMP_FILEPATH_REPLACEMENT = '_'
429+
427430
# Options that need to be restored in multiple targets run mode
428431
RESTORE_MERGED_OPTIONS = ("col", "db", "dnsDomain", "privEsc", "tbl", "regexp", "string", "textOnly", "threads", "timeSec", "tmpPath", "uChar", "user")
429432

txt/checksum.md5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ e3a3f5218b2e52dd0afafdfc9fed2002 lib/core/agent.py
3434
12e80071013606f01822c3823fb51054 lib/core/decorators.py
3535
9458679feb9184f3fb1611daf1ebef63 lib/core/defaults.py
3636
a8bea09096a42a9a7feeb9d4d118ae66 lib/core/dicts.py
37-
1a94690d60ed792ce441b6f2f4dbbef8 lib/core/dump.py
37+
0d742fbf72bca25a3e82640616c30c9a lib/core/dump.py
3838
c8551f7696a76450e6d139409e4f06cd lib/core/enums.py
3939
cada93357a7321655927fc9625b3bfec lib/core/exception.py
4040
1e5532ede194ac9c083891c2f02bca93 lib/core/__init__.py
@@ -46,7 +46,7 @@ ffa5f01f39b17c8d73423acca6cfe86a lib/core/readlineng.py
4646
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
4747
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
4848
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
49-
67ea2aee17da22379743e5dc18159f3f lib/core/settings.py
49+
e4a29b441ac8137ce22d7113dd2b72c5 lib/core/settings.py
5050
d0adc28a38e43a787df4471f7f027413 lib/core/shell.py
5151
63491be462c515a1a3880c27c2acc4a2 lib/core/subprocessng.py
5252
505aaa61e1bba3c3d4567c3e667699e3 lib/core/target.py

0 commit comments

Comments
 (0)