Ir al contenido

Querying and Exporting Fundamentals with psort.py

Basic processing of super timeline data with psort.py, date filtering, and structuring readable l2tcsv reports.

0views

psort.py (Plaso Sort) is the query, sorting, and post-extraction processing tool for the Plaso platform. Once you have generated the compressed database file .plaso (via log2timeline.py), psort.py is the tool you will use to:

  1. Read the tables of the .plaso database file.
  2. Filter the immense list of events based on your criteria (dates, data types, keywords, domains).
  3. Sort all records in a strictly chronological manner.
  4. Write the results obtained in a structured format that is easily human-readable or integrated into external tools (CSV, JSON, Timesketch).

Indirect Inspection

You should never attempt to open or read the .plaso database directly with text editors. Any query, structuring, or metadata analysis must be channeled through psort.py.


The general syntax of the tool is as follows:

Ventana de terminal
psort.py [OPCIONES_DE_SALIDA] [OPCIONES_DE_FILTRADO] <archivo.plaso>

Console Warning

By default, if no destination file writing method is specified, psort.py will output the full list of millions of events directly to the screen. In real timelines, this will cause terminal buffer saturation.


To save the data analysis to a physical text file and use it in your investigation or attach it to the forensic report:

  • -w <ARCHIVO_SALIDA> or --write <ARCHIVO_SALIDA>: Indicates to psort.py the absolute or relative path where we want to generate the resulting analysis file.
Ventana de terminal
# COMANDO CORRECTO: Escribe el contenido estructurado directamente a un archivo
psort.py -w /opt/forensics/cases/case-001/all_events_raw.txt /opt/forensics/cases/case-001/my_timeline.plaso

To structure the output file and enable processing in spreadsheets (Excel, LibreOffice) or analytical platforms:

  • -o <FORMATO> or --output_format <FORMATO>: Specifies the structure format type for the report.
    • To list all available output modules: psort.py --list-output-modules
  • ✔ l2tcsv (Log2Timeline CSV): It is the preferred export method. It generates a text document where each value is comma-separated (CSV).
  • ✔ dynamic: Ideal for running quick queries and filtering on-screen if you are performing interactive hunting tasks.
  • ✔ json: Used to integrate the forensic timeline with other Python scripts or enterprise database engines.
  • ✔ timesketch: Special format structured in jsonl optimized for direct import to the Timesketch analytical platform.
Ventana de terminal
psort.py -o l2tcsv -w /opt/forensics/cases/case-001/timeline_triage_export.csv /opt/forensics/cases/case-001/my_timeline.plaso
  • datetime: The event date and time, synchronized with the selected time zone.
  • timestamp: The timestamp in Epoch format (Unix time).
  • timestamp_desc: The most relevant column for investigation. It uniquely describes what the timestamp means (e.g., File Creation Time, Last Access Time, Web Visit Time).
  • source_short: Simplified artifact category (e.g., REG for registry, FILE for file system, WEBHIST for web).
  • parser: Exact module that has indexed the data (e.g., chrome_history, prefetch).
  • message: The technical detail contained in the event (e.g., Execution of: notepad.exe, URL: https://...).
  • filename: Full physical path where the evidence was recovered within the analyzed disk.

5. Case Study C: Date-based Triage Filtering (--date_filter)

Sección titulada «5. Casuística C: Filtrado de Triaje por Fechas (--date_filter)»

A general database contains millions of rows irrelevant to your incident response case. Limiting the temporal scope of the query accelerates incident resolution:

  • --date_filter "YYYY-MM-DD to YYYY-MM-DD": Filter to isolate an interval of full days.
  • --date_filter "YYYY-MM-DD": Exclusively isolate what occurred during the 24 hours of that date.
  • --date_filter "YYYY-MM-DD HH:MM:SS to YYYY-MM-DD HH:MM:SS": Restrict the search to a specific range of hours (high-precision triage).

Example of data filtering by hour range (Security Incident on March 15, 2026):

Sección titulada «Ejemplo de filtrado de datos por rango de horas (Incident de Seguridad el 15 de Marzo de 2026):»
Ventana de terminal
psort.py -o l2tcsv -w /opt/forensics/cases/case-001/timeline_hour_triage.csv /opt/forensics/cases/case-001/my_timeline.plaso --date_filter "2026-03-15 10:00:00 to 2026-03-15 11:00:00"

This simple step can reduce the volume of the file to be analyzed from 15 gigabytes to a CSV sheet of a few megabytes.


Plaso stores all internal metadata in a unified UTC format. The investigator usually needs to see events in the local time where the incident occurred or from their own forensic unit to cross-reference witness times or live system captures:

Ventana de terminal
# Forzar la exportación de los eventos en horario de Madrid
psort.py -z "Europe/Madrid" -o l2tcsv -w /opt/forensics/cases/case-001/timeline_local_triage.csv /opt/forensics/cases/case-001/my_timeline.plaso --date_filter "2026-03-15"
  • Result: You will obtain a CSV file where all timestamps in the datetime column will be converted to Europe/Madrid local time, ready for direct correlation.