mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-14 10:03:04 +03:00
Added support for direct connection (-d switch) to IBM DB2
This commit is contained in:
parent
9eb683531d
commit
fe686feefa
|
@ -1,31 +1,57 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
Copyright (c) 2006-2011 sqlmap developers (http://sqlmap.sourceforge.net/)
|
|
||||||
See the file 'doc/COPYING' for copying permission
|
|
||||||
"""
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ibm_db
|
import ibm_db_dbi
|
||||||
except ImportError, _:
|
except ImportError, _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
from lib.core.exception import sqlmapConnectionException
|
from lib.core.exception import sqlmapConnectionException
|
||||||
from lib.core.exception import sqlmapUnsupportedFeatureException
|
|
||||||
|
|
||||||
from plugins.generic.connector import Connector as GenericConnector
|
from plugins.generic.connector import Connector as GenericConnector
|
||||||
|
|
||||||
class Connector(GenericConnector):
|
class Connector(GenericConnector):
|
||||||
"""
|
"""
|
||||||
Homepage: http://code.google.com/p/ibm-db/
|
Homepage: http://code.google.com/p/ibm-db/
|
||||||
User guide: http://code.google.com/p/ibm-db/wiki/ibm_db_README
|
User guide: http://code.google.com/p/ibm-db/wiki/README
|
||||||
API: http://code.google.com/p/ibm-db/wiki/APIs
|
API: http://www.python.org/dev/peps/pep-0249/
|
||||||
Debian package: <none>
|
License: Apache License 2.0
|
||||||
License: Apache
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
GenericConnector.__init__(self)
|
GenericConnector.__init__(self)
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
self.initConnection()
|
||||||
|
|
||||||
|
try:
|
||||||
|
database = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=%s;HOSTNAME=%s;PORT=%s;PROTOCOL=TCPIP;" % (self.db, self.hostname, self.port)
|
||||||
|
self.connector = ibm_db_dbi.connect(database, self.user, self.password)
|
||||||
|
except ibm_db_dbi.OperationalError, msg:
|
||||||
|
raise sqlmapConnectionException, msg
|
||||||
|
|
||||||
|
|
||||||
|
self.setCursor()
|
||||||
|
self.connected()
|
||||||
|
|
||||||
|
def fetchall(self):
|
||||||
|
try:
|
||||||
|
return self.cursor.fetchall()
|
||||||
|
except ibm_db_dbi.ProgrammingError, msg:
|
||||||
|
logger.warn(msg[1])
|
||||||
|
return None
|
||||||
|
|
||||||
|
def execute(self, query):
|
||||||
|
try:
|
||||||
|
self.cursor.execute(query)
|
||||||
|
except (ibm_db_dbi.OperationalError, ibm_db_dbi.ProgrammingError), msg:
|
||||||
|
logger.warn(msg[1])
|
||||||
|
except ibm_db_dbi.InternalError, msg:
|
||||||
|
raise sqlmapConnectionException, msg[1]
|
||||||
|
|
||||||
|
self.connector.commit()
|
||||||
|
|
||||||
|
def select(self, query):
|
||||||
|
self.execute(query)
|
||||||
|
return self.fetchall()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user