From eb8e5caaca1349bc10a61b1fa58f3d9b31df7e13 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 18 Feb 2023 20:30:10 -0500 Subject: comm: Localize stdin nonblock to interact's readall In interact(), we set stdin to be nonblocking for the duration of the function. As an unexpected side-effect, this was setting stdout to be nonblocking as well. This has caused at least one crash in the past. Localizing the nonblock to just when we're reading from stdin should solve this. Signed-off-by: dusoleil --- sploit/comm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sploit/comm.py b/sploit/comm.py index 41eae60..16a8fa7 100644 --- a/sploit/comm.py +++ b/sploit/comm.py @@ -102,8 +102,12 @@ class Comm: event = select.POLLIN def readall_stdin(): - for line in stdin: - self.write(line) + try: + os.set_blocking(stdin.fileno(), False) + for line in stdin: + self.write(line) + finally: + os.set_blocking(stdin.fileno(), True) readtable = { self.back.stdin.fileno(): self.readall_nonblock, @@ -112,7 +116,6 @@ class Comm: try: ilog("<--Interact Mode-->") - os.set_blocking(stdin.fileno(), False) l = self.logonread self.logonread = True @@ -129,7 +132,6 @@ class Comm: pass finally: self.logonread = l - os.set_blocking(stdin.fileno(), True) ilog("<--Interact Mode Done-->") def popen(cmdline=''): -- cgit v1.2.3