From 3dbb44a7568ab28e2e6502f2f75e62aba7744ded Mon Sep 17 00:00:00 2001 From: Malfurious Date: Wed, 23 Mar 2022 06:45:02 -0400 Subject: sploit: Fix units for Comm.timeout select's poll.poll() function expects its timeout argument to be in milliseconds. This is an artifact from earlier developent where we were using the higher-level 'selectors' API, which never got merged. Signed-off-by: Malfurious Signed-off-by: dusoleil --- tools/sploit/sploit/comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py index 265ab96..b373762 100644 --- a/tools/sploit/sploit/comm.py +++ b/tools/sploit/sploit/comm.py @@ -12,7 +12,7 @@ class Comm: logonwrite = False flushonwrite = True readonwrite = False - timeout = 0.25 # seconds + timeout = 250 # milliseconds def __init__(self, backend): self.back = backend -- cgit v1.2.3 From 93c6adcbc97f6cdd9b45b78b95279abb82e8a05c Mon Sep 17 00:00:00 2001 From: Malfurious Date: Wed, 23 Mar 2022 07:09:11 -0400 Subject: 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 Signed-off-by: dusoleil --- tools/sploit/sploit/comm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py index b373762..67c97bc 100644 --- a/tools/sploit/sploit/comm.py +++ b/tools/sploit/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) -- cgit v1.2.3