mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-04 14:55:40 +00:00
Some more patches for -d
This commit is contained in:
parent
3378f8df34
commit
e23a91f6db
6 changed files with 32 additions and 26 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue