Fix for -d with file paths containing special characters (e.g. 'sqlite:///tmp/my dir (old)/t.db')

This commit is contained in:
Miroslav Štampar 2026-11-12 16:57:46 +01:00
parent c209a97131
commit 5a2fda4d27
2 changed files with 7 additions and 3 deletions

View file

@ -1681,10 +1681,14 @@ def parseTargetDirect():
for dbms in SUPPORTED_DBMS:
details = re.search(r"^(?P<dbms>%s)://(?P<credentials>(?P<user>.*?)\:(?P<pass>.*)\@)?(?P<remote>(?P<hostname>[\w.-]+?)\:(?P<port>[\d]+)\/)?(?P<db>[\w\d\ \:\.\_~\-\/\\]*)$" % dbms, conf.direct, re.I)
# Note: database file path of a file-based DBMS (e.g. SQLite) can contain (almost) any character (e.g. '/tmp/my dir (old)/t.db')
if not details and dbms in DBMS_DICT[DBMS.SQLITE][0] + DBMS_DICT[DBMS.ACCESS][0]:
details = re.search(r"^(?P<dbms>%s)://(?P<db>.+)$" % re.escape(dbms), conf.direct, re.I)
if details:
conf.dbms = details.group("dbms")
if details.group("credentials"):
if details.groupdict().get("credentials"):
conf.dbmsUser = details.group("user").strip("'\"")
conf.dbmsPass = details.group("pass").strip("'\"")
else:
@ -1697,7 +1701,7 @@ def parseTargetDirect():
if not conf.dbmsPass:
conf.dbmsPass = None
if details.group("remote"):
if details.groupdict().get("remote"):
remote = True
conf.hostname = details.group("hostname").strip()
conf.port = int(details.group("port"))

View file

@ -19,7 +19,7 @@ from lib.core.enums import OS
from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.10.11.59"
VERSION = "1.10.11.60"
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)