diff --git a/lib/request/direct.py b/lib/request/direct.py index cc5c487cd..4eec90e4a 100644 --- a/lib/request/direct.py +++ b/lib/request/direct.py @@ -26,6 +26,7 @@ from lib.core.agent import agent from lib.core.common import dataToSessionFile from lib.core.convert import base64pickle from lib.core.convert import base64unpickle +from lib.core.convert import utf8decode from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -67,7 +68,10 @@ def direct(query, content=True): if len(output) == 1: if len(output[0]) == 1: - return unicode(list(output)[0][0]) + out = list(output)[0][0] + if isinstance(out, str): + out = utf8decode(out) + return out else: return list(output) else: diff --git a/plugins/dbms/postgresql/connector.py b/plugins/dbms/postgresql/connector.py index 885b0056f..4abe50b04 100644 --- a/plugins/dbms/postgresql/connector.py +++ b/plugins/dbms/postgresql/connector.py @@ -24,6 +24,9 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA try: import psycopg2 + import psycopg2.extensions + psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) + psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) except ImportError, _: pass @@ -54,6 +57,8 @@ class Connector(GenericConnector): except psycopg2.OperationalError, msg: raise sqlmapConnectionException, msg + self.connector.set_client_encoding('UNICODE') + self.setCursor() self.connected()