@@ -1732,6 +1732,19 @@ def __setTorProxySettings():
17321732
17331733 raise sqlmapConnectionException , errMsg
17341734
1735+ def __checkTor ():
1736+ infoMsg = "checking Tor connection"
1737+ logger .info (infoMsg )
1738+
1739+ if conf .checkTor :
1740+ page , _ , _ = Request .getPage (url = "https://check.torproject.org/" , raise404 = False )
1741+ if not page or 'Congratulations' not in page :
1742+ errMsg = "it seems that your Tor connection is not properly set"
1743+ raise sqlmapConnectionException , errMsg
1744+ else :
1745+ infoMsg = "Tor connection is properly set"
1746+ logger .info (infoMsg )
1747+
17351748def __basicOptionValidation ():
17361749 if conf .limitStart is not None and not (isinstance (conf .limitStart , int ) and conf .limitStart > 0 ):
17371750 errMsg = "value for --start (limitStart) option must be an integer value greater than zero (>0)"
@@ -1795,6 +1808,10 @@ def __basicOptionValidation():
17951808 errMsg = "switch --tor is incompatible with switch --proxy"
17961809 raise sqlmapSyntaxException , errMsg
17971810
1811+ if conf .checkTor and not conf .tor :
1812+ errMsg = "switch --check-tor requires usage of switch --tor"
1813+ raise sqlmapSyntaxException , errMsg
1814+
17981815 if conf .skip and conf .testParameter :
17991816 errMsg = "switch --skip is incompatible with switch -p"
18001817 raise sqlmapSyntaxException , errMsg
@@ -1881,6 +1898,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
18811898 __setGoogleDorking ()
18821899 __setBulkMultipleTargets ()
18831900 __urllib2Opener ()
1901+ __checkTor ()
18841902 __setCrawler ()
18851903 __findPageForms ()
18861904 __setDBMS ()
0 commit comments