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
commite5b172c56c2e5d2f55de884b65ac8457dc638075 (patch)
treee8104792d993576d385f899b3315dcb0fc7a3e44
parent26b1c7a2c68d0747784cc5cebe71f835e8e24255 (diff)
downloadlib-des-gnux-e5b172c56c2e5d2f55de884b65ac8457dc638075.tar.gz
lib-des-gnux-e5b172c56c2e5d2f55de884b65ac8457dc638075.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--tools/sploit/sploit/comm.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py
index 009f193..9b68c38 100644
--- a/tools/sploit/sploit/comm.py
+++ b/tools/sploit/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()