Some more patches for -d

This commit is contained in:
Miroslav Štampar 2026-07-11 15:51:04 +02:00
parent 3378f8df34
commit e23a91f6db
6 changed files with 32 additions and 26 deletions

View file

@ -1714,7 +1714,7 @@ def parseTargetDirect():
try:
conf.dbms = dbmsName
if dbmsName in (DBMS.ACCESS, DBMS.SQLITE, DBMS.FIREBIRD):
if dbmsName in (DBMS.ACCESS, DBMS.SQLITE):
if remote:
warnMsg = "direct connection over the network for "
warnMsg += "%s DBMS is not supported" % dbmsName
@ -1749,7 +1749,7 @@ def parseTargetDirect():
elif dbmsName == DBMS.ACCESS:
__import__("pyodbc")
elif dbmsName == DBMS.FIREBIRD:
__import__("kinterbasdb")
__import__("firebirdsql")
except (SqlmapSyntaxException, SqlmapMissingDependence):
raise
except:

View file

@ -231,7 +231,7 @@ DBMS_DICT = {
DBMS.ORACLE: (ORACLE_ALIASES, "python-oracledb", "https://oracle.github.io/python-oracledb/", "oracle"),
DBMS.SQLITE: (SQLITE_ALIASES, "python-sqlite", "https://docs.python.org/3/library/sqlite3.html", "sqlite"),
DBMS.ACCESS: (ACCESS_ALIASES, "python-pyodbc", "https://github.com/mkleehammer/pyodbc", "access"),
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python-kinterbasdb", "https://kinterbasdb.sourceforge.net/", "firebird"),
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python3-firebirdsql", "https://github.com/nakagami/pyfirebirdsql/", "firebird"),
DBMS.MAXDB: (MAXDB_ALIASES, None, None, "maxdb"),
DBMS.SYBASE: (SYBASE_ALIASES, "python-pymssql", "https://github.com/pymssql/pymssql", "sybase"),
DBMS.DB2: (DB2_ALIASES, "python ibm-db", "https://github.com/ibmdb/python-ibmdb", "ibm_db_sa"),

View file

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

View file

@ -38,7 +38,7 @@ def checkDependencies():
elif dbmsName == DBMS.ACCESS:
__import__("pyodbc")
elif dbmsName == DBMS.FIREBIRD:
__import__("kinterbasdb")
__import__("firebirdsql")
elif dbmsName == DBMS.DB2:
__import__("ibm_db_dbi")
elif dbmsName in (DBMS.HSQLDB, DBMS.CACHE):

View file

@ -6,7 +6,7 @@ See the file 'LICENSE' for copying permission
"""
try:
import kinterbasdb
import firebirdsql
except:
pass
@ -20,10 +20,12 @@ from plugins.generic.connector import Connector as GenericConnector
class Connector(GenericConnector):
"""
Homepage: http://kinterbasdb.sourceforge.net/
User guide: http://kinterbasdb.sourceforge.net/dist_docs/usage.html
Debian package: python-kinterbasdb
Homepage: https://github.com/nakagami/pyfirebirdsql
User guide: https://pyfirebirdsql.readthedocs.io/
Debian package: python3-firebirdsql
License: BSD
Note: ported from the (Python 2-only, unmaintained) kinterbasdb driver to firebirdsql
"""
# sample usage:
@ -36,9 +38,8 @@ class Connector(GenericConnector):
self.checkFileDb()
try:
# Reference: http://www.daniweb.com/forums/thread248499.html
self.connector = kinterbasdb.connect(host=self.hostname, database=self.db, user=self.user, password=self.password, charset="UTF8")
except kinterbasdb.OperationalError as ex:
self.connector = firebirdsql.connect(host=self.hostname, database=self.db, port=self.port or 3050, user=self.user, password=self.password, charset="UTF8")
except firebirdsql.OperationalError as ex:
raise SqlmapConnectionException(getSafeExString(ex))
self.initCursor()
@ -47,20 +48,25 @@ class Connector(GenericConnector):
def fetchall(self):
try:
return self.cursor.fetchall()
except kinterbasdb.OperationalError as ex:
except firebirdsql.OperationalError as ex:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
return None
def execute(self, query):
def execute(self, query, commit=True):
try:
self.cursor.execute(query)
except kinterbasdb.OperationalError as ex:
except firebirdsql.OperationalError as ex:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
except kinterbasdb.Error as ex:
except firebirdsql.Error as ex:
raise SqlmapConnectionException(getSafeExString(ex))
self.connector.commit()
# commit non-SELECT (DML) here; select() commits only AFTER fetchall() because a Firebird COMMIT closes
# open cursors (discarding an unfetched result set)
if commit:
self.connector.commit()
def select(self, query):
self.execute(query)
return self.fetchall()
self.execute(query, commit=False)
retVal = self.fetchall()
self.connector.commit()
return retVal

View file

@ -53,11 +53,11 @@ class TestCheckDependencies(unittest.TestCase):
deps.logger = self._real_logger
def test_missing_driver_warns_with_library_name(self):
# 'kinterbasdb' (Firebird driver) is essentially never installed, so the
# probe must hit the except branch and emit a warning naming the library.
# 'CUBRIDdb' (CUBRID driver) is not on PyPI and essentially never installed,
# so the probe must hit the except branch and emit a warning naming the library.
try:
__import__("kinterbasdb")
self.skipTest("kinterbasdb is unexpectedly installed")
__import__("CUBRIDdb")
self.skipTest("CUBRIDdb is unexpectedly installed")
except ImportError:
pass
@ -65,10 +65,10 @@ class TestCheckDependencies(unittest.TestCase):
warnings = self.rec.messages("warning")
self.assertTrue(warnings, msg="no warnings captured for a missing driver")
# the Firebird entry must name its third-party library in a warning
# the CUBRID entry must name its third-party library in a warning
self.assertTrue(
any("kinterbasdb" in w for w in warnings),
msg="missing Firebird driver did not produce a library-naming warning: %r" % warnings,
any("CUBRID-Python" in w for w in warnings),
msg="missing CUBRID driver did not produce a library-naming warning: %r" % warnings,
)
def test_all_present_emits_all_installed_info(self):