From 6e2fce66aa66b5ec2a8fdd26640b1494c11bdc71 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 23 Oct 2012 15:34:59 +0200 Subject: [PATCH] Patch for an Issue #212 --- plugins/dbms/access/connector.py | 7 +++++-- plugins/dbms/db2/connector.py | 7 +++++-- plugins/dbms/firebird/connector.py | 6 ++++-- plugins/dbms/mssqlserver/connector.py | 6 ++++-- plugins/dbms/mysql/connector.py | 6 ++++-- plugins/dbms/oracle/connector.py | 6 ++++-- plugins/dbms/sqlite/connector.py | 6 ++++-- plugins/dbms/sybase/connector.py | 6 ++++-- 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/plugins/dbms/access/connector.py b/plugins/dbms/access/connector.py index f185bde7a..0910b63a5 100644 --- a/plugins/dbms/access/connector.py +++ b/plugins/dbms/access/connector.py @@ -10,6 +10,9 @@ try: except ImportError, _: pass +import logging + +from lib.core.data import conf from lib.core.data import logger from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapUnsupportedFeatureException @@ -49,14 +52,14 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except pyodbc.ProgrammingError, msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None def execute(self, query): try: self.cursor.execute(query) except (pyodbc.OperationalError, pyodbc.ProgrammingError), msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except pyodbc.Error, msg: raise sqlmapConnectionException, msg[1] diff --git a/plugins/dbms/db2/connector.py b/plugins/dbms/db2/connector.py index 2b235e153..e486ce088 100644 --- a/plugins/dbms/db2/connector.py +++ b/plugins/dbms/db2/connector.py @@ -10,6 +10,9 @@ try: except ImportError, _: pass +import logging + +from lib.core.data import conf from lib.core.data import logger from lib.core.exception import sqlmapConnectionException from plugins.generic.connector import Connector as GenericConnector @@ -42,14 +45,14 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except ibm_db_dbi.ProgrammingError, msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None def execute(self, query): try: self.cursor.execute(query) except (ibm_db_dbi.OperationalError, ibm_db_dbi.ProgrammingError), msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except ibm_db_dbi.InternalError, msg: raise sqlmapConnectionException, msg[1] diff --git a/plugins/dbms/firebird/connector.py b/plugins/dbms/firebird/connector.py index 269abe554..86fc7edb1 100644 --- a/plugins/dbms/firebird/connector.py +++ b/plugins/dbms/firebird/connector.py @@ -10,6 +10,8 @@ try: except ImportError, _: pass +import logging + from lib.core.data import logger from lib.core.exception import sqlmapConnectionException from lib.core.settings import UNICODE_ENCODING @@ -47,14 +49,14 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except kinterbasdb.OperationalError, msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None def execute(self, query): try: self.cursor.execute(query) except kinterbasdb.OperationalError, msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except kinterbasdb.Error, msg: raise sqlmapConnectionException, msg[1] diff --git a/plugins/dbms/mssqlserver/connector.py b/plugins/dbms/mssqlserver/connector.py index 24082ca84..c34554ef7 100644 --- a/plugins/dbms/mssqlserver/connector.py +++ b/plugins/dbms/mssqlserver/connector.py @@ -11,6 +11,8 @@ try: except ImportError, _: pass +import logging + from lib.core.convert import utf8encode from lib.core.data import conf from lib.core.data import logger @@ -49,7 +51,7 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except (pymssql.ProgrammingError, pymssql.OperationalError, _mssql.MssqlDatabaseException), msg: - logger.warn("(remote) %s" % str(msg).replace("\n", " ")) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % str(msg).replace("\n", " ")) return None def execute(self, query): @@ -59,7 +61,7 @@ class Connector(GenericConnector): self.cursor.execute(utf8encode(query)) retVal = True except (pymssql.OperationalError, pymssql.ProgrammingError), msg: - logger.warn("(remote) %s" % str(msg).replace("\n", " ")) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % str(msg).replace("\n", " ")) except pymssql.InternalError, msg: raise sqlmapConnectionException, msg diff --git a/plugins/dbms/mysql/connector.py b/plugins/dbms/mysql/connector.py index 932f5c1f0..ce19ce79b 100644 --- a/plugins/dbms/mysql/connector.py +++ b/plugins/dbms/mysql/connector.py @@ -10,6 +10,8 @@ try: except ImportError, _: pass +import logging + from lib.core.data import conf from lib.core.data import logger from lib.core.exception import sqlmapConnectionException @@ -44,7 +46,7 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: - logger.warn(msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None def execute(self, query): @@ -54,7 +56,7 @@ class Connector(GenericConnector): self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: - logger.warn("(remote) %s" % msg[1]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except pymysql.InternalError, msg: raise sqlmapConnectionException, msg[1] diff --git a/plugins/dbms/oracle/connector.py b/plugins/dbms/oracle/connector.py index 2746f2955..195b9aa34 100644 --- a/plugins/dbms/oracle/connector.py +++ b/plugins/dbms/oracle/connector.py @@ -10,9 +10,11 @@ try: except ImportError, _: pass +import logging import os from lib.core.convert import utf8encode +from lib.core.data import conf from lib.core.data import logger from lib.core.exception import sqlmapConnectionException from plugins.generic.connector import Connector as GenericConnector @@ -53,7 +55,7 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except cx_Oracle.InterfaceError, msg: - logger.warn("(remote) %s" % msg) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) return None def execute(self, query): @@ -63,7 +65,7 @@ class Connector(GenericConnector): self.cursor.execute(utf8encode(query)) retVal = True except (cx_Oracle.DatabaseError), msg: - logger.warn("(remote) %s" % msg) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) except cx_Oracle.InternalError, msg: raise sqlmapConnectionException, msg diff --git a/plugins/dbms/sqlite/connector.py b/plugins/dbms/sqlite/connector.py index 856d967ec..298d4e295 100644 --- a/plugins/dbms/sqlite/connector.py +++ b/plugins/dbms/sqlite/connector.py @@ -10,6 +10,8 @@ try: except ImportError, _: pass +import logging + from lib.core.convert import utf8encode from lib.core.data import conf from lib.core.data import logger @@ -68,14 +70,14 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except self.__sqlite.OperationalError, msg: - logger.warn("(remote) %s" % msg[0]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[0]) return None def execute(self, query): try: self.cursor.execute(utf8encode(query)) except self.__sqlite.OperationalError, msg: - logger.warn("(remote) %s" % msg[0]) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[0]) except self.__sqlite.DatabaseError, msg: raise sqlmapConnectionException, msg[0] diff --git a/plugins/dbms/sybase/connector.py b/plugins/dbms/sybase/connector.py index 124cff585..81fa3ced9 100644 --- a/plugins/dbms/sybase/connector.py +++ b/plugins/dbms/sybase/connector.py @@ -11,6 +11,8 @@ try: except ImportError, _: pass +import logging + from lib.core.convert import utf8encode from lib.core.data import conf from lib.core.data import logger @@ -49,14 +51,14 @@ class Connector(GenericConnector): try: return self.cursor.fetchall() except (pymssql.ProgrammingError, pymssql.OperationalError, _mssql.MssqlDatabaseException), msg: - logger.warn("(remote) %s" % msg) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) return None def execute(self, query): try: self.cursor.execute(utf8encode(query)) except (pymssql.OperationalError, pymssql.ProgrammingError), msg: - logger.warn("(remote) %s" % msg) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) except pymssql.InternalError, msg: raise sqlmapConnectionException, msg