/*
   Odin by Brandefense - Monograph 27 / 30 YARA Artifact Suite
   Scope: Sanitized configuration and binary metadata strings for Hak5 Cloud C2,
          ReverseSSH/Platypus, GShellC2/BlueShell/XorekC2, and KeyPlug/Relay workbenches.
   Classification: TLP:CLEAR
*/

rule ODIN_Hak5_CloudC2_Controller_Config
{
    meta:
        author = "Odin by Brandefense"
        monograph = "27 / 30"
        classification = "TLP:CLEAR"
        use = "hunting and analyst review"
        description = "Matches Hak5 Cloud C2 server or drop-box enrollment configuration manifests"
    strings:
        $h1 = "cloudc2_edition" ascii nocase
        $h2 = "c2-community-linux" ascii nocase
        $d1 = "/api/device/" ascii
        $d2 = "device_model" ascii nocase
    condition:
        filesize < 512KB and ($h1 or $h2) and $d1 and $d2
}

rule ODIN_ReverseSSH_Platypus_Multiplexer_Manifest
{
    meta:
        author = "Odin by Brandefense"
        monograph = "27 / 30"
        classification = "TLP:CLEAR"
        use = "hunting and analyst review"
        description = "Matches ReverseSSH (:3232) and Platypus (:23590) multiplexer configs"
    strings:
        $r1 = "/rssh/ws" ascii
        $r2 = "reverse_ssh" ascii nocase
        $p1 = "X-Platypus-Auth" ascii
        $p2 = "platypus-ingress" ascii nocase
        $port1 = "3232" ascii
        $port2 = "23590" ascii
    condition:
        filesize < 512KB and (($r1 and $r2 and $port1) or ($p1 and $p2 and $port2))
}

rule ODIN_GShell_BlueShell_Xorek_Backdoor_Config
{
    meta:
        author = "Odin by Brandefense"
        monograph = "27 / 30"
        classification = "TLP:CLEAR"
        use = "hunting and analyst review"
        description = "Matches GShellC2, BlueShell, or XorekC2 controller configuration artifacts"
    strings:
        $g1 = "Gshell Server" ascii
        $g2 = "/gshell/beacon" ascii
        $b1 = "/blueshell/poll" ascii
        $b2 = "X-BlueShell-Node" ascii
        $x1 = "/xorek/register" ascii
        $x2 = "session_xor" ascii
    condition:
        filesize < 512KB and (($g1 and $g2) or ($b1 and $b2) or ($x1 and $x2))
}

rule ODIN_KeyPlug_TokenFlow_Stunnel_Relay_Config
{
    meta:
        author = "Odin by Brandefense"
        monograph = "27 / 30"
        classification = "TLP:CLEAR"
        use = "hunting and analyst review"
        description = "Matches KeyPlug wolfSSL configs and TokenFlow/OpenWrt stunnel relay manifests"
    strings:
        $k1 = "/ws/keyplug" ascii
        $k2 = "www.wolfssl.com" ascii
        $t1 = "tokenflow-linux-amd64" ascii
        $t2 = "astr-proxy.js" ascii
        $s1 = "stunnel_openwrt_config" ascii
    condition:
        filesize < 512KB and (($k1 and $k2) or ($t1 and $t2) or $s1)
}
