/*
   Odin by Brandefense - Monograph 63 (Blind SQL and Tunnel Staging) YARA Suite
   4 filesize-bounded structural rules covering JNDI HTTP proof callback classes,
   VShell server configuration files, Python blind-SQL/xp_cmdshell harnesses, and
   exposed VShell web UI bundles (zero victim, organization, or vendor strings).
*/

rule ODIN_R63_JNDI_HTTP_Proof_Callback_Class
{
    meta:
        author = "Odin by Brandefense"
        monograph = "63"
        description = "Detects compiled Java .class files or Java sources embedding /RCE_PROOF and /RCE_ERR HTTP callback paths"
        date = "2026-11-25"
    strings:
        $u1 = "/RCE_PROOF" ascii
        $u2 = "/RCE_ERR" ascii
        $j1 = "java/net/URL" ascii
        $j2 = "java/lang/Runtime" ascii
        $j3 = "ProcessBuilder" ascii
        $j4 = "HttpURLConnection" ascii
    condition:
        filesize < 64KB and $u1 and $u2 and 1 of ($j*)
}

rule ODIN_R63_VShell_Server_Configuration
{
    meta:
        author = "Odin by Brandefense"
        monograph = "63"
        description = "Detects staged VShell C2 server configuration files referencing TLS certificates and WebSocket listener settings"
        date = "2026-11-25"
    strings:
        $c1 = "server.pem" ascii
        $k1 = "vshell" ascii nocase
        $k2 = "plugins" ascii
        $k3 = "websocket" ascii nocase
        $k4 = "secret" ascii nocase
    condition:
        filesize < 64KB and $c1 and 2 of ($k*)
}

rule ODIN_R63_Python_BlindSQL_and_XpCmdshell_Harness
{
    meta:
        author = "Odin by Brandefense"
        monograph = "63"
        description = "Detects Python scripts orchestrating SQL Server role checks, sp_configure, and xp_cmdshell JSON capture workflows"
        date = "2026-11-25"
    strings:
        $s1 = "xp_cmdshell" ascii nocase
        $s2 = "sp_configure" ascii nocase
        $p1 = "IS_SRVROLEMEMBER" ascii nocase
        $p2 = "requests" ascii
        $p3 = "urllib" ascii
        $p4 = ".json" ascii
    condition:
        filesize < 128KB and $s1 and $s2 and 2 of ($p*)
}

rule ODIN_R63_VShell_WebUI_Bundle_Artifact
{
    meta:
        author = "Odin by Brandefense"
        monograph = "63"
        description = "Detects exposed VShell operator frontend JavaScript bundles referencing GOST tunneling and fscan plugin modules"
        date = "2026-11-25"
    strings:
        $v1 = "vshell" ascii nocase
        $m1 = "gost" ascii nocase
        $m2 = "fscan" ascii nocase
        $m3 = "socks5" ascii nocase
        $m4 = "ws://" ascii
    condition:
        filesize < 3MB and $v1 and 3 of ($m*)
}
