summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-03-23 07:09:11 -0400
committerMalfurious <m@lfurio.us>2022-04-08 23:41:39 -0400
commit93c6adcbc97f6cdd9b45b78b95279abb82e8a05c (patch)
treed7feb42202bbf46e995edc000f99d88fb071857e /tools
parent3dbb44a7568ab28e2e6502f2f75e62aba7744ded (diff)
downloadlib-des-gnux-93c6adcbc97f6cdd9b45b78b95279abb82e8a05c.tar.gz
lib-des-gnux-93c6adcbc97f6cdd9b45b78b95279abb82e8a05c.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>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/comm.py8
1 files 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)