diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2021-09-07 02:34:54 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2021-09-07 02:34:54 -0400 |
commit | ca1aa3ef5fd45dbd473e94ced9cac0c1894b73fa (patch) | |
tree | f9774ae1c01e1fd8b09af16f80f2e4eab648dcf9 | |
parent | 93202f358c2aab4672a06a5dc11ac0f67bf5ff0d (diff) | |
download | sploit-ca1aa3ef5fd45dbd473e94ced9cac0c1894b73fa.tar.gz sploit-ca1aa3ef5fd45dbd473e94ced9cac0c1894b73fa.zip |
Clean up exception handling in main.py
The handling from the daemon mode code will also work in the process and
pipes cases. Putting it in a common location removes the need for the
outer try/except. It is also easier to read/maintain in general.
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/main.py | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/sploit/main.py b/sploit/main.py index 6404786..f97e04e 100644 --- a/sploit/main.py +++ b/sploit/main.py @@ -14,18 +14,15 @@ def main(): help='target program to exploit') args = parser.parse_args() - try: - if(len(args.target)>0): - if(args.daemon): - print("Target Given. Ignoring Daemon Flag...") - target(args.script, args.target) + if(len(args.target)>0): + if(args.daemon): + print("Target Given. Ignoring Daemon Flag...") + target(args.script, args.target) + else: + if(args.daemon): + daemon(args.script) else: - if(args.daemon): - daemon(args.script) - else: - pipe(args.script) - except KeyboardInterrupt: - pass + pipe(args.script) def daemon(script): print("Running in Pipe Daemon Mode...") @@ -35,12 +32,7 @@ def daemon(script): p = Pipes(tmpdir) except KeyboardInterrupt: break - try: - runscript(script, Comm(p)); - except KeyboardInterrupt: - pass - except: - traceback.print_exc() + runscript(script, Comm(p)); del p def pipe(script): @@ -52,8 +44,15 @@ def target(script, target): runscript(script, Comm(Process(target))); def runscript(script, comm): - print("Running Script...") - code = compile(open(script).read(), script, 'exec') - exec(code, {'io': comm}) - print("Script Finished!") - comm.readall() + try: + print("Running Script...") + code = compile(open(script).read(), script, 'exec') + exec(code, {'io': comm}) + print("Script Finished!") + comm.readall() + return + except KeyboardInterrupt: + pass + except: + traceback.print_exc() + print("Script Ended Early!") |