/*
 * ============================================================================
 * ODIN Threat Research - Report 11: Autonomous Red-Team Forks & Multi-Agent Fleets
 * YARA Ruleset: White-Label Console Bundles, Subagent Orchestrators & Polyglot Dropzones
 * Validation: Loads in YARA-X; not replayed against live samples
 * ============================================================================
 */

rule ODIN_ARTEX_Whitelabel_Console {
    meta:
        author = "ODIN Threat Research (Brandefense)"
        description = "Detects ARTEX and Korean-localized white-label web console HTML/JS bundles sharing invariant static asset hashes and swarm API routes"
        date = "2026-11-18"
        report = "Odin by Brandefense - Autonomous Red-Team Forks"
        confidence = "high"
        mitre_attack = "T1583.006"
    strings:
        $ko_ops = { ea b3 b5 ea b2 a9 c2 b7 eb b3 b4 ec 95 88 20 ec 9a b4 ec 98 81 }
        $artex_en = "ARTEX - Autonomous security assessment console" ascii wide
        $artex_en2 = "ARTEX - Autonomous Red-Team Expert" ascii wide
        $artex_zh = { e8 87 aa e4 b8 bb e6 b8 97 e9 80 8f e6 b5 8b e8 af 95 e6 8e a7 e5 88 b6 e5 8f b0 }
        $fav_md5 = "cd3ebd16437d6d3963592f7365dd3980" ascii nocase
        $api_tasks = "/api/v1/tasks" ascii
        $dom_root = "artex-swarm-root" ascii
    condition:
        filesize < 10MB and (
            (($ko_ops or $artex_en or $artex_en2 or $artex_zh) and ($api_tasks or $dom_root or $fav_md5)) or
            ($fav_md5 and ($api_tasks or $dom_root))
        )
}

rule ODIN_PentAGI_Subagent_Orchestrator_Artifact {
    meta:
        author = "ODIN Threat Research (Brandefense)"
        description = "Detects PentAGI autonomous penetration testing orchestrator configurations, GraphQL flow schemas, and Docker subagent runtime artifacts"
        date = "2026-11-18"
        report = "Odin by Brandefense - Autonomous Red-Team Forks"
        confidence = "high"
        mitre_attack = "T1609"
    strings:
        $p1 = "PentAGI" ascii wide
        $s_gql = "/api/v1/graphql" ascii
        $s_pgv = "pgvector" ascii nocase
        $s_sock = "/var/run/docker.sock" ascii
        $s_kali = "vxcontrol/kali" ascii nocase
        $s_flow = "createFlow" ascii
    condition:
        filesize < 15MB and $p1 and 2 of ($s_gql, $s_pgv, $s_sock, $s_kali, $s_flow)
}

rule ODIN_HexStrikeAI_MCP_Offensive_Tool_Server {
    meta:
        author = "ODIN Threat Research (Brandefense)"
        description = "Detects HexStrikeAI Model Context Protocol (MCP) JSON-RPC tool-execution servers wrapping offensive CLI scanners"
        date = "2026-11-18"
        report = "Odin by Brandefense - Autonomous Red-Team Forks"
        confidence = "high"
        mitre_attack = "T1059.006"
    strings:
        $hex_id = "hexstrike" ascii nocase
        $zh_portal = { e7 94 a8 e6 88 b7 e7 99 bb e5 bd 95 20 2d 20 e6 99 ba e6 b5 8b e5 b7 a5 e5 85 b7 }
        $mcp_rpc = "\"jsonrpc\"" ascii
        $mcp_call = "tools/call" ascii
        $t_nmap = "nmap" ascii nocase
        $t_nuclei = "nuclei" ascii nocase
        $t_sqlmap = "sqlmap" ascii nocase
        $t_gobuster = "gobuster" ascii nocase
        $t_ffuf = "ffuf" ascii nocase
    condition:
        filesize < 10MB and ($hex_id or $zh_portal) and ($mcp_rpc or $mcp_call) and 3 of ($t_*)
}

rule ODIN_Polyglot_Htaccess_PHP_Webshell_Dropzone {
    meta:
        author = "ODIN Threat Research (Brandefense)"
        description = "Detects Apache .htaccess MIME-override companions and PNG/JPEG polyglot PHP execution probes staged on co-hosted offensive dropzones"
        date = "2026-11-18"
        report = "Odin by Brandefense - Autonomous Red-Team Forks"
        confidence = "high"
        mitre_attack = "T1505.003"
    strings:
        $ht_addtype = "AddType" ascii nocase
        $ht_mime = "application/x-httpd-php" ascii nocase
        $ht_ext = /\.(jpg|jpeg|png|gif)/i
        $png_hdr = { 89 50 4E 47 0D 0A }
        $jpg_hdr = { FF D8 FF E0 }
        $php_open = "<?php" ascii nocase
        $php_post = "$_POST" ascii
        $php_isset = "isset(" ascii
    condition:
        filesize < 500KB and (
            ($ht_addtype and $ht_mime and $ht_ext) or
            (($png_hdr or $jpg_hdr) and $php_open and ($ht_mime or $php_post or $php_isset))
        )
}
