summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-12-15 21:20:44 -0500
committerMalfurious <m@lfurio.us>2021-12-17 22:19:55 -0500
commitbe1c5e41d78a8ce8053de6893d19ad100ff75adb (patch)
treea4d61acf1836747e40480f62bac4265714bb600d
parent97c48aa4badc4f56914e258f7cd989380ee2d50f (diff)
downloadsploit-be1c5e41d78a8ce8053de6893d19ad100ff75adb.tar.gz
sploit-be1c5e41d78a8ce8053de6893d19ad100ff75adb.zip
sploit: Ensure the logonread option is restored by Comm.readuntil()
This function has a momentary side-effect of switching self.logonread to False. This patch ensures its original value is always restored, even if an exception is raised. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/comm.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/sploit/comm.py b/sploit/comm.py
index 0bc8c6a..afa14e8 100644
--- a/sploit/comm.py
+++ b/sploit/comm.py
@@ -41,11 +41,13 @@ class Comm:
pred = bind(pred, *args, **kwargs)
l = self.logonread
self.logonread = False
- while(True):
- data += self.read(1)
- if(pred(data)):
- break
- self.logonread = l
+ try:
+ while(True):
+ data += self.read(1)
+ if(pred(data)):
+ break
+ finally:
+ self.logonread = l
if self.logonread : ilog(data, file=sys.stdout, color=NORMAL)
return data