Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 563c0c1

Browse files
committed
adding switch --tor-type
1 parent 316e27a commit 563c0c1

8 files changed

Lines changed: 37 additions & 28 deletions

File tree

lib/controller/controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ def start():
487487
break
488488

489489
msg = "%s parameter '%s' " % (injection.place, injection.parameter)
490-
msg += "is vulnerable. Do you want to keep testing the others? [y/N] "
491-
test = readInput(msg, default="N")
490+
msg += "is vulnerable. Do you want to keep testing the others? [Y/n] "
491+
test = readInput(msg, default="Y")
492492

493493
if test[0] in ("n", "N"):
494494
proceed = False

lib/core/defaults.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"threads": 1,
2323
"level": 1,
2424
"risk": 1,
25-
"tech": "BEUST"
25+
"tech": "BEUST",
26+
"torType": "HTTP"
2627
}
2728

2829
defaults = AttribDict(_defaults)

lib/core/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class MOBILES:
8585
NEXUS = "Google Nexus One;Mozilla/5.0 (Linux; U; Android 2.2; en-US; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
8686
NOKIA = "Nokia N97;Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/10.0.012; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) WicKed/7.1.12344"
8787

88+
class PROXYTYPE:
89+
HTTP = "HTTP"
90+
SOCKS4 = "SOCKS4"
91+
SOCKS5 = "SOCKS5"
92+
8893
class HTTPHEADER:
8994
ACCEPT = "Accept"
9095
ACCEPT_CHARSET = "Accept-Charset"

lib/core/option.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
from lib.core.enums import MOBILES
6767
from lib.core.enums import PAYLOAD
6868
from lib.core.enums import PRIORITY
69+
from lib.core.enums import PROXYTYPE
6970
from lib.core.enums import REFLECTIVE_COUNTER
7071
from lib.core.exception import sqlmapConnectionException
7172
from 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-
17201728
def __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

17311736
def __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()

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"replicate": "boolean",
173173
"updateAll": "boolean",
174174
"tor": "boolean",
175+
"torType": "string",
175176
},
176177

177178
"Miscellaneous": {

lib/parse/cmdline.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ def cmdLineParser():
529529

530530
general.add_option("--tor", dest="tor",
531531
action="store_true",
532-
help="Use default Tor SOCKS5 proxy address")
532+
help="Use Tor anonymity network")
533+
534+
general.add_option("--tor-type", dest="torType",
535+
help="Set Tor proxy type (HTTP - default, SOCKS4 or SOCKS5)")
533536

534537
general.add_option("--update", dest="updateAll",
535538
action="store_true",
@@ -609,9 +612,6 @@ def cmdLineParser():
609612
parser.add_option("--test-filter", dest="testFilter",
610613
help=SUPPRESS_HELP)
611614

612-
parser.add_option("--tor-http", dest="torHttp", action="store_true",
613-
help=SUPPRESS_HELP)
614-
615615
parser.add_option_group(target)
616616
parser.add_option_group(request)
617617
parser.add_option_group(optimization)

lib/request/connect.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ def __retryProxy(**kwargs):
104104
warnMsg += "(e.g. https://www.torproject.org/download/download.html.en)"
105105
else:
106106
warnMsg += "(e.g. https://help.ubuntu.com/community/Tor)"
107-
warnMsg += " (or try hidden switch --tor-http "
108-
warnMsg += " if you want to utilize Tor proxy bundles)"
109107
else:
110108
warnMsg = "if the problem persists please check that the provided "
111109
warnMsg += "target url is valid. If it is, you can try to rerun "

sqlmap.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,14 @@ parseErrors = False
571571
# Valid: True or False
572572
replicate = False
573573

574-
# Use default Tor SOCKS5 proxy address.
574+
# Use Use Tor anonymity network.
575575
# Valid: True or False
576576
tor = False
577577

578+
# Set Tor proxy type.
579+
# Valid: HTTP, SOCKS4, SOCKS5
580+
torType = HTTP
581+
578582
# Update sqlmap.
579583
# Valid: True or False
580584
updateAll = False

0 commit comments

Comments
 (0)