1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 19:04:15 +01:00

Fixed exit command

This commit is contained in:
Caleb Stewart 2020-11-13 12:16:22 -05:00
parent 9ed174f5f0
commit 67cdcb2972
4 changed files with 10 additions and 6 deletions

View File

@ -106,7 +106,7 @@ def main():
except ConnectionResetError:
pwncat.victim.restore_local_term()
console.log("[yellow]warning[/yellow]: connection reset by remote host")
except SystemExit:
except (pwncat.util.CommandSystemExit, SystemExit):
console.log("closing connection")
finally:
# Restore the shell

View File

@ -210,10 +210,7 @@ class CommandParser:
if pwncat.config.module:
self.prompt.message = [
(
"fg:ansiyellow bold",
f"({pwncat.config.module.name}) ",
),
("fg:ansiyellow bold", f"({pwncat.config.module.name}) ",),
("fg:ansimagenta bold", "pwncat"),
("", "$ "),
]
@ -233,6 +230,8 @@ class CommandParser:
# We used to catch only KeyboardException, but this prevents a
# badly written command from completely killing our remote
# connection.
except pwncat.util.CommandSystemExit:
raise
except EOFError:
# We don't have a connection yet, just exit
if pwncat.victim is None or pwncat.victim.client is None:

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import pwncat
from pwncat.util import console
from pwncat.commands.base import CommandDefinition, Complete, Parameter
@ -27,4 +28,4 @@ class Command(CommandDefinition):
return
# Get outa here!
raise EOFError
raise pwncat.util.CommandSystemExit

View File

@ -66,6 +66,10 @@ class Init(Enum):
SYSV = auto()
class CommandSystemExit(Exception):
""" A command has requested that we exit pwncat (mostly used for exit command) """
class CompilationError(Exception):
"""
Indicates that compilation failed on either the local or remote host.