1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 10:54:14 +01:00

Corrected set command to fallback to global

This commit is contained in:
Caleb Stewart 2021-01-18 00:39:06 -05:00
parent 67cdcb2972
commit 82207c9405
2 changed files with 10 additions and 11 deletions

View File

@ -9,7 +9,7 @@ class Command(CommandDefinition):
""" Set the currently used module in the config handler """
def get_module_choices(self):
yield from [module.name for module in pwncat.modules.match(".*")]
yield from [module.name for module in pwncat.modules.match("*")]
PROG = "use"
ARGS = {

View File

@ -15,8 +15,8 @@ from pwncat.modules import BaseModule
def key_type(value: str) -> bytes:
""" Converts a key name to a ansi keycode. The value can either be a single
printable character or a named key from prompt_toolkit Keys """
"""Converts a key name to a ansi keycode. The value can either be a single
printable character or a named key from prompt_toolkit Keys"""
if len(value) == 1:
return value.encode("utf-8")
if value not in ALL_KEYS:
@ -97,17 +97,16 @@ class Config:
def set(self, name: str, value: Any, glob: bool = False):
""" Set a config value """
if glob:
self.values[name]["value"] = self.values[name]["type"](value)
return
elif self.module is None or name not in self.module.ARGUMENTS:
if not glob and self.module is not None and name in self.module.ARGUMENTS:
self.locals[name] = self.module.ARGUMENTS[name].type(value)
elif name not in self.values:
raise KeyError(f"{name}: no such configuration value")
self.locals[name] = self.module.ARGUMENTS[name].type(value)
else:
self.values[name]["value"] = self.values[name]["type"](value)
def use(self, module: BaseModule):
""" Use the specified module. This clears the current
locals configuration. """
"""Use the specified module. This clears the current
locals configuration."""
self.locals = {}
self.module = module