From 4b80ca684eea86fb9e64d6ab5ec606bb403cb4cd Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sun, 26 Feb 2023 07:08:37 -0500 Subject: Add io.last as the result of the last discrete read Signed-off-by: dusoleil --- sploit/comm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sploit/comm.py b/sploit/comm.py index 16a8fa7..e9ea53d 100644 --- a/sploit/comm.py +++ b/sploit/comm.py @@ -13,6 +13,7 @@ class Comm: flushonwrite = True readonwrite = False timeout = 250 # milliseconds + last = None # result of last discrete read def __init__(self, backend): self.back = backend @@ -28,6 +29,7 @@ class Comm: if(data == b''): raise BrokenPipeError('Tried to read on broken pipe') if self.logonread : ilog(data, file=sys.stdout, color=NORMAL) + self.last = data return data def readline(self): @@ -37,6 +39,7 @@ class Comm: if(data == b''): raise BrokenPipeError('Tried to read on broken pipe') if self.logonread : ilog(data, file=sys.stdout, color=NORMAL) + self.last = data return data def readall(self): @@ -48,6 +51,7 @@ class Comm: data += line except KeyboardInterrupt: pass + self.last = data return data def readall_nonblock(self): @@ -59,7 +63,9 @@ class Comm: while True: poll.poll(self.timeout) d = self.readall() - if len(d) == 0: return data + if len(d) == 0: + self.last = data + return data data += d finally: os.set_blocking(self.back.stdin.fileno(), True) @@ -77,6 +83,7 @@ class Comm: finally: self.logonread = l if self.logonread : ilog(data, file=sys.stdout, color=NORMAL) + self.last = data return data def readlineuntil(self, pred, /, *args, **kwargs): @@ -86,6 +93,7 @@ class Comm: dataarr.append(self.readline()) if(pred(dataarr)): break + self.last = dataarr return dataarr def write(self, data): -- cgit v1.2.3