implemented --tor-port by request

This commit is contained in:
Miroslav Stampar 2011-12-23 10:57:09 +00:00
parent 89d2c7c042
commit b71a81041d
5 changed files with 19 additions and 2 deletions

View File

@ -470,6 +470,9 @@ Ryan Sears <rdsears@mtu.edu>
Uemit Seren <uemit.seren@gmail.com>
for reporting a minor adjustment when running with python 2.6
Shane Sewell <ssewell@gmail.com>
for suggesting a feature
Ahmed Shawky <ahmed@isecur1ty.org>
for reporting a major bug with improper handling of parameter values
for reporting a bug

View File

@ -1338,6 +1338,9 @@ def __cleanupOptions():
if conf.csvDel:
conf.csvDel = conf.csvDel.decode('string_escape') # e.g. '\\t' -> '\t'
if conf.torPort and conf.torPort.isdigit():
conf.torPort = int(conf.torPort)
if conf.torType:
conf.torType = conf.torType.upper()
@ -1701,7 +1704,7 @@ def __setTorHttpProxySettings():
found = None
for port in DEFAULT_TOR_HTTP_PORTS:
for port in (DEFAULT_TOR_HTTP_PORTS if not conf.torPort else (conf.torPort, )):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((LOCALHOST, port))
@ -1732,7 +1735,7 @@ def __setTorSocksProxySettings():
logger.info(infoMsg)
# Has to be SOCKS5 to prevent DNS leaks (http://en.wikipedia.org/wiki/Tor_%28anonymity_network%29)
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 if conf.torType == PROXYTYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4, LOCALHOST, DEFAULT_TOR_SOCKS_PORT)
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 if conf.torType == PROXYTYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4, LOCALHOST, conf.torPort or DEFAULT_TOR_SOCKS_PORT)
socks.wrapmodule(urllib2)
def __checkTor():
@ -1821,6 +1824,10 @@ def __basicOptionValidation():
errMsg = "switch --check-tor requires usage of switch --tor (or --proxy with HTTP proxy address using Tor)"
raise sqlmapSyntaxException, errMsg
if conf.torPort is not None and not (isinstance(conf.torPort, int) and conf.torPort > 0):
errMsg = "value for --tor-port (torPort) option must be an integer value greater than zero (>0)"
raise sqlmapSyntaxException, errMsg
if conf.torType not in getPublicTypeMembers(PROXYTYPE, True):
errMsg = "switch --tor-type accepts one of following values: %s" % ", ".join(getPublicTypeMembers(PROXYTYPE, True))
raise sqlmapSyntaxException, errMsg

View File

@ -173,6 +173,7 @@ optDict = {
"replicate": "boolean",
"updateAll": "boolean",
"tor": "boolean",
"torPort": "integer",
"torType": "string",
},

View File

@ -534,6 +534,9 @@ def cmdLineParser():
action="store_true",
help="Use Tor anonymity network")
general.add_option("--tor-port", dest="torPort",
help="Set Tor proxy port other than default")
general.add_option("--tor-type", dest="torType",
help="Set Tor proxy type (HTTP - default, SOCKS4 or SOCKS5)")

View File

@ -577,6 +577,9 @@ replicate = False
# Valid: True or False
tor = False
# Set Tor proxy port other than default
torPort =
# Set Tor proxy type.
# Valid: HTTP, SOCKS4, SOCKS5
torType = HTTP