diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2023-02-18 20:30:10 -0500 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-02-18 20:30:10 -0500 |
commit | eb8e5caaca1349bc10a61b1fa58f3d9b31df7e13 (patch) | |
tree | 55a5ff318f8c3219d72f41a4d286acaf11c5c907 | |
parent | 1130206afaf5a4cf192c8cb3626ed475930b07bb (diff) | |
download | sploit-eb8e5caaca1349bc10a61b1fa58f3d9b31df7e13.tar.gz sploit-eb8e5caaca1349bc10a61b1fa58f3d9b31df7e13.zip |
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 <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/comm.py | 10 |
1 files 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=''): |