/*
 * Odin by Brandefense - Monograph 31 / 35 Bounded YARA Structural Suite
 * Coverage: GodPotato/PrintSpoofer PE/CLR markers, Go Chisel reverse SOCKS binaries,
 *           and subagent SMB/SQLMap task runners
 * Classification: TLP:CLEAR
 */

rule ODIN_Windows_GodPotato_PrintSpoofer_Impersonation_Tool
{
    meta:
        author = "Odin by Brandefense"
        date = "2026-11-20"
        monograph = "31 / 35"
        tlp = "CLEAR"
        description = "Matches structural PE/CLR strings of GodPotato and PrintSpoofer SeImpersonatePrivilege binaries"
    strings:
        $priv = "SeImpersonatePrivilege" ascii wide
        $pipe1 = "CreateNamedPipe" ascii wide
        $pipe2 = "ImpersonateNamedPipeClient" ascii wide
        $tool1 = "GodPotato" ascii wide nocase
        $tool2 = "PrintSpoofer" ascii wide nocase
        $rpc = "ncacn_ip_tcp" ascii wide
    condition:
        uint16(0) == 0x5A4D and filesize < 256KB and $priv and ($pipe1 or $pipe2) and ($tool1 or $tool2 or $rpc)
}

rule ODIN_Go_Chisel_WebSocket_Reverse_SOCKS_Binary
{
    meta:
        author = "Odin by Brandefense"
        date = "2026-11-20"
        monograph = "31 / 35"
        tlp = "CLEAR"
        description = "Matches Go-compiled Chisel HTTP/WebSocket reverse SOCKS5 tunnel binaries"
    strings:
        $ws_proto = "chisel-v3" ascii
        $pkg = "jpillora/chisel" ascii
        $hdr = "Sec-WebSocket-Protocol" ascii
        $socks = "R:socks" ascii
    condition:
        uint16(0) == 0x5A4D and filesize < 16MB and $ws_proto and $hdr and ($pkg or $socks)
}

rule ODIN_Subagent_MultiTask_SMB_AD_And_SQLMap_Runner
{
    meta:
        author = "Odin by Brandefense"
        date = "2026-11-20"
        monograph = "31 / 35"
        tlp = "CLEAR"
        description = "Matches subagent task scripts for SMBv1 MS17-010 relays or SQLMap batch logs"
    strings:
        $smb1 = "SMB_COM_NT_TRANSACT" ascii
        $smb2 = "TRANS2_SESSION_SETUP" ascii
        $smb3 = "PeekNamedPipe" ascii
        $sqli1 = "sqlmap identified the following injection point" ascii
        $sqli2 = "back-end DBMS:" ascii
    condition:
        filesize < 2MB and ((2 of ($smb*)) or ($sqli1 and $sqli2))
}
