summaryrefslogtreecommitdiffstats
path: root/tools
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
commit76e068420455a067d22ef2d4a45d65e2875e58b6 (patch)
treea07690944ca3c5562d4756d1ac17d280278e5479 /tools
parentc7603c3cd00c565d67b6ee08510720934b34ca2e (diff)
downloadlib-des-gnux-76e068420455a067d22ef2d4a45d65e2875e58b6.tar.gz
lib-des-gnux-76e068420455a067d22ef2d4a45d65e2875e58b6.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>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/comm.py3
-rw-r--r--tools/sploit/sploit/main.py1
2 files changed, 4 insertions, 0 deletions
diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py
index 789a77e..604045c 100644
--- a/tools/sploit/sploit/comm.py
+++ b/tools/sploit/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/tools/sploit/sploit/main.py b/tools/sploit/sploit/main.py
index e6c9bb3..b0fe3eb 100644
--- a/tools/sploit/sploit/main.py
+++ b/tools/sploit/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: