summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2021-08-31 19:32:59 -0400
committerdusoleil <howcansocksbereal@gmail.com>2021-08-31 19:32:59 -0400
commit72b8043524620f1bb48259002d777b28680c9008 (patch)
tree70aff1ce2562a1d446fcfc5e559084f2c949dcee
parent8c231fb7b7d60ded06521023456fd303cda8c78d (diff)
downloadsploit-72b8043524620f1bb48259002d777b28680c9008.tar.gz
sploit-72b8043524620f1bb48259002d777b28680c9008.zip
Add readuntil() and readlineuntil() to Comms
Both new functions check the input for a predicate and keep reading until the predicate is true. readuntil() will consume input byte by byte and use the entire string read to check the predicate. It will then return that entire string. readlineuntil() consumes input line by line and only uses the last line to check the predicate. The line that satisfies the predicate is all that is returned. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/comm.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/sploit/comm.py b/sploit/comm.py
index 009f193..9b68c38 100644
--- a/sploit/comm.py
+++ b/sploit/comm.py
@@ -22,6 +22,20 @@ class Comm:
log(data)
return data
+ def readuntil(self,pred):
+ data = b''
+ while(not pred(data)):
+ data += self.back.stdin.read(1)
+ log(data)
+ return data
+
+ def readlineuntil(self,pred):
+ data = b''
+ while(not pred(data)):
+ data = self.back.stdin.readline()
+ log(data)
+ return data
+
def write(self, data):
self.back.stdout.write(data)
self.back.stdout.flush()