Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6762f59

Browse files
committed
direct connection supported only on Windows machines
1 parent 939fa5d commit 6762f59

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

plugins/dbms/access/connector.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from lib.core.data import conf
3131
from lib.core.data import logger
3232
from lib.core.exception import sqlmapConnectionException
33+
from lib.core.exception import sqlmapUnsupportedFeatureException
34+
from lib.core.settings import IS_WIN
3335

3436
from plugins.generic.connector import Connector as GenericConnector
3537

@@ -46,32 +48,25 @@ def __init__(self):
4648
GenericConnector.__init__(self)
4749

4850
def connect(self):
51+
if not IS_WIN:
52+
errMsg = "currently, direct connection to Microsoft Access database(s) "
53+
errMsg += "is restricted to Windows platforms"
54+
raise sqlmapUnsupportedFeatureException, errMsg
55+
4956
self.initConnection()
57+
self.checkFileDb()
5058

51-
lastMsg = None
52-
for connString in ('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db, 'DSN=%s' % self.db):
53-
try:
54-
self.connector = pyodbc.connect(connString)
55-
break
56-
except pyodbc.Error, msg:
57-
lastMsg = msg
58-
except pyodbc.OperationalError, msg:
59-
raise sqlmapConnectionException, msg[1]
60-
if not self.connector:
61-
raise sqlmapConnectionException, lastMsg[1]
59+
try:
60+
self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db)
61+
except (pyodbc.Error, pyodbc.OperationalError), msg:
62+
raise sqlmapConnectionException, msg[1]
6263

6364
self.setCursor()
6465
self.connected()
6566

6667
def fetchall(self):
6768
try:
68-
output = self.cursor.fetchall()
69-
for i in xrange(len(output)):
70-
for j in xrange(len(output[i])):
71-
if type(output[i][j]) == str and output[i][j].find('\0') != -1:
72-
output[i][j] = output[i][j][:output[i][j].find('\0')].rstrip()
73-
return output
74-
69+
return self.cursor.fetchall()
7570
except pyodbc.ProgrammingError, msg:
7671
logger.log(8, msg[1])
7772
return None

0 commit comments

Comments
 (0)