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

fix: 'except' the parent class at last

We were catching 'ModuleFailed' in './pwncat/commands/run.py' first.
But there are other *child* / *derived* exception classes - ModuleNotFound, MissingArgument, ...; which were caught after their parent class.
This will simply prevent them from being ever caught as the parent class will always be matched with 'except ParentClass:' before 'except ChildClass:'

# before
(local) pwncat$ run implant.pam
[00:00:00] error: module failed: password

# after
(local) pwncat$ run implant.pam
[00:00:00] error: missing argument: password
This commit is contained in:
Mitul16 2022-02-17 12:56:42 +05:30
parent ab87581c39
commit 8549ca3694
No known key found for this signature in database
GPG Key ID: 5C5BBBE501A9BA25

View File

@ -68,12 +68,6 @@ class Command(CommandDefinition):
if args.module is not None:
manager.config.back()
except pwncat.modules.ModuleFailed as exc:
if args.traceback:
console.print_exception()
else:
console.log(f"[red]error[/red]: module failed: {exc}")
return
except pwncat.modules.ModuleNotFound:
console.log(f"[red]error[/red]: {module_name}: not found")
return
@ -86,6 +80,12 @@ class Command(CommandDefinition):
except pwncat.modules.InvalidArgument as exc:
console.log(f"[red]error[/red]: invalid argument: {exc}")
return
except pwncat.modules.ModuleFailed as exc:
if args.traceback:
console.print_exception()
else:
console.log(f"[red]error[/red]: module failed: {exc}")
return
if isinstance(result, list):
result = [r for r in result if not r.hidden]