Skip to content

Commit e23a91f

Browse files
committed
Some more patches for -d
1 parent 3378f8d commit e23a91f

6 files changed

Lines changed: 32 additions & 26 deletions

File tree

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ def parseTargetDirect():
17141714
try:
17151715
conf.dbms = dbmsName
17161716

1717-
if dbmsName in (DBMS.ACCESS, DBMS.SQLITE, DBMS.FIREBIRD):
1717+
if dbmsName in (DBMS.ACCESS, DBMS.SQLITE):
17181718
if remote:
17191719
warnMsg = "direct connection over the network for "
17201720
warnMsg += "%s DBMS is not supported" % dbmsName
@@ -1749,7 +1749,7 @@ def parseTargetDirect():
17491749
elif dbmsName == DBMS.ACCESS:
17501750
__import__("pyodbc")
17511751
elif dbmsName == DBMS.FIREBIRD:
1752-
__import__("kinterbasdb")
1752+
__import__("firebirdsql")
17531753
except (SqlmapSyntaxException, SqlmapMissingDependence):
17541754
raise
17551755
except:

lib/core/dicts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
DBMS.ORACLE: (ORACLE_ALIASES, "python-oracledb", "https://oracle.github.io/python-oracledb/", "oracle"),
232232
DBMS.SQLITE: (SQLITE_ALIASES, "python-sqlite", "https://docs.python.org/3/library/sqlite3.html", "sqlite"),
233233
DBMS.ACCESS: (ACCESS_ALIASES, "python-pyodbc", "https://github.com/mkleehammer/pyodbc", "access"),
234-
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python-kinterbasdb", "https://kinterbasdb.sourceforge.net/", "firebird"),
234+
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python3-firebirdsql", "https://github.com/nakagami/pyfirebirdsql/", "firebird"),
235235
DBMS.MAXDB: (MAXDB_ALIASES, None, None, "maxdb"),
236236
DBMS.SYBASE: (SYBASE_ALIASES, "python-pymssql", "https://github.com/pymssql/pymssql", "sybase"),
237237
DBMS.DB2: (DB2_ALIASES, "python ibm-db", "https://github.com/ibmdb/python-ibmdb", "ibm_db_sa"),

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty import six
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.10.7.82"
23+
VERSION = "1.10.7.83"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def checkDependencies():
3838
elif dbmsName == DBMS.ACCESS:
3939
__import__("pyodbc")
4040
elif dbmsName == DBMS.FIREBIRD:
41-
__import__("kinterbasdb")
41+
__import__("firebirdsql")
4242
elif dbmsName == DBMS.DB2:
4343
__import__("ibm_db_dbi")
4444
elif dbmsName in (DBMS.HSQLDB, DBMS.CACHE):

plugins/dbms/firebird/connector.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
try:
9-
import kinterbasdb
9+
import firebirdsql
1010
except:
1111
pass
1212

@@ -20,10 +20,12 @@
2020

2121
class Connector(GenericConnector):
2222
"""
23-
Homepage: http://kinterbasdb.sourceforge.net/
24-
User guide: http://kinterbasdb.sourceforge.net/dist_docs/usage.html
25-
Debian package: python-kinterbasdb
23+
Homepage: https://github.com/nakagami/pyfirebirdsql
24+
User guide: https://pyfirebirdsql.readthedocs.io/
25+
Debian package: python3-firebirdsql
2626
License: BSD
27+
28+
Note: ported from the (Python 2-only, unmaintained) kinterbasdb driver to firebirdsql
2729
"""
2830

2931
# sample usage:
@@ -36,9 +38,8 @@ def connect(self):
3638
self.checkFileDb()
3739

3840
try:
39-
# Reference: http://www.daniweb.com/forums/thread248499.html
40-
self.connector = kinterbasdb.connect(host=self.hostname, database=self.db, user=self.user, password=self.password, charset="UTF8")
41-
except kinterbasdb.OperationalError as ex:
41+
self.connector = firebirdsql.connect(host=self.hostname, database=self.db, port=self.port or 3050, user=self.user, password=self.password, charset="UTF8")
42+
except firebirdsql.OperationalError as ex:
4243
raise SqlmapConnectionException(getSafeExString(ex))
4344

4445
self.initCursor()
@@ -47,20 +48,25 @@ def connect(self):
4748
def fetchall(self):
4849
try:
4950
return self.cursor.fetchall()
50-
except kinterbasdb.OperationalError as ex:
51+
except firebirdsql.OperationalError as ex:
5152
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
5253
return None
5354

54-
def execute(self, query):
55+
def execute(self, query, commit=True):
5556
try:
5657
self.cursor.execute(query)
57-
except kinterbasdb.OperationalError as ex:
58+
except firebirdsql.OperationalError as ex:
5859
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
59-
except kinterbasdb.Error as ex:
60+
except firebirdsql.Error as ex:
6061
raise SqlmapConnectionException(getSafeExString(ex))
6162

62-
self.connector.commit()
63+
# commit non-SELECT (DML) here; select() commits only AFTER fetchall() because a Firebird COMMIT closes
64+
# open cursors (discarding an unfetched result set)
65+
if commit:
66+
self.connector.commit()
6367

6468
def select(self, query):
65-
self.execute(query)
66-
return self.fetchall()
69+
self.execute(query, commit=False)
70+
retVal = self.fetchall()
71+
self.connector.commit()
72+
return retVal

tests/test_deps.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ def tearDown(self):
5353
deps.logger = self._real_logger
5454

5555
def test_missing_driver_warns_with_library_name(self):
56-
# 'kinterbasdb' (Firebird driver) is essentially never installed, so the
57-
# probe must hit the except branch and emit a warning naming the library.
56+
# 'CUBRIDdb' (CUBRID driver) is not on PyPI and essentially never installed,
57+
# so the probe must hit the except branch and emit a warning naming the library.
5858
try:
59-
__import__("kinterbasdb")
60-
self.skipTest("kinterbasdb is unexpectedly installed")
59+
__import__("CUBRIDdb")
60+
self.skipTest("CUBRIDdb is unexpectedly installed")
6161
except ImportError:
6262
pass
6363

6464
checkDependencies()
6565

6666
warnings = self.rec.messages("warning")
6767
self.assertTrue(warnings, msg="no warnings captured for a missing driver")
68-
# the Firebird entry must name its third-party library in a warning
68+
# the CUBRID entry must name its third-party library in a warning
6969
self.assertTrue(
70-
any("kinterbasdb" in w for w in warnings),
71-
msg="missing Firebird driver did not produce a library-naming warning: %r" % warnings,
70+
any("CUBRID-Python" in w for w in warnings),
71+
msg="missing CUBRID driver did not produce a library-naming warning: %r" % warnings,
7272
)
7373

7474
def test_all_present_emits_all_installed_info(self):

0 commit comments

Comments
 (0)