summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2021-09-01 00:12:30 -0400
committerdusoleil <howcansocksbereal@gmail.com>2021-09-01 00:12:30 -0400
commita56433c9557141fcdd7c681e818a3c8665e89e5e (patch)
tree2bcee52340965fcf8e77cef2d81520d6e59f6289
parentffad0c5afbdc7968bb8d9de7d5ec017284dee45f (diff)
downloadlib-des-gnux-a56433c9557141fcdd7c681e818a3c8665e89e5e.tar.gz
lib-des-gnux-a56433c9557141fcdd7c681e818a3c8665e89e5e.zip
Better Shutdown Process for Pipes
Handle all of the edge cases when shutting down in Pipes mode. e.g. If the pipes are broken (tried to write after the program died) If the fifos don't exist anymore (sometimes tempfile cleans them up before the destructor finishes when certain errors happen) If the object attributes for the streams and fifo paths aren't set (this can happen if the constructor didn't finish. e.g. the user cancels while waiting on a connection) Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--tools/sploit/sploit/comm.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py
index d3b1395..040ddd6 100644
--- a/tools/sploit/sploit/comm.py
+++ b/tools/sploit/sploit/comm.py
@@ -132,8 +132,11 @@ class Pipes:
print("Connected!")
def __del__(self):
- self.stdout.close()
- self.stdin.close()
- os.unlink(self.pathin)
- os.unlink(self.pathout)
+ try:
+ if getattr(self,'stdout',None) : self.stdout.close()
+ if getattr(self,'stdin',None) : self.stdin.close()
+ except BrokenPipeError:
+ pass
+ if getattr(self,'pathin',None) and os.path.exists(self.pathin) : os.unlink(self.pathin)
+ if getattr(self,'pathout',None) and os.path.exists(self.pathout) : os.unlink(self.pathout)