From 101d1f0d497dd435cbf6165a966801d69745f228 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 3 Dec 2018 23:18:52 +0100 Subject: [PATCH] Fixes #3395 --- lib/controller/checks.py | 7 ++++++- lib/core/option.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index aee960b62..104aeec9e 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -70,6 +70,7 @@ from lib.core.enums import PAYLOAD from lib.core.enums import PLACE from lib.core.enums import REDIRECTION from lib.core.exception import SqlmapConnectionException +from lib.core.exception import SqlmapDataException from lib.core.exception import SqlmapNoneDataException from lib.core.exception import SqlmapSilentQuitException from lib.core.exception import SqlmapSkipTargetException @@ -1530,10 +1531,14 @@ def checkConnection(suppressOutput=False): except socket.gaierror: errMsg = "host '%s' does not exist" % conf.hostname raise SqlmapConnectionException(errMsg) - except (socket.error, UnicodeError), ex: + except socket.error, ex: errMsg = "problem occurred while " errMsg += "resolving a host name '%s' ('%s')" % (conf.hostname, getSafeExString(ex)) raise SqlmapConnectionException(errMsg) + except UnicodeError, ex: + errMsg = "problem occurred while " + errMsg += "handling a host name '%s' ('%s')" % (conf.hostname, getSafeExString(ex)) + raise SqlmapDataException(errMsg) if not suppressOutput and not conf.dummy and not conf.offline: infoMsg = "testing connection to the target URL" diff --git a/lib/core/option.py b/lib/core/option.py index 95fd7e7cb..8081e3462 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -82,6 +82,7 @@ from lib.core.enums import PROXY_TYPE from lib.core.enums import REFLECTIVE_COUNTER from lib.core.enums import WIZARD from lib.core.exception import SqlmapConnectionException +from lib.core.exception import SqlmapDataException from lib.core.exception import SqlmapFilePathException from lib.core.exception import SqlmapGenericException from lib.core.exception import SqlmapInstallationException @@ -1364,7 +1365,12 @@ def _setHostname(): """ if conf.url: - conf.hostname = urlparse.urlsplit(conf.url).netloc.split(':')[0] + try: + conf.hostname = urlparse.urlsplit(conf.url).netloc.split(':')[0] + except ValueError, ex: + errMsg = "problem occurred while " + errMsg += "parsing an URL '%s' ('%s')" % (conf.url, getSafeExString(ex)) + raise SqlmapDataException(errMsg) def _setHTTPTimeout(): """