diff --git a/plugins/dbms/mssqlserver/connector.py b/plugins/dbms/mssqlserver/connector.py index 0c9602b5a..53a09f569 100644 --- a/plugins/dbms/mssqlserver/connector.py +++ b/plugins/dbms/mssqlserver/connector.py @@ -56,20 +56,27 @@ class Connector(GenericConnector): return None def execute(self, query): + retVal = False + try: self.cursor.execute(utf8encode(query)) + retVal = True except (pymssql.OperationalError, pymssql.ProgrammingError), msg: logger.warn(msg) except pymssql.InternalError, msg: raise sqlmapConnectionException, msg + return retVal + def select(self, query): - self.execute(query) - value = self.fetchall() + retVal = None - try: - self.connector.commit() - except pymssql.OperationalError: - pass + if self.execute(query): + retVal = self.fetchall() - return value + try: + self.connector.commit() + except pymssql.OperationalError: + pass + + return retVal diff --git a/plugins/dbms/mysql/connector.py b/plugins/dbms/mysql/connector.py index c3082a2b6..5ee413288 100644 --- a/plugins/dbms/mysql/connector.py +++ b/plugins/dbms/mysql/connector.py @@ -51,8 +51,11 @@ class Connector(GenericConnector): return None def execute(self, query): + retVal = False + try: self.cursor.execute(query) + retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.warn(msg[1]) except pymysql.InternalError, msg: @@ -60,6 +63,12 @@ class Connector(GenericConnector): self.connector.commit() + return retVal + def select(self, query): - self.execute(query) - return self.fetchall() + retVal = None + + if self.execute(query): + retVal = self.fetchall() + + return retVal diff --git a/plugins/dbms/oracle/connector.py b/plugins/dbms/oracle/connector.py index 29e113341..b86c2002b 100644 --- a/plugins/dbms/oracle/connector.py +++ b/plugins/dbms/oracle/connector.py @@ -60,8 +60,11 @@ class Connector(GenericConnector): return None def execute(self, query): + retVal = False + try: self.cursor.execute(utf8encode(query)) + retVal = True except (cx_Oracle.DatabaseError), msg: logger.warn(msg) except cx_Oracle.InternalError, msg: @@ -69,6 +72,12 @@ class Connector(GenericConnector): self.connector.commit() + return retVal + def select(self, query): - self.execute(query) - return self.fetchall() + retVal = None + + if self.execute(query): + retVal = self.fetchall() + + return retVal diff --git a/plugins/dbms/postgresql/connector.py b/plugins/dbms/postgresql/connector.py index 2569c954e..942b13c01 100644 --- a/plugins/dbms/postgresql/connector.py +++ b/plugins/dbms/postgresql/connector.py @@ -55,8 +55,11 @@ class Connector(GenericConnector): return None def execute(self, query): + retVal = False + try: self.cursor.execute(query) + retVal = True except (psycopg2.OperationalError, psycopg2.ProgrammingError), msg: logger.warn(msg) except psycopg2.InternalError, msg: @@ -64,6 +67,12 @@ class Connector(GenericConnector): self.connector.commit() + return retVal + def select(self, query): - self.execute(query) - return self.fetchall() + retVal = None + + if self.execute(query): + retVal = self.fetchall() + + return retVal