From 65c3dd486448407070e1a5e62cbc5d91db88f4db Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Thu, 17 Jun 2021 16:31:52 -0400 Subject: [PATCH] Brought interactive enabling into exception handler --- pwncat/manager.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pwncat/manager.py b/pwncat/manager.py index dc3d129..e50d7ea 100644 --- a/pwncat/manager.py +++ b/pwncat/manager.py @@ -574,9 +574,8 @@ class Manager: self.log("no active session, returning to local prompt") continue - self.target.platform.interactive = True - interactive_complete = threading.Event() + output_thread = None def output_thread_main(target: Session): @@ -597,12 +596,14 @@ class Manager: except ChannelError: interactive_complete.set() - output_thread = threading.Thread( - target=output_thread_main, args=[self.target] - ) - output_thread.start() - try: + self.target.platform.interactive = True + + output_thread = threading.Thread( + target=output_thread_main, args=[self.target] + ) + output_thread.start() + try: self.target.platform.interactive_loop(interactive_complete) except RawModeExit: @@ -615,10 +616,10 @@ class Manager: self.target.died() except Exception: pwncat.util.console.print_exception() - - # Trigger thread to exit - interactive_complete.set() - output_thread.join() + finally: + interactive_complete.set() + if output_thread is not None: + output_thread.join() def create_session(self, platform: str, channel: Channel = None, **kwargs): """