Fixed some warning messages and removed commented code

This commit is contained in:
Sudipto Rakshit 2022-11-10 15:36:27 -08:00 коммит произвёл Gary
Родитель ffdcf43e9b
Коммит 055efd8dcc
6 изменённых файлов: 5 добавлений и 65 удалений

Просмотреть файл

@ -67,10 +67,6 @@ def list_attacks() -> Table:
"""
frameworks = CFState.state().get_frameworks()
#loaded_frameworks = sum([f.loaded_status for f in frameworks.values()])
#if loaded_frameworks == 0:
# CFPrint.warn("No frameworks loaded. Try 'load <framework>'.\n")
# return ""
table = Table(header_style="bold magenta")
table.add_column("Name")
table.add_column("Category")

Просмотреть файл

@ -56,7 +56,7 @@ def predict_cmd(args: argparse.Namespace) -> None:
target = CFState.state().get_active_target()
if not target:
CFPrint.warn("No active target. Try 'interact' <target>")
CFPrint.warn("No active target. Try 'set_target' <target>")
return
heading1 = "Sample Index"
# default behavior
@ -67,7 +67,7 @@ def predict_cmd(args: argparse.Namespace) -> None:
elif args.attack_result:
active_attack = CFState.state().get_active_attack()
if not active_attack:
CFPrint.warn("No active attack. Try 'use' <attack>")
CFPrint.warn("No active attack. Try 'set_attack' <attack>")
return
elif active_attack.attack_status == "complete":

Просмотреть файл

@ -1,30 +0,0 @@
# import argparse
#
# import cmd2
# from examples.terminal.core.state import CFState
# from counterfit.core.output import CFPrint
#
#
# def reload_cmd(args: argparse.Namespace) -> None:
# """Reload a Counterfit object
# """
# if args.target:
# if not CFState.state().get_active_target():
# CFPrint.warn("Not interacting with a target.")
# else:
# CFState.state().reload_target()
# CFPrint.success("Successfully reloaded target")
# elif args.commands:
# self.load_commands()
# CFPrint.success("Successfully reloaded commands")
# else:
# CFPrint.failed("Argument not recognized")
#
#
# reload_args = cmd2.Cmd2ArgumentParser()
# reload_args.add_argument(
# "-c", "--commands", action="store_true", help="Reload commands")
# reload_args.add_argument(
# "-t", "--target", action="store_true", help="Reload the active target")
# reload_args.add_argument(
# "-f", "--framework", help="Reload a framework", choices=list(CFState.state().get_frameworks().keys()))

Просмотреть файл

@ -11,7 +11,7 @@ def run_cmd(args: argparse.Namespace) -> None:
target_to_scan = CFState.state().get_active_target()
if not target_to_scan:
CFPrint.warn("Active target not set. Try 'interact <target>''")
CFPrint.warn("Active target not set. Try 'set_target <target>''")
return
active_attack = CFState.state().get_active_attack()

Просмотреть файл

@ -13,10 +13,10 @@ def save_cmd(args: argparse.Namespace) -> None:
parameters (bool): Save the parameters used for the attack.
"""
if not CFState.state().active_target:
CFPrint.warn("Not interacting with a target. Set the active target with `interact`.")
CFPrint.warn("Not interacting with a target. Set the active target with `set_target`.")
return
if not CFState.state().active_attack:
CFPrint.warn("No active attack. Set the active target with `use`.")
CFPrint.warn("No active attack. Set the active attack with `set_attack`.")
return
if not args.parameters and not args.results:
CFPrint.warn(f"Specify the --parameters or --results flag.")

Просмотреть файл

@ -44,32 +44,6 @@ class Terminal(cmd2.Cmd):
self._load_counterfit()
return stop
# def pexcept(self, msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
# """Print an exception
# Args:
# msg (Any): [description]
# end (str, optional): [description]. Defaults to '\n'.
# apply_style (bool, optional): [description]. Defaults to True.
# """
# if isinstance(msg, Exception):
# final_msg = f"EXCEPTION of type '{type(msg).__name__}' occurred with message: {msg}"
# else:
# final_msg = str(msg)
# if apply_style:
# final_msg = cmd2.ansi.style_error(final_msg)
# if not self.debug and 'debug' in self.settables:
# warning = "\n [!] To enable full traceback, run the following command: 'set debug true'"
# final_msg += cmd2.ansi.style_warning(warning)
# self.perror(final_msg, end=end, apply_style=False)
# @cmd2.with_category('Source Code Reload')
# def do_reload_terminal(self, other):
# self._load_counterfit()
def _load_counterfit(self):
if self._cmd:
self.unregister_command_set(self._cmd)