Querying and Exporting Fundamentals with psort.py
Basic processing of super timeline data with psort.py, date filtering, and structuring readable l2tcsv reports.
The Analysis and Exporting Workshop
Sección titulada «El Taller de Análisis y Exportación»1. What is psort.py?
Sección titulada «1. ¿Qué es psort.py?»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:
- Read the tables of the
.plasodatabase file. - Filter the immense list of events based on your criteria (dates, data types, keywords, domains).
- Sort all records in a strictly chronological manner.
- 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.
2. Basic Syntax of psort.py
Sección titulada «2. Sintaxis Básica de psort.py»The general syntax of the tool is as follows:
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.
3. Use Case A: Controlled File Writing (-w)
Sección titulada «3. Casuística A: Escritura Controlada a Archivo (-w)»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 topsort.pythe absolute or relative path where we want to generate the resulting analysis file.
# COMANDO CORRECTO: Escribe el contenido estructurado directamente a un archivopsort.py -w /opt/forensics/cases/case-001/all_events_raw.txt /opt/forensics/cases/case-001/my_timeline.plaso4. Case Scenario B: Export Format Selection (-o)
Sección titulada «4. Casuística B: Selección del Format de Exportación (-o)»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
- To list all available output modules:
Key Forensic Industry Formats:
Sección titulada «Formatos Clave de la Industria Forense:»- ✔
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 injsonloptimized for direct import to the Timesketch analytical platform.
Forensic CSV Export Example:
Sección titulada «Ejemplo de Exportación a CSV Forense:»psort.py -o l2tcsv -w /opt/forensics/cases/case-001/timeline_triage_export.csv /opt/forensics/cases/case-001/my_timeline.plasoRelevant Columns in the l2tcsv Report:
Sección titulada «Columnas Relevantes del Reporte l2tcsv:»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.,REGfor registry,FILEfor file system,WEBHISTfor 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):»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.
6. Case Study D: Defining the Analyst's Time Zone (-z or --zone)
Sección titulada «6. Casuística D: Definición de la Zona Horaria del Analista (-z o --zone)»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:
# Forzar la exportación de los eventos en horario de Madridpsort.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
datetimecolumn will be converted to Europe/Madrid local time, ready for direct correlation.

