summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2021-09-07 02:36:54 -0400
committerdusoleil <howcansocksbereal@gmail.com>2021-09-07 02:36:54 -0400
commit71ff58d57ecc0fc7560537e8527418465ace440a (patch)
tree40479842ddf3e415e2140b0a08236c3089fd0b9c
parentca1aa3ef5fd45dbd473e94ced9cac0c1894b73fa (diff)
downloadsploit-71ff58d57ecc0fc7560537e8527418465ace440a.tar.gz
sploit-71ff58d57ecc0fc7560537e8527418465ace440a.zip
Manually run garbage collection after exec
Apparently python won't run garbage collection on stuff owned by the exec context if you define a function in the exec. This can lead to random leaks, but it is most impactful in daemon mode. If the globals dictionary given to exec isn't cleaned up, there will be a random reference to comm that still exists. This holds a reference to the Pipes object which prevents it from getting cleaned up before we try to make a new one. Making a new one needs the fifos to have been cleaned up, so it relies on the fact that the old one was supposed to be cleaned up. The most straightforward and non-intrusive way I could think to fix this was to just manually run the garbage collector after exec. This is able to find the leaked references and clean it all up. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/main.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/sploit/main.py b/sploit/main.py
index f97e04e..77ef49e 100644
--- a/sploit/main.py
+++ b/sploit/main.py
@@ -1,6 +1,7 @@
import argparse
import tempfile
import traceback
+import gc
from sploit.comm import *
@@ -55,4 +56,6 @@ def runscript(script, comm):
pass
except:
traceback.print_exc()
+ finally:
+ gc.collect()
print("Script Ended Early!")