dissect.target

3.25.1 · active · verified Tue Apr 14

dissect.target is a core Python module that ties together various Dissect components, offering a programming API and command-line tools for accessing data sources within disk images or file collections (referred to as 'targets'). It is currently at version 3.25.1 and is actively maintained, with regular releases reflecting ongoing development in digital forensics and incident response tooling.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to open a target (e.g., a disk image or directory) and extract basic information such as hostname, OS version, and user accounts. It uses `Target.open()` to transparently handle various forensic image formats and then accesses attributes and methods on the `Target` object. Ensure you replace the placeholder path with an actual forensic artifact.

import os
from dissect.target import Target

# IMPORTANT: Replace "/path/to/your/forensic_image" with a real path
# to a disk image (e.g., .raw, .vmdk, .e01) or a collected directory.
# This example uses a placeholder and will raise an error if not replaced.
target_path = os.environ.get('DISSECT_TARGET_PATH', '/path/to/your/forensic_image')

try:
    # Open a target for analysis
    target = Target.open(target_path)

    # Access basic information
    print(f"Hostname: {target.hostname}")
    print(f"Operating System Version: {target.version}")

    # Iterate and print users
    print("\nUsers found:")
    for user in target.users():
        print(f"- {user.username} (RID: {user.rid})")

except FileNotFoundError:
    print(f"ERROR: Target file or directory not found at '{target_path}'.")
    print("Please ensure 'DISSECT_TARGET_PATH' environment variable is set or")
    print("replace '/path/to/your/forensic_image' with a valid path.")
except Exception as e:
    print(f"An error occurred while processing the target: {e}")

view raw JSON →