From 72646d6f197910c2a8c424fc2e769d03d0b5a332 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Wed, 1 Sep 2021 05:56:31 -0400 Subject: Add Config Toggles for Read/Write Extra Behavior logonread can enable/disable logging the result of every read flushonwrite can enable/disable automatically flushing every write Signed-off-by: dusoleil --- sploit/comm.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sploit/comm.py b/sploit/comm.py index 037516f..a0a9ebd 100644 --- a/sploit/comm.py +++ b/sploit/comm.py @@ -11,18 +11,21 @@ class Comm: def __init__(self, backend): self.back = backend + logonread = True + flushonwrite = True + def read(self, size): data = os.read(self.back.stdin.fileno(), size) if(data == b''): raise BrokenPipeError('Tried to read on broken pipe') - log(data) + if self.logonread : log(data) return data def readline(self): data = self.back.stdin.readline() if(data == b''): raise BrokenPipeError('Tried to read on broken pipe') - log(data) + if self.logonread : log(data) return data def readuntil(self, pred, /, *args, **kwargs): @@ -32,7 +35,7 @@ class Comm: data += self.back.stdin.read(1) if(pred(data)): break - log(data) + if self.logonread : log(data) return data def readlineuntil(self, pred, /, *args, **kwargs): @@ -40,7 +43,7 @@ class Comm: pred = bind(pred, *args, **kwargs) while(True): data = self.back.stdin.readline() - log(data) + if self.logonread : log(data) dataarr.append(data) if(pred(dataarr)): break @@ -48,7 +51,7 @@ class Comm: def write(self, data): self.back.stdout.write(data) - self.back.stdout.flush() + if self.flushonwrite : self.back.stdout.flush() def writeline(self, data): self.write(data + b'\n') -- cgit v1.2.3