1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-30 12:24:14 +01:00

Added bare except around entire interactive loop

This commit is contained in:
Caleb Stewart 2021-06-17 17:58:30 -04:00
parent a1499f1a38
commit a59857a2fc
2 changed files with 73 additions and 67 deletions

View File

@ -127,7 +127,7 @@ class Socket(Channel):
self._connected = False
raise ChannelClosed(self)
return data + new_data
except BlockingIOError as exc:
except BlockingIOError:
return data
except socket.error as exc:
if exc.args[0] == errno.EAGAIN or exc.args[0] == errno.EWOULDBLOCK:

View File

@ -557,6 +557,8 @@ class Manager:
while self.interactive_running:
try:
# This is it's own main loop that will continue until
# it catches a C-d sequence.
try:
@ -578,9 +580,10 @@ class Manager:
interactive_complete = threading.Event()
output_thread = None
channel_error = None
def output_thread_main(target: Session, exception_queue: queue.SimpleQueue):
def output_thread_main(
target: Session, exception_queue: queue.SimpleQueue
):
while not interactive_complete.is_set():
try:
@ -628,13 +631,16 @@ class Manager:
f"[yellow]warning[/yellow]: {self.target.platform}: connection reset"
)
self.target.died()
except Exception:
pwncat.util.console.print_exception()
finally:
interactive_complete.set()
if output_thread is not None:
output_thread.join()
output_thread.join()
except: # noqa: E722
# We don't want to die because of an uncaught exception, but
# at least let the user know something happened. This should
# probably be configurable somewhere.
pwncat.util.console.print_exception()
def create_session(self, platform: str, channel: Channel = None, **kwargs):
"""