6666from lib .core .enums import MOBILES
6767from lib .core .enums import PAYLOAD
6868from lib .core .enums import PRIORITY
69+ from lib .core .enums import PROXYTYPE
6970from lib .core .enums import REFLECTIVE_COUNTER
7071from lib .core .exception import sqlmapConnectionException
7172from lib .core .exception import sqlmapFilePathException
@@ -1337,6 +1338,9 @@ class _(unicode): pass
13371338 if conf .csvDel :
13381339 conf .csvDel = conf .csvDel .decode ('string_escape' ) # e.g. '\\t' -> '\t'
13391340
1341+ if conf .torType :
1342+ conf .torType = conf .torType .upper ()
1343+
13401344 threadData = getCurrentThreadData ()
13411345 threadData .reset ()
13421346
@@ -1680,10 +1684,16 @@ def __setTrafficOutputFP():
16801684
16811685 conf .trafficFP = openFile (conf .trafficFile , "w+" )
16821686
1683- def __setTorHttpProxySettings ():
1684- if not conf .torHttp :
1687+ def __setTorProxySettings ():
1688+ if not conf .tor :
16851689 return
16861690
1691+ if conf .torType == PROXYTYPE .HTTP :
1692+ __setTorHttpProxySettings ()
1693+ else :
1694+ __setTorSocksProxySettings ()
1695+
1696+ def __setTorHttpProxySettings ():
16871697 infoMsg = "setting Tor HTTP proxy settings"
16881698 logger .info (infoMsg )
16891699
@@ -1715,17 +1725,12 @@ def __setTorHttpProxySettings():
17151725
17161726 raise sqlmapConnectionException , errMsg
17171727
1718- conf .tor = True
1719-
17201728def __setTorSocksProxySettings ():
1721- if not conf .tor or conf .torHttp :
1722- return
1723-
17241729 infoMsg = "setting Tor SOCKS proxy settings"
17251730 logger .info (infoMsg )
17261731
17271732 # Has to be SOCKS5 to prevent DNS leaks (http://en.wikipedia.org/wiki/Tor_%28anonymity_network%29)
1728- socks .setdefaultproxy (socks .PROXY_TYPE_SOCKS5 , LOCALHOST , DEFAULT_TOR_SOCKS_PORT )
1733+ socks .setdefaultproxy (socks .PROXY_TYPE_SOCKS5 if conf . torType == PROXYTYPE . SOCKS5 else socks . PROXY_TYPE_SOCKS4 , LOCALHOST , DEFAULT_TOR_SOCKS_PORT )
17291734 socks .wrapmodule (urllib2 )
17301735
17311736def __checkTor ():
@@ -1806,12 +1811,12 @@ def __basicOptionValidation():
18061811 errMsg = "switch --tor is incompatible with switch --proxy"
18071812 raise sqlmapSyntaxException , errMsg
18081813
1809- if conf .torHttp and conf .proxy :
1810- errMsg = "switch --tor-http is incompatible with switch --proxy"
1814+ if conf .checkTor and not any ([ conf .tor , conf . proxy ]) :
1815+ errMsg = "switch --check-tor requires usage of switch --tor (or -- proxy with HTTP proxy address using Tor) "
18111816 raise sqlmapSyntaxException , errMsg
18121817
1813- if conf .checkTor and not any ([ conf . tor , conf . torHttp , conf . proxy ] ):
1814- errMsg = "switch --check- tor requires usage of switch --tor (or --proxy with HTTP proxy address using Tor)"
1818+ if conf .torType not in getPublicTypeMembers ( PROXYTYPE , True ):
1819+ errMsg = "switch --tor-type accepts one of following values: %s" % ", " . join ( getPublicTypeMembers ( PROXYTYPE , True ))
18151820 raise sqlmapSyntaxException , errMsg
18161821
18171822 if conf .skip and conf .testParameter :
@@ -1826,10 +1831,6 @@ def __basicOptionValidation():
18261831 errMsg = "switch --proxy is incompatible with switch --ignore-proxy"
18271832 raise sqlmapSyntaxException , errMsg
18281833
1829- if conf .tor and conf .torHttp :
1830- errMsg = "switch --tor is incompatible with switch --tor-http"
1831- raise sqlmapSyntaxException , errMsg
1832-
18331834 if conf .forms and any ([conf .logFile , conf .bulkFile , conf .direct , conf .requestFile , conf .googleDork ]):
18341835 errMsg = "switch --forms is compatible only with -u (--url) target switch"
18351836 raise sqlmapSyntaxException , errMsg
@@ -1877,8 +1878,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
18771878 __cleanupOptions ()
18781879 __checkDependencies ()
18791880 __basicOptionValidation ()
1880- __setTorSocksProxySettings ()
1881- __setTorHttpProxySettings ()
1881+ __setTorProxySettings ()
18821882 __setMultipleTargets ()
18831883 __setTamperingFunctions ()
18841884 __setTrafficOutputFP ()
0 commit comments