1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-20 14:39:22 +01:00

Don't delete channels when handling dead resources

Deleting the channels when they are dead prevents Metasploit from
reading their streams before closing them.
This commit is contained in:
Spencer McIntyre 2021-10-27 15:10:33 -04:00
parent d07f44ed46
commit 46ce044ab3

View File

@ -667,6 +667,7 @@ class MeterpreterProcess(MeterpreterChannel):
self.proc_h.kill()
if self.proc_h.ptyfd is not None:
os.close(self.proc_h.ptyfd)
self.proc_h.ptyfd = None
for stream in (self.proc_h.stdin, self.proc_h.stdout, self.proc_h.stderr):
if not hasattr(stream, 'close'):
continue
@ -1362,7 +1363,6 @@ class PythonMeterpreter(object):
self.send_packet(tlv_pack_request('core_channel_write', write_request_parts))
def handle_dead_resource_channel(self, channel_id):
del self.channels[channel_id]
if channel_id in self.interact_channels:
self.interact_channels.remove(channel_id)
self.send_packet(tlv_pack_request('core_channel_close', [