/*
   Odin by Brandefense - Monograph 56 (Exposed Java Workbench) YARA Suite
   4 filesize-bounded structural rules covering STOMP-over-WebSocket test scripts,
   custom LDAP/OOB callback listeners, FFmpeg Lavf HTTP callback logs, and Actuator
   heapdump/classloader parsers (zero victim, telecom, or vendor identifiers).
*/

rule ODIN_R56_STOMP_WebSocket_Probe_Script
{
    meta:
        author = "Odin by Brandefense"
        monograph = "56"
        description = "Detects Python scripts crafting raw STOMP CONNECT, SUBSCRIBE, and SEND frames over WebSockets"
        date = "2026-11-24"
    strings:
        $f1 = "CONNECT" ascii
        $f2 = "SUBSCRIBE" ascii
        $f3 = "SEND" ascii
        $w1 = "websocket" ascii nocase
        $w2 = "accept-version:1." ascii
        $w3 = "selector:" ascii
    condition:
        filesize < 128KB and $f1 and $f2 and $f3 and 2 of ($w*)
}

rule ODIN_R56_Custom_LDAP_OOB_Callback_Listener
{
    meta:
        author = "Odin by Brandefense"
        monograph = "56"
        description = "Detects lightweight Python raw-socket LDAP or HTTP out-of-band callback listeners"
        date = "2026-11-24"
    strings:
        $s1 = "socket.socket" ascii
        $s2 = "0.0.0.0" ascii
        $p1 = "1389" ascii
        $p2 = "389" ascii
        $p3 = "Lavf/" ascii
        $p4 = "User-Agent" ascii
    condition:
        filesize < 64KB and $s1 and $s2 and 2 of ($p*)
}

rule ODIN_R56_FFmpeg_Lavf_Callback_Log
{
    meta:
        author = "Odin by Brandefense"
        monograph = "56"
        description = "Detects HTTP callback listener logs containing a Lavf identifier and an HTTP request marker."
        date = "2026-11-24"
    strings:
        $l1 = "Lavf/58." ascii
        $l2 = "User-Agent:" ascii nocase
        $l3 = "ffprobe" ascii nocase
        $h1 = "GET /" ascii
    condition:
        filesize < 5MB and $l1 and $h1 and ($l2 or $l3)
}

rule ODIN_R56_Actuator_Heapdump_and_Classloader_Parser
{
    meta:
        author = "Odin by Brandefense"
        monograph = "56"
        description = "Detects scripts parsing JVM HPROF heapdumps, JMX MBeans, and Spring Boot Actuator route mappings"
        date = "2026-11-24"
    strings:
        $h1 = "heapdump" ascii nocase
        $h2 = "JAVA PROFILE 1.0" ascii
        $m1 = "ClassLoader" ascii
        $m2 = "javax.management" ascii
        $m3 = "/actuator/" ascii
    condition:
        filesize < 128KB and ($h1 or $h2) and 2 of ($m*)
}
