Add the proxy before to open the request

https://github.com/sqlmapproject/sqlmap/issues/4430
This commit is contained in:
mendickxiao 2020-11-18 09:29:11 +08:00 committed by GitHub
parent 194c911433
commit 1c02f04ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -573,6 +573,19 @@ class Connect(object):
for char in (r"\r", r"\n"): for char in (r"\r", r"\n"):
cookie.value = re.sub(r"(%s)([^ \t])" % char, r"\g<1>\t\g<2>", cookie.value) cookie.value = re.sub(r"(%s)([^ \t])" % char, r"\g<1>\t\g<2>", cookie.value)
# You need to set the proxy in the request, just conside to add the http, you can consider to add more proxy
if conf.proxy:
_ = _urllib.parse.urlsplit(conf.proxy)
hostnamePort = _.netloc.rsplit(":", 1)
hostname = hostnamePort[0]
if len(hostnamePort) == 2:
try:
port = int(hostnamePort[1])
except:
pass # drops into the next check block
proxyString = "%s:%d" % (hostname, port)
req.set_proxy(proxyString, 'http')
conn = _urllib.request.urlopen(req) conn = _urllib.request.urlopen(req)
if not kb.authHeader and getRequestHeader(req, HTTP_HEADER.AUTHORIZATION) and (conf.authType or "").lower() == AUTH_TYPE.BASIC.lower(): if not kb.authHeader and getRequestHeader(req, HTTP_HEADER.AUTHORIZATION) and (conf.authType or "").lower() == AUTH_TYPE.BASIC.lower():