From 885b432808933dc614129084aaf5e71ddfe94869 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 23 Nov 2011 21:39:53 +0000 Subject: [PATCH] minor update --- lib/core/option.py | 39 ++------------------------------------- lib/core/settings.py | 4 ++-- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index dc32272ae..182e59bb4 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -81,7 +81,7 @@ from lib.core.optiondict import optDict from lib.core.settings import CODECS_LIST_PAGE from lib.core.settings import DEFAULT_GET_POST_DELIMITER from lib.core.settings import DEFAULT_PAGE_ENCODING -from lib.core.settings import DEFAULT_TOR_PORTS +from lib.core.settings import DEFAULT_TOR_SOCKS_PORT from lib.core.settings import GENERAL_IP_ADDRESS_REGEX from lib.core.settings import IS_WIN from lib.core.settings import PLATFORM @@ -1682,44 +1682,9 @@ def __setTorSocksProxySettings(): infoMsg = "setting Tor SOCKS proxy settings" logger.info(infoMsg) - socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, 'localhost', 9050) + socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, LOCALHOST, DEFAULT_TOR_SOCKS_PORT) socks.wrapmodule(urllib2) -def __setTorHTTPProxySettings(): - if not conf.tor: - return - - infoMsg = "setting Tor HTTP proxy settings" - logger.info(infoMsg) - - found = None - - for port in DEFAULT_TOR_PORTS: - try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((LOCALHOST, port)) - found = port - break - except socket.error: - pass - - s.close() - - if found: - conf.proxy = "http://%s:%d" % (LOCALHOST, found) - else: - errMsg = "can't establish connection with the Tor proxy. " - errMsg += "Please make sure that you have Vidalia, Privoxy or " - errMsg += "Polipo bundle installed for you to be able to " - errMsg += "successfully use --tor switch " - - if IS_WIN: - errMsg += "(e.g. https://www.torproject.org/projects/vidalia.html.en)" - else: - errMsg += "(e.g. http://www.coresec.org/2011/04/24/sqlmap-with-tor/)" - - raise sqlmapConnectionException, errMsg - def __checkTor(): if conf.checkTor: infoMsg = "checking Tor connection" diff --git a/lib/core/settings.py b/lib/core/settings.py index 7a72873bf..e2a4d1000 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -347,8 +347,8 @@ SQL_SCALAR_REGEX = r"\A(SELECT(?!\s+DISTINCT\(?))?\s*\w*\(" # IP address of the localhost LOCALHOST = "127.0.0.1" -# Default ports used in Tor proxy bundles -DEFAULT_TOR_PORTS = (8123, 8118) +# Default port used by Tor +DEFAULT_TOR_SOCKS_PORT = 9050 # Percentage below which comparison engine could have problems LOW_TEXT_PERCENT = 20