mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-05 09:14:16 +03:00
Fix timeout inconsistency in network requests
Add explicit timeout parameter to urllib.request.urlopen() calls to ensure consistent timeout behavior and prevent hanging in poor network conditions.
This commit is contained in:
parent
03be59042f
commit
ad76636313
|
|
@ -3919,7 +3919,7 @@ def getLatestRevision():
|
||||||
req = _urllib.request.Request(url="https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/lib/core/settings.py", headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
req = _urllib.request.Request(url="https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/lib/core/settings.py", headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = getUnicode(_urllib.request.urlopen(req).read())
|
content = getUnicode(_urllib.request.urlopen(req, timeout=conf.timeout).read())
|
||||||
retVal = extractRegexResult(r"VERSION\s*=\s*[\"'](?P<result>[\d.]+)", content)
|
retVal = extractRegexResult(r"VERSION\s*=\s*[\"'](?P<result>[\d.]+)", content)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -3987,7 +3987,7 @@ def createGithubIssue(errMsg, excMsg):
|
||||||
req = _urllib.request.Request(url="https://api.github.com/search/issues?q=%s" % _urllib.parse.quote("repo:sqlmapproject/sqlmap Unhandled exception (#%s)" % key), headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
req = _urllib.request.Request(url="https://api.github.com/search/issues?q=%s" % _urllib.parse.quote("repo:sqlmapproject/sqlmap Unhandled exception (#%s)" % key), headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = _urllib.request.urlopen(req).read()
|
content = _urllib.request.urlopen(req, timeout=conf.timeout).read()
|
||||||
_ = json.loads(content)
|
_ = json.loads(content)
|
||||||
duplicate = _["total_count"] > 0
|
duplicate = _["total_count"] > 0
|
||||||
closed = duplicate and _["items"][0]["state"] == "closed"
|
closed = duplicate and _["items"][0]["state"] == "closed"
|
||||||
|
|
@ -4006,7 +4006,7 @@ def createGithubIssue(errMsg, excMsg):
|
||||||
req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % token, HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % token, HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = getText(_urllib.request.urlopen(req).read())
|
content = getText(_urllib.request.urlopen(req, timeout=conf.timeout).read())
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
content = None
|
content = None
|
||||||
_excMsg = getSafeExString(ex)
|
_excMsg = getSafeExString(ex)
|
||||||
|
|
|
||||||
|
|
@ -661,7 +661,7 @@ class Connect(object):
|
||||||
|
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
||||||
|
|
||||||
conn = _urllib.request.urlopen(req)
|
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||||
|
|
||||||
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():
|
||||||
kb.authHeader = getUnicode(getRequestHeader(req, HTTP_HEADER.AUTHORIZATION))
|
kb.authHeader = getUnicode(getRequestHeader(req, HTTP_HEADER.AUTHORIZATION))
|
||||||
|
|
|
||||||
|
|
@ -750,7 +750,7 @@ def _client(url, options=None):
|
||||||
headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False)
|
headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False)
|
||||||
|
|
||||||
req = _urllib.request.Request(url, data, headers)
|
req = _urllib.request.Request(url, data, headers)
|
||||||
response = _urllib.request.urlopen(req)
|
response = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||||
text = getText(response.read())
|
text = getText(response.read())
|
||||||
except:
|
except:
|
||||||
if options:
|
if options:
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def _search(dork):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
req = _urllib.request.Request("https://www.google.com/ncr", headers=requestHeaders)
|
req = _urllib.request.Request("https://www.google.com/ncr", headers=requestHeaders)
|
||||||
conn = _urllib.request.urlopen(req)
|
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
errMsg = "unable to connect to Google ('%s')" % getSafeExString(ex)
|
errMsg = "unable to connect to Google ('%s')" % getSafeExString(ex)
|
||||||
raise SqlmapConnectionException(errMsg)
|
raise SqlmapConnectionException(errMsg)
|
||||||
|
|
@ -72,7 +72,7 @@ def _search(dork):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
req = _urllib.request.Request(url, headers=requestHeaders)
|
req = _urllib.request.Request(url, headers=requestHeaders)
|
||||||
conn = _urllib.request.urlopen(req)
|
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||||
|
|
||||||
requestMsg = "HTTP request:\nGET %s" % url
|
requestMsg = "HTTP request:\nGET %s" % url
|
||||||
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
||||||
|
|
@ -138,7 +138,7 @@ def _search(dork):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
req = _urllib.request.Request(url, data=getBytes(data), headers=requestHeaders)
|
req = _urllib.request.Request(url, data=getBytes(data), headers=requestHeaders)
|
||||||
conn = _urllib.request.urlopen(req)
|
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||||
|
|
||||||
requestMsg = "HTTP request:\nGET %s" % url
|
requestMsg = "HTTP request:\nGET %s" % url
|
||||||
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user