dissect.target.tools.utils#

Module Contents#

Functions#

configure_generic_arguments

process_generic_arguments

generate_argparse_for_bound_method

Generate an argparse.ArgumentParser for a bound Plugin class method

generate_argparse_for_unbound_method

Generate an argparse.ArgumentParser for an unbound Plugin class method

generate_argparse_for_plugin_class

Generate an argparse.ArgumentParser for a Plugin class

generate_argparse_for_plugin

Generate an argparse.ArgumentParser for a Plugin instance

plugin_factory

execute_function_on_target

Execute function func on provided target target with provided cli_params list.

get_target_attribute

Retrieves the function attribute from the target.

plugin_function_with_argparser

Resolves which plugin function to execute, and creates the argument parser for said plugin.

persist_execution_report

catch_sigpipe

Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows).

args_to_uri

Converts argument-style -L to URI-style.

dissect.target.tools.utils.configure_generic_arguments(args_parser: argparse.ArgumentParser) None#
dissect.target.tools.utils.process_generic_arguments(args: argparse.Namespace) None#
dissect.target.tools.utils.generate_argparse_for_bound_method(method: Callable, usage_tmpl: str | None = None) argparse.ArgumentParser#

Generate an argparse.ArgumentParser for a bound Plugin class method

dissect.target.tools.utils.generate_argparse_for_unbound_method(method: Callable, usage_tmpl: str | None = None) argparse.ArgumentParser#

Generate an argparse.ArgumentParser for an unbound Plugin class method

dissect.target.tools.utils.generate_argparse_for_plugin_class(plugin_cls: Type[dissect.target.plugin.Plugin], usage_tmpl: str | None = None) argparse.ArgumentParser#

Generate an argparse.ArgumentParser for a Plugin class

dissect.target.tools.utils.generate_argparse_for_plugin(plugin_instance: dissect.target.plugin.Plugin, usage_tmpl: str | None = None) argparse.ArgumentParser#

Generate an argparse.ArgumentParser for a Plugin instance

dissect.target.tools.utils.plugin_factory(target: dissect.target.Target, plugin: type | object, funcname: str, namespace: str | None) tuple[dissect.target.plugin.Plugin, str]#
dissect.target.tools.utils.execute_function_on_target(target: dissect.target.Target, func: dissect.target.plugin.PluginFunction, cli_params: List[str] | None = None) Tuple[str, Any, List[str]]#

Execute function func on provided target target with provided cli_params list.

dissect.target.tools.utils.get_target_attribute(target: dissect.target.Target, func: dissect.target.plugin.PluginFunction) dissect.target.plugin.Plugin | Callable#

Retrieves the function attribute from the target.

If the function does not exist yet, it will attempt to load it into the target.

Parameters:
  • target – The target we wish to run the function on.

  • func – The function to run on the target.

Returns:

The function, either plugin or a callable to execute.

Raises:

UnsupportedPluginError – When the function was incompatible with the target.

dissect.target.tools.utils.plugin_function_with_argparser(target_attr: dissect.target.plugin.Plugin | Callable) tuple[Iterator | None, argparse.ArgumentParser | None]#

Resolves which plugin function to execute, and creates the argument parser for said plugin.

dissect.target.tools.utils.persist_execution_report(output_dir: pathlib.Path, report_data: Dict, timestamp: datetime.datetime) pathlib.Path#
dissect.target.tools.utils.catch_sigpipe(func: Callable) Callable#

Catches KeyboardInterrupt and BrokenPipeError (OSError 22 on Windows).

dissect.target.tools.utils.args_to_uri(targets: list[str], loader_name: str, rest: list[str]) list[str]#

Converts argument-style -L to URI-style.

Turns:

target-query /evtxs/* -L log --log-hint="evtx" -f evtx

into:

target-query "log:///evtxs/*?hint=evtx" -f evtx

For loaders providing @arg() arguments.