summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-12-15 22:02:07 -0500
committerMalfurious <m@lfurio.us>2021-12-17 22:20:05 -0500
commit93d36981b1ea0494e3aeb344ce2b4e43ca55991c (patch)
tree87302792c32ac488e6de489c1fedb720711f4f6b
parentdf6be3606022ce72bf543367ffd4f43f6e91c03a (diff)
downloadsploit-93d36981b1ea0494e3aeb344ce2b4e43ca55991c.tar.gz
sploit-93d36981b1ea0494e3aeb344ce2b4e43ca55991c.zip
sploit: Automatically shutdown outgoing comms after script execution
A new function, Comm.shutdown(), is added. It will close only the stdout stream of the communications backend, potentially making the termination of the target program more fluid. The name 'shutdown' is chosen to emulate shutdown(2) from the low-level socket api, which is used to close just part of a full-duplex file descriptor. This is in contrast to 'close', which I would expect to completely terminate the given object IO. comm.shutdown() is now called by main.py, after the user script returns, to ensure that the subsequent readall() doesn't get stuck because our target is blocked reading its stdin. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/comm.py3
-rw-r--r--sploit/main.py1
2 files changed, 4 insertions, 0 deletions
diff --git a/sploit/comm.py b/sploit/comm.py
index 789a77e..604045c 100644
--- a/sploit/comm.py
+++ b/sploit/comm.py
@@ -15,6 +15,9 @@ class Comm:
def __init__(self, backend):
self.back = backend
+ def shutdown(self):
+ self.back.stdout.close()
+
def read(self, size):
data = os.read(self.back.stdin.fileno(), size)
if(data == b''):
diff --git a/sploit/main.py b/sploit/main.py
index e6c9bb3..b0fe3eb 100644
--- a/sploit/main.py
+++ b/sploit/main.py
@@ -48,6 +48,7 @@ def runscript(script, comm):
code = compile(open(script).read(), script, 'exec')
exec(code, {'io': comm, 'print': elog})
ilog("Script Finished!")
+ comm.shutdown()
comm.readall()
return
except KeyboardInterrupt: