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

fix: Fixes 'set' command usage for incorrect keys

The key wasn't being checked before accessing the value from the 'manager.config' dictionary
This commit is contained in:
Mitul16 2022-02-16 15:57:06 +05:30
parent 9d1aff43fc
commit 03456e51cb
No known key found for this signature in database
GPG Key ID: 5C5BBBE501A9BA25

View File

@ -80,9 +80,14 @@ class Command(CommandDefinition):
try: try:
if manager.sessions and args.variable == "db": if manager.sessions and args.variable == "db":
raise ValueError("cannot change database with running session") raise ValueError("cannot change database with running session")
manager.config.set( if args.variable in manager.config:
args.variable, args.value, getattr(args, "global") manager.config.set(
) args.variable, args.value, getattr(args, "global")
)
else:
console.log(
f"[red]error[/red]: invalid choice {repr(args.variable)}"
)
if args.variable == "db": if args.variable == "db":
# Ensure the database is re-opened, if it was already # Ensure the database is re-opened, if it was already
manager.open_database() manager.open_database()
@ -95,10 +100,15 @@ class Command(CommandDefinition):
except ValueError as exc: except ValueError as exc:
console.log(f"[red]error[/red]: {exc}") console.log(f"[red]error[/red]: {exc}")
elif args.variable is not None: elif args.variable is not None:
value = manager.config[args.variable] if args.variable in manager.config:
console.print( value = manager.config[args.variable]
f" [cyan]{args.variable}[/cyan] = [yellow]{repr(value)}[/yellow]" console.print(
) f" [cyan]{args.variable}[/cyan] = [yellow]{repr(value)}[/yellow]"
)
else:
console.log(
f"[red]error[/red]: invalid choice {repr(args.variable)}"
)
else: else:
for name in manager.config: for name in manager.config:
value = manager.config[name] value = manager.config[name]