Skip to content

Commit 8549ca3

Browse files
committed
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
1 parent ab87581 commit 8549ca3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pwncat/commands/run.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ def run(self, manager: "pwncat.manager.Manager", args):
6868

6969
if args.module is not None:
7070
manager.config.back()
71-
except pwncat.modules.ModuleFailed as exc:
72-
if args.traceback:
73-
console.print_exception()
74-
else:
75-
console.log(f"[red]error[/red]: module failed: {exc}")
76-
return
7771
except pwncat.modules.ModuleNotFound:
7872
console.log(f"[red]error[/red]: {module_name}: not found")
7973
return
@@ -86,6 +80,12 @@ def run(self, manager: "pwncat.manager.Manager", args):
8680
except pwncat.modules.InvalidArgument as exc:
8781
console.log(f"[red]error[/red]: invalid argument: {exc}")
8882
return
83+
except pwncat.modules.ModuleFailed as exc:
84+
if args.traceback:
85+
console.print_exception()
86+
else:
87+
console.log(f"[red]error[/red]: module failed: {exc}")
88+
return
8989

9090
if isinstance(result, list):
9191
result = [r for r in result if not r.hidden]

0 commit comments

Comments
 (0)