/*
   Odin by Brandefense - Monograph 58 (Operation FalsePort) YARA Suite
   4 filesize-bounded structural rules covering rogue MySQL 0xFB LOCAL INFILE listeners,
   stored rogue MySQL session logs, multi-engine JDBC property audit scripts, and
   JNDIExploit / java-chains artifacts (zero victim or vendor identifiers).
*/

rule ODIN_FalsePort_Rogue_MySQL_Local_Infile_Server
{
    meta:
        author = "Odin by Brandefense"
        monograph = "58"
        description = "Detects rogue MySQL listener scripts crafting 0xFB LOCAL INFILE file-read packets for sensitive Linux files"
        date = "2026-11-24"
    strings:
        $m1 = "@@session.auto_increment_increment" ascii nocase
        $m2 = "SHOW SESSION STATUS" ascii nocase
        $m3 = "mysql_native_password" ascii
        $p1 = "\\xfb" ascii nocase
        $p2 = "0xfb" ascii nocase
        $f1 = "/etc/passwd" ascii
        $f2 = ".git-credentials" ascii
        $f3 = ".ssh/id_" ascii
    condition:
        filesize < 512KB and ($m1 or $m2 or $m3) and ($p1 or $p2) and ($f1 or $f2 or $f3)
}

rule ODIN_FalsePort_Rogue_MySQL_Listener_Session_Log
{
    meta:
        author = "Odin by Brandefense"
        monograph = "58"
        description = "Detects rogue MySQL TCP 3306 listener logs recording inbound Connector/J handshakes and session queries"
        date = "2026-11-24"
    strings:
        $c1 = "== connect from" ascii
        $j1 = "mysql-connector-java" ascii
        $q1 = "@@session.auto_increment_increment" ascii
        $q2 = "SHOW SESSION STATUS" ascii
    condition:
        filesize < 5MB and $c1 and $j1 and ($q1 or $q2)
}

rule ODIN_FalsePort_MultiEngine_JDBC_Audit_Script
{
    meta:
        author = "Odin by Brandefense"
        monograph = "58"
        description = "Detects multi-engine JDBC connection-property audit scripts testing MySQL and PostgreSQL driver sinks"
        date = "2026-11-24"
    strings:
        $d1 = "allowLoadLocalInfile" ascii
        $d2 = "autoDeserialize" ascii
        $d3 = "queryInterceptors" ascii
        $p1 = "socketFactory" ascii
        $p2 = "authenticationPluginClassName" ascii
    condition:
        filesize < 256KB and 2 of ($d*) and ($p1 or $p2)
}

rule ODIN_FalsePort_JNDIExploit_or_JavaChains_Artifact
{
    meta:
        author = "Odin by Brandefense"
        monograph = "58"
        description = "Detects JNDIExploit or java-chains listener outputs and configuration files"
        date = "2026-11-24"
    strings:
        $t1 = "JNDIExploit" ascii
        $t2 = "java-chains" ascii
        $r1 = "ldap://" ascii
        $r2 = "rmi://" ascii
        $g1 = "TemplatesImpl" ascii
        $g2 = "BasicController" ascii
    condition:
        filesize < 2MB and ($t1 or $t2) and ($r1 or $r2) and ($g1 or $g2)
}
