mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-04 09:57:38 +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 conf
 | 
				
			||||||
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 lib.core.settings import IS_WIN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from plugins.generic.connector import Connector as GenericConnector
 | 
					from plugins.generic.connector import Connector as GenericConnector
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,32 +48,25 @@ class Connector(GenericConnector):
 | 
				
			||||||
        GenericConnector.__init__(self)
 | 
					        GenericConnector.__init__(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def connect(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
 | 
					        self.initConnection()
 | 
				
			||||||
        for connString in ('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db, 'DSN=%s' % self.db):
 | 
					        self.checkFileDb()
 | 
				
			||||||
            try:
 | 
					
 | 
				
			||||||
                self.connector = pyodbc.connect(connString)
 | 
					        try:
 | 
				
			||||||
                break
 | 
					            self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db)
 | 
				
			||||||
            except pyodbc.Error, msg:
 | 
					        except (pyodbc.Error, pyodbc.OperationalError), msg:
 | 
				
			||||||
                lastMsg = msg
 | 
					            raise sqlmapConnectionException, msg[1]
 | 
				
			||||||
            except pyodbc.OperationalError, msg:
 | 
					 | 
				
			||||||
                raise sqlmapConnectionException, msg[1]
 | 
					 | 
				
			||||||
        if not self.connector:
 | 
					 | 
				
			||||||
            raise sqlmapConnectionException, lastMsg[1]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.setCursor()
 | 
					        self.setCursor()
 | 
				
			||||||
        self.connected()
 | 
					        self.connected()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def fetchall(self):
 | 
					    def fetchall(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            output = self.cursor.fetchall()
 | 
					            return 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
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        except pyodbc.ProgrammingError, msg:
 | 
					        except pyodbc.ProgrammingError, msg:
 | 
				
			||||||
            logger.log(8, msg[1])
 | 
					            logger.log(8, msg[1])
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user