This class defines generic dbms protocol functionalities for plugins.
| 13 | from lib.core.exception import SqlmapUndefinedMethod |
| 14 | |
| 15 | class Connector(object): |
| 16 | """ |
| 17 | This class defines generic dbms protocol functionalities for plugins. |
| 18 | """ |
| 19 | |
| 20 | def __init__(self): |
| 21 | self.connector = None |
| 22 | self.cursor = None |
| 23 | self.hostname = None |
| 24 | |
| 25 | def initConnection(self): |
| 26 | self.user = conf.dbmsUser or "" |
| 27 | self.password = conf.dbmsPass or "" |
| 28 | self.hostname = conf.hostname |
| 29 | self.port = conf.port |
| 30 | self.db = conf.dbmsDb |
| 31 | |
| 32 | def printConnected(self): |
| 33 | if self.hostname and self.port: |
| 34 | infoMsg = "connection to %s server '%s:%d' established" % (conf.dbms, self.hostname, self.port) |
| 35 | logger.info(infoMsg) |
| 36 | |
| 37 | def closed(self): |
| 38 | if self.hostname and self.port: |
| 39 | infoMsg = "connection to %s server '%s:%d' closed" % (conf.dbms, self.hostname, self.port) |
| 40 | logger.info(infoMsg) |
| 41 | |
| 42 | self.connector = None |
| 43 | self.cursor = None |
| 44 | |
| 45 | def initCursor(self): |
| 46 | self.cursor = self.connector.cursor() |
| 47 | |
| 48 | def close(self): |
| 49 | try: |
| 50 | if self.cursor: |
| 51 | self.cursor.close() |
| 52 | if self.connector: |
| 53 | self.connector.close() |
| 54 | except Exception as ex: |
| 55 | logger.debug(ex) |
| 56 | finally: |
| 57 | self.closed() |
| 58 | |
| 59 | def checkFileDb(self): |
| 60 | if not os.path.exists(self.db): |
| 61 | errMsg = "the provided database file '%s' does not exist" % self.db |
| 62 | raise SqlmapFilePathException(errMsg) |
| 63 | |
| 64 | def connect(self): |
| 65 | errMsg = "'connect' method must be defined " |
| 66 | errMsg += "inside the specific DBMS plugin" |
| 67 | raise SqlmapUndefinedMethod(errMsg) |
| 68 | |
| 69 | def fetchall(self): |
| 70 | errMsg = "'fetchall' method must be defined " |
| 71 | errMsg += "inside the specific DBMS plugin" |
| 72 | raise SqlmapUndefinedMethod(errMsg) |
no outgoing calls
no test coverage detected
searching dependent graphs…