Hindsight

repository·main·Indexed 23 days ago

https://github.com/ryandfir/hindsight

A forensics tool for analyzing web artifacts from Google Chrome, Chromium, and Mozilla Firefox. Hindsight extracts URLs, downloads, cache, bookmarks, and cookies to correlate them into a unified timeline. It provides both a command-line interface and a web UI for processing browser profiles across Windows, Linux, OS X, iOS, Android, and CrOS.

Tokens
3.8K
Snippets
4
Records
25
Agent score
81%

What's inside Hindsight

  1. Follow the Sync Protocol Style for Protobufs

    main

    When defining or modifying protobufs within the Sync Protocol, adhere to these core guidelines to ensure consistency and compatibility:

    General Rules

    Naming and Formatting

    • Enums: Entries must be in ALL_CAPS. The first entry should always be an unspecified value: FOO_UNSPECIFIED = 0.
    • Timestamps: Must specify epoch and unit in the suffix using the format _[unix|windows]_epoch_[seconds|millis|micros|nanos].
      • Example: creation_time_unix_epoch_millis.
    • Durations: Must specify the unit as a suffix, e.g., _[minutes|seconds|millis|...].

    Compatibility and Evolution

    • Avoid Version Numbers: Do not use explicit version numbers in protobufs. Instead, write code that tests for the existence of a field to determine logic.
    • Backwards Compatibility: All changes must be fully backwards-compatible. Sync supports clients that may be several years old.
    • Field Renaming: Renaming a field within a specifics message is generally safe. Never rename fields outside of specifics.
    • Field Repurposing: Do not repurpose existing fields. Add a new field for new data and deprecate the old one.
    • Adding Fields: New fields are unrecognized by older clients and pose a risk of data loss during commits by older clients. Ensure data types follow Protection against data override by old Sync clients.
  2. Analyze Mozilla Firefox profiles

    main

    To analyze Firefox profiles, you must specify the browser type using the -b Firefox flag (or select "Firefox" in the GUI). You must point Hindsight to the profile directory (e.g., [userdir]\AppData\Roaming\Mozilla\Firefox\Profiles\<profile>).

    Hindsight parses the following files within the Firefox profile:

    • places.sqlite (history visits, bookmarks, and downloads)
    • cookies.sqlite
    • formhistory.sqlite
  3. Use the Hindsight Web UI

    main

    Hindsight provides a simple web interface for analyzing browser profiles.

    1. Start the interface by running hindsight_gui.py (or hindsight_gui.exe on Windows).
    2. Open a browser and visit http://localhost:8080.
    3. Enter the Profile Path (the location of the Chrome or Firefox profile you want to analyze).
    4. Click Run.

    Once processing is complete, you will be directed to a results page where you can save the extracted data to a spreadsheet or other formats.

  4. Install Hindsight manually

    main

    To install both the command line tool and the web interface, use pip to install pyhindsight and the required ccl_chromium_reader dependency from GitHub.

    If you want to use the "View SQLite DB in Browser" feature within the web interface, you must also run the provided installation script via curl.

    pip install pyhindsight
    pip install git+https://github.com/cclgroupltd/ccl_chromium_reader.git
    
    # Optional: For "View SQLite DB in Browser" feature
    curl -sSL https://raw.githubusercontent.com/RyanDFIR/hindsight/main/install-js.sh | sh
  5. Deprecate and Remove Protobuf Fields

    main

    When a field is no longer needed, follow these procedures based on its usage status:

    If the field is still being accessed

    Mark the field with the [deprecated = true] option. This is necessary to maintain backwards compatibility for the browser.

    If the field is no longer accessed

    1. Remove the field.
    2. Add reserved entries for both the name and the tag number to prevent reuse.

    CRITICAL NOTE: If the data type uses Protection against data override by old Sync clients, do not remove the field even if it is no longer accessed. The field must remain in the proto definition so it can be treated as supported for the purpose of trimming, preventing data from being carried forward indefinitely.

  6. Understand the return format of decode_user_data()

    main

    When calling decode_user_data(user_data_key, value, timezone), the function returns a tuple in the format (label, formatted_value, event_time):

    • label (str): A friendly subsystem name (e.g., used for the 'Type' column in reports).
    • formatted_value (str): A human-readable string representation of the data.
    • event_time (datetime.datetime | None): A timestamp extracted from the subsystem data (if available), used for the last_modified column. Returns None if no timestamp is present.

    Fallback Behavior: If no specific decoder matches the key, the function returns:

    • ('user data', <utf-8 string>, None) if the value is valid UTF-8.
    • ('user data', '<binary len=X, first 32 bytes=0x...>', None) if the value is binary/non-UTF-8.
  7. Use the Hindsight Command Line Interface

    main

    The command line version (hindsight.py or hindsight.exe) allows for automated analysis of browser artifacts.

    Example usage:

    C:\hindsight.py -i "C:\Users\Ryan\AppData\Local\Google\Chrome\User Data\Default" -o test_case
  8. Reference the Hindsight CLI options

    main

    Use the following flags when running hindsight.py or hindsight.exe:

    OptionDescription
    -i or --inputPath to the Chrome(ium) "Default" directory
    -o or --outputName of the output file (without extension)
    -f or --formatOutput format (default is XLSX, other options are SQLite and JSONL)
    -c or --cachePath to the cache directory; only needed if the directory is outside the given "input" directory. Mac systems are setup this way by default.
    -b or --browser_typeThe type of browser the input files belong to. Supported options are Chrome (default) and Firefox.
    -l or --logLocation Hindsight should log to (will append if exists)
    -h or --helpShows these options and the default Chrome data locations
    -t or --timezoneDisplay timezone for the timestamps in XLSX output
  9. Default Chrome profile paths by OS

    main

    When using the -i or --input flag, these are the standard locations for Chrome profiles:

    • WinXP: [userdir]\Local Settings\Application Data\Google\Chrome\User Data\Default
    • Vista/7/8/10: [userdir]\AppData\Local\Google\Chrome\User Data\Default
    • Linux: [userdir]/.config/google-chrome/Default
    • OS X: [userdir]/Library/Application Support/Google/Chrome/Default
    • iOS: \Applications\com.google.chrome.ios\Library\Application Support\Google\Chrome\Default
    • Android: /userdata/data/com.android.chrome/app_chrome/Default
    • CrOS: \home\user\<GUID>
  10. Decode Service Worker user data with decode_user_data()

    main

    The decode_user_data function is used to process REG_USER_DATA: records found in the Chromium Service Worker LevelDB. It dispatches the data to a specific subsystem decoder (such as Push Messaging, Background Sync, or Notifications) based on the provided user_data_key.

    If a matching subsystem decoder is found, it returns a tuple containing a subsystem label, a human-readable formatted value, and an optional event timestamp. If no decoder matches, the function falls back to a generic UTF-8 string or a hex preview of the binary data to ensure the information is not lost.

    decode_user_data(user_data_key, value, timezone)
  11. Decode DevTools Background Services events

    main

    When analyzing Chrome/Chromium artifacts, DevTools "Background services" panel events are logged under user data keys starting with devtools_background_services_. These events are stored as BackgroundServiceEvent protobufs.

    To decode these events, use the decode function. It parses the raw value and returns a tuple containing a human-readable service label, a string of event details (including event name, instance ID, origin, service worker registration ID, and metadata), and a timestamp.

    Key Format: devtools_background_services_<service_int>_<UUID>

    • <service_int>: An integer identifying the subsystem via the BackgroundService enum.
    • <UUID>: A unique identifier for the event entry.