diff --git a/lib/core/option.py b/lib/core/option.py index 7f38508e9..aed2c5572 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1732,6 +1732,19 @@ def __setTorProxySettings(): raise sqlmapConnectionException, errMsg +def __checkTor(): + infoMsg = "checking Tor connection" + logger.info(infoMsg) + + if conf.checkTor: + page, _, _ = Request.getPage(url="https://check.torproject.org/", raise404=False) + if not page or 'Congratulations' not in page: + errMsg = "it seems that your Tor connection is not properly set" + raise sqlmapConnectionException, errMsg + else: + infoMsg = "Tor connection is properly set" + logger.info(infoMsg) + def __basicOptionValidation(): if conf.limitStart is not None and not (isinstance(conf.limitStart, int) and conf.limitStart > 0): errMsg = "value for --start (limitStart) option must be an integer value greater than zero (>0)" @@ -1795,6 +1808,10 @@ def __basicOptionValidation(): errMsg = "switch --tor is incompatible with switch --proxy" raise sqlmapSyntaxException, errMsg + if conf.checkTor and not conf.tor: + errMsg = "switch --check-tor requires usage of switch --tor" + raise sqlmapSyntaxException, errMsg + if conf.skip and conf.testParameter: errMsg = "switch --skip is incompatible with switch -p" raise sqlmapSyntaxException, errMsg @@ -1881,6 +1898,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False): __setGoogleDorking() __setBulkMultipleTargets() __urllib2Opener() + __checkTor() __setCrawler() __findPageForms() __setDBMS() diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index c1ac8cae4..8f5b19f3e 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -167,7 +167,8 @@ optDict = { "parseErrors": "boolean", "replicate": "boolean", "updateAll": "boolean", - "tor": "boolean" + "tor": "boolean", + "checkTor": "boolean" }, "Miscellaneous": { diff --git a/lib/core/settings.py b/lib/core/settings.py index ba004c92e..8870153fd 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -348,7 +348,7 @@ SQL_SCALAR_REGEX = r"\A(SELECT(?!\s+DISTINCT\(?))?\s*\w*\(" LOCALHOST = "127.0.0.1" # Default ports used in Tor proxy bundles -DEFAULT_TOR_PORTS = (8118, 8123) +DEFAULT_TOR_PORTS = (8123, 8118) # Percentage below which comparison engine could have problems LOW_TEXT_PERCENT = 20 diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 59967217d..4447caf41 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -520,6 +520,10 @@ def cmdLineParser(): action="store_true", help="Use default Tor (Vidalia/Privoxy/Polipo) proxy address") + general.add_option("--check-tor", dest="checkTor", + action="store_true", + help="Check to see if Tor is used properly") + general.add_option("--update", dest="updateAll", action="store_true", help="Update sqlmap") diff --git a/sqlmap.conf b/sqlmap.conf index 139af26d4..8ac6e9d7c 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -563,6 +563,10 @@ replicate = False # Valid: True or False tor = False +# Check to see if Tor is used properly +# Valid: True or False +checkTor = False + # Update sqlmap. # Valid: True or False updateAll = False