mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-09 08:00:36 +03:00
Implementation for Issue #91
This commit is contained in:
parent
c1a14257a4
commit
4d759984b2
|
@ -876,50 +876,60 @@ def __setHTTPProxy():
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
debugMsg = "setting the HTTP proxy to pass by all HTTP requests"
|
debugMsg = "setting the %s proxy to pass by all HTTP requests" % ("SOCKS" if "socks" in conf.proxy else "HTTP")
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
__proxySplit = urlparse.urlsplit(conf.proxy)
|
proxySplit = urlparse.urlsplit(conf.proxy)
|
||||||
__hostnamePort = __proxySplit[1].split(":")
|
hostnamePort = proxySplit[1].split(":")
|
||||||
|
|
||||||
__scheme = __proxySplit[0]
|
scheme = proxySplit[0].lower()
|
||||||
__hostname = __hostnamePort[0]
|
hostname = hostnamePort[0]
|
||||||
__port = None
|
port = None
|
||||||
__proxyString = ""
|
username = None
|
||||||
|
password = None
|
||||||
|
|
||||||
if len(__hostnamePort) == 2:
|
if len(hostnamePort) == 2:
|
||||||
try:
|
try:
|
||||||
__port = int(__hostnamePort[1])
|
port = int(hostnamePort[1])
|
||||||
except:
|
except:
|
||||||
pass #drops into the next check block
|
pass #drops into the next check block
|
||||||
|
|
||||||
if not __scheme or not __hostname or not __port:
|
if not all((scheme, hostname, port)):
|
||||||
errMsg = "proxy value must be in format 'http://url:port'"
|
errMsg = "proxy value must be in format '(http|socks|socks4|socks5)://url:port'"
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
if conf.pCred:
|
if conf.pCred:
|
||||||
pCredRegExp = re.search("^(.*?):(.*?)$", conf.pCred)
|
_ = re.search("^(.*?):(.*?)$", conf.pCred)
|
||||||
|
if not _:
|
||||||
if not pCredRegExp:
|
|
||||||
errMsg = "Proxy authentication credentials "
|
errMsg = "Proxy authentication credentials "
|
||||||
errMsg += "value must be in format username:password"
|
errMsg += "value must be in format username:password"
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
else:
|
||||||
|
username = _.group(1)
|
||||||
|
password = _.group(2)
|
||||||
|
|
||||||
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
|
if "socks" in scheme:
|
||||||
__proxyString = "%s@" % conf.pCred
|
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 if "4" not in scheme else socks.PROXY_TYPE_SOCKS4, hostname, port, username=username, password=password)
|
||||||
|
socks.wrapmodule(urllib2)
|
||||||
__proxyString += "%s:%d" % (__hostname, __port)
|
|
||||||
|
|
||||||
# Workaround for http://bugs.python.org/issue1424152 (urllib/urllib2:
|
|
||||||
# HTTPS over (Squid) Proxy fails) as long as HTTP over SSL requests
|
|
||||||
# can't be tunneled over an HTTP proxy natively by Python (<= 2.5)
|
|
||||||
# urllib2 standard library
|
|
||||||
if PYVERSION >= "2.6":
|
|
||||||
proxyHandler = urllib2.ProxyHandler({"http": __proxyString, "https": __proxyString})
|
|
||||||
elif conf.scheme == "https":
|
|
||||||
proxyHandler = ProxyHTTPSHandler(__proxyString)
|
|
||||||
else:
|
else:
|
||||||
proxyHandler = urllib2.ProxyHandler({"http": __proxyString})
|
if conf.pCred:
|
||||||
|
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
|
||||||
|
proxyString = "%s@" % conf.pCred
|
||||||
|
else:
|
||||||
|
proxyString = ""
|
||||||
|
|
||||||
|
proxyString += "%s:%d" % (hostname, port)
|
||||||
|
|
||||||
|
# Workaround for http://bugs.python.org/issue1424152 (urllib/urllib2:
|
||||||
|
# HTTPS over (Squid) Proxy fails) as long as HTTP over SSL requests
|
||||||
|
# can't be tunneled over an HTTP proxy natively by Python (<= 2.5)
|
||||||
|
# urllib2 standard library
|
||||||
|
if PYVERSION >= "2.6":
|
||||||
|
proxyHandler = urllib2.ProxyHandler({"http": proxyString, "https": proxyString})
|
||||||
|
elif conf.scheme == "https":
|
||||||
|
proxyHandler = ProxyHTTPSHandler(proxyString)
|
||||||
|
else:
|
||||||
|
proxyHandler = urllib2.ProxyHandler({"http": proxyString})
|
||||||
|
|
||||||
def __setSafeUrl():
|
def __setSafeUrl():
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user