Added unicode support also to Oracle connector - see #184.

This commit is contained in:
Bernardo Damele 2010-05-29 12:14:51 +00:00
parent e98b049e7f
commit 4ba22b5098

View File

@ -27,11 +27,16 @@ try:
except ImportError, _: except ImportError, _:
pass pass
import os
from lib.core.convert import utf8encode
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 plugins.generic.connector import Connector as GenericConnector from plugins.generic.connector import Connector as GenericConnector
os.environ["NLS_LANG"] = ".AL32UTF8"
class Connector(GenericConnector): class Connector(GenericConnector):
""" """
Homepage: http://cx-oracle.sourceforge.net/ Homepage: http://cx-oracle.sourceforge.net/
@ -46,6 +51,9 @@ class Connector(GenericConnector):
def connect(self): def connect(self):
self.initConnection() self.initConnection()
self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db) self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db)
self.__dsn = utf8encode(self.__dsn)
self.user = utf8encode(self.user)
self.password = utf8encode(self.password)
try: try:
self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA) self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA)
@ -68,7 +76,7 @@ class Connector(GenericConnector):
def execute(self, query): def execute(self, query):
try: try:
self.cursor.execute(query) self.cursor.execute(utf8encode(query))
except (cx_Oracle.DatabaseError), msg: except (cx_Oracle.DatabaseError), msg:
logger.log(8, msg) logger.log(8, msg)
except cx_Oracle.InternalError, msg: except cx_Oracle.InternalError, msg: