mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00
fix python channel stderr output
This commit is contained in:
parent
582451f22e
commit
93496f1c3a
@ -680,10 +680,13 @@ class MeterpreterProcess(MeterpreterChannel):
|
|||||||
return self.proc_h.poll() is None
|
return self.proc_h.poll() is None
|
||||||
|
|
||||||
def read(self, length):
|
def read(self, length):
|
||||||
data = ''
|
data = bytes()
|
||||||
|
stderr_reader = self.proc_h.stderr_reader
|
||||||
stdout_reader = self.proc_h.stdout_reader
|
stdout_reader = self.proc_h.stdout_reader
|
||||||
if stdout_reader.is_read_ready():
|
if stderr_reader.is_read_ready() and length > 0:
|
||||||
data = stdout_reader.read(length)
|
data += stderr_reader.read(length)
|
||||||
|
if stdout_reader.is_read_ready() and (length - len(data)) > 0:
|
||||||
|
data += stdout_reader.read(length - len(data))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
@ -1329,9 +1332,9 @@ class PythonMeterpreter(object):
|
|||||||
if channel_id in self.interact_channels:
|
if channel_id in self.interact_channels:
|
||||||
proc_h = channel.proc_h
|
proc_h = channel.proc_h
|
||||||
if proc_h.stderr_reader.is_read_ready():
|
if proc_h.stderr_reader.is_read_ready():
|
||||||
data = proc_h.stderr_reader.read()
|
data += proc_h.stderr_reader.read()
|
||||||
elif proc_h.stdout_reader.is_read_ready():
|
if proc_h.stdout_reader.is_read_ready():
|
||||||
data = proc_h.stdout_reader.read()
|
data += proc_h.stdout_reader.read()
|
||||||
if not channel.is_alive():
|
if not channel.is_alive():
|
||||||
self.handle_dead_resource_channel(channel_id)
|
self.handle_dead_resource_channel(channel_id)
|
||||||
channel.close()
|
channel.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user