mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 08:14:24 +03:00
direct connection supported only on Windows machines
This commit is contained in:
parent
939fa5d2c4
commit
6762f592c1
|
@ -30,6 +30,8 @@ except ImportError, _:
|
|||
from lib.core.data import conf
|
||||
from lib.core.data import logger
|
||||
from lib.core.exception import sqlmapConnectionException
|
||||
from lib.core.exception import sqlmapUnsupportedFeatureException
|
||||
from lib.core.settings import IS_WIN
|
||||
|
||||
from plugins.generic.connector import Connector as GenericConnector
|
||||
|
||||
|
@ -46,32 +48,25 @@ class Connector(GenericConnector):
|
|||
GenericConnector.__init__(self)
|
||||
|
||||
def connect(self):
|
||||
self.initConnection()
|
||||
if not IS_WIN:
|
||||
errMsg = "currently, direct connection to Microsoft Access database(s) "
|
||||
errMsg += "is restricted to Windows platforms"
|
||||
raise sqlmapUnsupportedFeatureException, errMsg
|
||||
|
||||
lastMsg = None
|
||||
for connString in ('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db, 'DSN=%s' % self.db):
|
||||
try:
|
||||
self.connector = pyodbc.connect(connString)
|
||||
break
|
||||
except pyodbc.Error, msg:
|
||||
lastMsg = msg
|
||||
except pyodbc.OperationalError, msg:
|
||||
raise sqlmapConnectionException, msg[1]
|
||||
if not self.connector:
|
||||
raise sqlmapConnectionException, lastMsg[1]
|
||||
self.initConnection()
|
||||
self.checkFileDb()
|
||||
|
||||
try:
|
||||
self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db)
|
||||
except (pyodbc.Error, pyodbc.OperationalError), msg:
|
||||
raise sqlmapConnectionException, msg[1]
|
||||
|
||||
self.setCursor()
|
||||
self.connected()
|
||||
|
||||
def fetchall(self):
|
||||
try:
|
||||
output = self.cursor.fetchall()
|
||||
for i in xrange(len(output)):
|
||||
for j in xrange(len(output[i])):
|
||||
if type(output[i][j]) == str and output[i][j].find('\0') != -1:
|
||||
output[i][j] = output[i][j][:output[i][j].find('\0')].rstrip()
|
||||
return output
|
||||
|
||||
return self.cursor.fetchall()
|
||||
except pyodbc.ProgrammingError, msg:
|
||||
logger.log(8, msg[1])
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue
Block a user