:py:mod:`dissect.target` ======================== .. py:module:: dissect.target Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 containers/index.rst filesystems/index.rst helpers/index.rst loaders/index.rst plugins/index.rst tools/index.rst volumes/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 container/index.rst exceptions/index.rst filesystem/index.rst loader/index.rst plugin/index.rst report/index.rst target/index.rst volume/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.Target .. py:class:: Target(path: Union[str, pathlib.Path] = None) The class that represents the target that you are talking to. Targets are the glue that connects the different ``Containers``, ``Loaders``, ``Volumes`` and ``Filesystems`` together. ``Loaders`` are used to map the ``Containers``, ``Volumes`` and ``Filesystems`` of the target onto the ``Target`` object. The plugins of dissect.target get mapped onto the ``Target`` too. They become available as attributes on a ``Target`` object. For example, ``t.hostname``, ``t.evtx()``. By executing the plugin function with a target, it will perform the function on itself. :param path: The path of a target. .. py:property:: name :type: str Return a name for this target. The function is guaranteed to give back some name. The name will be guaranteed to not have slashes, backslashes and spaces. The name won't be guaranteed to be unique. :returns: The name of a target. .. py:method:: set_event_callback(*, event_type: Optional[Event] = None, event_callback: Callable) -> None :classmethod: Sets ``event_callbacks`` on a Target class. ``event_callbacks`` get used to handle specific events denoted by :class:`Event`. This records events related to the target, such as: - a plugin gets registered to the target - a plugin is incompatible with the target - a function succeededs in its execution - a function fails in execution .. py:method:: send_event(event_type: Event, **kwargs) -> None Notify event callbacks for the given ``event_type``. Each event can have multiple callback methods, it calls all the callbacks that fit the corresponding event type. ``None`` is a catch-all method for event callbacks that always get called. :param event_type: The type of event .. py:method:: apply() -> None Resolve all disks, volumes and filesystems and load an operating system on the current ``Target``. .. py:method:: open(path: Union[str, pathlib.Path]) -> Target :classmethod: Try to find a suitable loader for the given path and load a ``Target`` from it. :param path: Path to load the ``Target`` from. :returns: A Target with a linked :class:`~dissect.target.loader.Loader` object. .. py:method:: open_raw(path: Union[str, pathlib.Path]) -> Target :classmethod: Open a Target with the given path using the :class:`~dissect.target.loaders.raw.RawLoader`. :param path: Path to load the Target from. .. py:method:: open_all(paths: list[Union[str, pathlib.Path]], include_children: bool = False) -> Iterator[Target] :classmethod: Yield targets from a list of paths. If the path is a directory, iterate files one directory deep. :param paths: A list of paths to load ``Targets`` from. :raises TargetError: Raised when not a single ``Target`` can be loaded. .. py:method:: open_child(child: Union[str, pathlib.Path]) -> Target Open a child target. :param child: The location of a target within the current ``Target``. :returns: An opened ``Target`` object of the child target. .. py:method:: open_children(recursive: bool = False) -> Iterator[Target] Open all the child targets on a ``Target``. Will open all discovered child targets if the current ``Target`` has them, such as VMs on a hypervisor. :param recursive: Whether to check the child ``Target`` for more ``Targets``. :returns: An iterator of ``Targets``. .. py:method:: list_children() -> Iterator[dissect.target.helpers.record.ChildTargetRecord] Lists all child targets that compatible :class:`~dissect.target.plugin.ChildTargetPlugin` classes can discover. .. py:method:: add_plugin(plugin_cls: Union[dissect.target.plugin.Plugin, type[dissect.target.plugin.Plugin]], check_compatible: bool = True) -> dissect.target.plugin.Plugin Add and register a plugin by class. :param plugin_cls: The plugin to add and register, this can either be a class or instance. When this is a class, it will be instantiated. :param check_compatible: A flag that determines if we check whether the plugin is compatible with the ``Target``. :returns: The ``plugin_cls`` instance. :raises UnsupportedPluginError: Raised when plugins were found, but they were incompatible :raises PluginError: Raised when any other exception occurs while trying to load the plugin. .. py:method:: get_function(function: str) -> FunctionTuple Attempt to get a given function. If the function is not already registered, look for plugins that export the function and register them. :param function: Function name to look for. :returns: A tuple of the plugin and the corresponding function. :raises UnsupportedPluginError: Raised when plugins were found, but they were incompatible :raises PluginError: Raised when any other exception occurs while trying to load the plugin. .. py:method:: has_function(function: str) -> bool Return whether this Target supports a given function. :param function: The function name to look for. :returns: ``True`` if the function can be found, ``False`` otherwise. .. py:method:: __getattr__(attr: str) -> Union[dissect.target.plugin.Plugin, Any] Override of the default __getattr__ so plugins and functions can be called from a ``Target`` object. .. py:method:: __dir__() Override the default __dir__ to provide autocomplete for things like IPython. .. py:method:: __repr__() Return repr(self).