Brought interactive enabling into exception handler

This commit is contained in:
Caleb Stewart 2021-06-17 16:31:52 -04:00
parent af84d1a5a8
commit 65c3dd4864
1 changed files with 12 additions and 11 deletions

View File

@ -574,9 +574,8 @@ class Manager:
self.log("no active session, returning to local prompt") self.log("no active session, returning to local prompt")
continue continue
self.target.platform.interactive = True
interactive_complete = threading.Event() interactive_complete = threading.Event()
output_thread = None
def output_thread_main(target: Session): def output_thread_main(target: Session):
@ -597,12 +596,14 @@ class Manager:
except ChannelError: except ChannelError:
interactive_complete.set() interactive_complete.set()
try:
self.target.platform.interactive = True
output_thread = threading.Thread( output_thread = threading.Thread(
target=output_thread_main, args=[self.target] target=output_thread_main, args=[self.target]
) )
output_thread.start() output_thread.start()
try:
try: try:
self.target.platform.interactive_loop(interactive_complete) self.target.platform.interactive_loop(interactive_complete)
except RawModeExit: except RawModeExit:
@ -615,9 +616,9 @@ class Manager:
self.target.died() self.target.died()
except Exception: except Exception:
pwncat.util.console.print_exception() pwncat.util.console.print_exception()
finally:
# Trigger thread to exit
interactive_complete.set() interactive_complete.set()
if output_thread is not None:
output_thread.join() output_thread.join()
def create_session(self, platform: str, channel: Channel = None, **kwargs): def create_session(self, platform: str, channel: Channel = None, **kwargs):