/*
   Odin by Brandefense - Monograph 37 / 46 Structural YARA Suite
   Coverage: Host-agnostic detection of Python Chromium/Edge SQLite and DPAPI
             credential harvesters, harvested browser credential report manifests,
             and directory-listing manifests containing .git/, site-packages/ or .venv/
             and at least two distinct .ps1, .hta or .exe stager links
   Classification: TLP:CLEAR
*/

rule ODIN_Python_Chromium_Stealer_And_DPAPI_Bundle
{
    meta:
        author = "Odin by Brandefense"
        monograph = "37 / 46"
        date = "2026-11-20"
        tlp = "CLEAR"
        action = "hunt_python_chromium_credential_harvester"
        description = "Detects Python scripts or report manifests combining Chromium Login Data and Cookies SQLite references with DPAPI Local State key markers"
    strings:
        $s_login = "Login Data" ascii nocase
        $s_cookies = "Cookies" ascii nocase
        $s_state = "Local State" ascii nocase
        $k_oscrypt = "os_crypt" ascii
        $k_enckey = "encrypted_key" ascii
        $k_dpapi = "CryptUnprotectData" ascii
    condition:
        filesize < 256KB and 2 of ($s_*) and 2 of ($k_*)
}

rule ODIN_Harvested_Chromium_SQLite_And_LocalState_Manifest
{
    meta:
        author = "Odin by Brandefense"
        monograph = "37 / 46"
        date = "2026-11-20"
        tlp = "CLEAR"
        action = "hunt_harvested_browser_credential_manifest"
        description = "Detects browser credential report manifests pairing Chromium SQLite schema fields with DPAPI Local State key fields"
    strings:
        $db_pw = "password_value" ascii
        $db_ck = "encrypted_value" ascii
        $db_url = "origin_url" ascii
        $ls_os = "os_crypt" ascii
        $ls_ek = "encrypted_key" ascii
    condition:
        filesize < 256KB and 2 of ($db_*) and all of ($ls_*)
}

rule ODIN_Open_Directory_Listing_Exposing_Git_Venv_And_Stagers
{
    meta:
        author = "Odin by Brandefense"
        monograph = "37 / 46"
        date = "2026-11-20"
        tlp = "CLEAR"
        action = "hunt_open_directory_offensive_workspace"
        description = "Detects HTTP directory-listing manifests containing .git/, site-packages/ or .venv/ folders and at least two distinct .ps1, .hta or .exe stager links"
    strings:
        $dir = "Directory listing for /" ascii
        $env1 = ".git/" ascii
        $env2 = "site-packages/" ascii
        $env3 = ".venv/" ascii
        $stg1 = ".ps1\"" ascii nocase
        $stg2 = ".hta\"" ascii nocase
        $stg3 = ".exe\"" ascii nocase
    condition:
        filesize < 512KB and $dir and 1 of ($env*) and 2 of ($stg*)
}
