summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2021-09-01 05:56:31 -0400
committerdusoleil <howcansocksbereal@gmail.com>2021-09-01 05:56:31 -0400
commit72646d6f197910c2a8c424fc2e769d03d0b5a332 (patch)
tree3939dd2a5bf3648076f0f13dd62346edc8aa8710
parent9aa7f881197220fe1750c9538386ce14cdf8ae96 (diff)
downloadsploit-72646d6f197910c2a8c424fc2e769d03d0b5a332.tar.gz
sploit-72646d6f197910c2a8c424fc2e769d03d0b5a332.zip
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 <howcansocksbereal@gmail.com>
-rw-r--r--sploit/comm.py13
1 files 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')