diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2021-09-01 00:12:30 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2021-09-01 00:12:30 -0400 |
commit | 5c6a5aba81037ca276d2cf6fae53d2e9647524c4 (patch) | |
tree | d17c36fed5f68e0a3ec7b5e8e460fcb18285c9fc | |
parent | b4216a6525f1a71b785707c7c018cf55c05a159f (diff) | |
download | sploit-5c6a5aba81037ca276d2cf6fae53d2e9647524c4.tar.gz sploit-5c6a5aba81037ca276d2cf6fae53d2e9647524c4.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-- | sploit/comm.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sploit/comm.py b/sploit/comm.py index d3b1395..040ddd6 100644 --- a/sploit/comm.py +++ b/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) |