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.

execute_function_on_target

Execute function on provided target with provided arguments.

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.

find_and_filter_plugins

escape_str

Escape non-ASCII, unicode characters and bytes to a printable form.

dissect.target.tools.utils.configure_generic_arguments(parser: argparse.ArgumentParser) None
dissect.target.tools.utils.process_generic_arguments(args: argparse.Namespace, rest: list[str]) 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.execute_function_on_target(target: dissect.target.Target, func: dissect.target.plugin.FunctionDescriptor, arguments: list[str] | None = None) tuple[str, Any, list[str]]

Execute function on provided target with provided arguments.

dissect.target.tools.utils.plugin_function_with_argparser(target_attr: dissect.target.plugin.Plugin | Callable) tuple[Callable | 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.

dissect.target.tools.utils.find_and_filter_plugins(functions: str, target: dissect.target.Target, excluded_func_paths: set[str] | None = None) Iterator[dissect.target.plugin.FunctionDescriptor]
dissect.target.tools.utils.escape_str(value: str) str

Escape non-ASCII, unicode characters and bytes to a printable form.