diff options
author | Malfurious <m@lfurio.us> | 2022-03-23 07:09:11 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2022-04-08 23:41:39 -0400 |
commit | a425bd4110a272cb889326a0b26cfb81cd67be8e (patch) | |
tree | 25847ded15b77d82a7d54d1415709b0d4d5aaa68 | |
parent | cf0ba79fdeca5c007f02c34031a8cba34423a576 (diff) | |
download | sploit-a425bd4110a272cb889326a0b26cfb81cd67be8e.tar.gz sploit-a425bd4110a272cb889326a0b26cfb81cd67be8e.zip |
sploit: Allow multiple reads in Comm.readall_nonblock()
Due to line buffering, we may often trigger a burst of data to be sent
by the target, but resolve the non-blocking read only after the first
line is received. We would like to wait just a little longer to receive
the entire burst instead.
readall_nonblock() will now reset its timeout period whenever any data
becomes readable and will not return until we go an entire period of
silence. Under normal conditions, the full duration of readall_nonblock
should barely be any longer than the defined period itself.
Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/comm.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sploit/comm.py b/sploit/comm.py index b373762..67c97bc 100644 --- a/sploit/comm.py +++ b/sploit/comm.py @@ -46,11 +46,15 @@ class Comm: def readall_nonblock(self): try: + data = b'' os.set_blocking(self.back.stdin.fileno(), False) poll = select.poll() poll.register(self.back.stdin, select.POLLIN) - poll.poll(self.timeout) - return self.readall() + while True: + poll.poll(self.timeout) + d = self.readall() + if len(d) == 0: return data + data += d finally: os.set_blocking(self.back.stdin.fileno(), True) |