/*
   Odin by Brandefense - Monograph 53 / 53 YARA Artifact Suite
   Operation LedgerSwarm: Structural rules for ARTEX console bundles,
   Google Cloud Storage-to-WordPress follow-up playbooks, and pax_cmd gates.
   Validation: Compiles cleanly in YARA-X; not replayed against live traffic.
   Classification: TLP:CLEAR
*/

rule ODIN_ARTEX_Console_and_Task_Bundle
{
    meta:
        author = "Odin by Brandefense"
        monograph = "53 / 53"
        classification = "TLP:CLEAR"
        description = "Matches ARTEX web console bundles combining title markers with task API routes or static icon digest"
    strings:
        $title_en = "ARTEX - Autonomous Red-Team Expert" ascii wide
        $title_zh = { e6 94 bb e9 98 b2 e5 ae 89 e5 85 a8 e8 bf 90 e8 90 a5 }
        $fav_md5 = "cd3ebd16437d6d3963592f7365dd3980" ascii nocase
        $api_tasks = "/api/v1/tasks" ascii
        $dom_root = "artex-swarm-root" ascii
    condition:
        filesize < 10MB and (
            (($title_en or $title_zh) and ($api_tasks or $dom_root or $fav_md5)) or
            ($fav_md5 and ($api_tasks or $dom_root))
        )
}

rule ODIN_GCS_WordPress_PaxCmd_Deployer_Playbook
{
    meta:
        author = "Odin by Brandefense"
        monograph = "53 / 53"
        classification = "TLP:CLEAR"
        mitre_attack = "T1078.004"
        description = "Matches Python scripts exchanging Google service-account JWTs to overwrite WordPress theme files"
    strings:
        $oa1 = "oauth2.googleapis.com/token" ascii
        $oa2 = "urn:ietf:params:oauth:grant-type:jwt-bearer" ascii
        $sc1 = "devstorage.full_control" ascii
        $up1 = "uploadType=media" ascii
        $wp1 = "wp-content/themes/" ascii
        $px1 = "pax_cmd" ascii
    condition:
        filesize < 128KB and ($oa1 or $oa2) and $sc1 and $up1 and ($wp1 or $px1)
}

rule ODIN_WordPress_PaxCmd_Injected_Theme_Gate
{
    meta:
        author = "Odin by Brandefense"
        monograph = "53 / 53"
        classification = "TLP:CLEAR"
        mitre_attack = "T1505.003"
        description = "Matches WordPress theme files containing the pax_cmd parameter gate and PHP execution fallbacks"
    strings:
        $gate = "pax_cmd" ascii
        $req = "_REQUEST" ascii
        $fn1 = "passthru" ascii
        $fn2 = "shell_exec" ascii
        $fn3 = "system" ascii
    condition:
        filesize < 256KB and $gate and $req and 2 of ($fn*)
}
