/*
   Odin by Brandefense - Monograph 25 / 30 YARA Artifact Suite
   Scope: Configuration, manifest, listing and staging controller artifacts for
          FortiGate /fg100e/ staging kits, multi-arch Adaptix gopher build sets,
          modular HTTP/DNS/IAT beacon kits, and OOB IMAP / SSRF fuzzing workbenches.
   Classification: TLP:CLEAR
   Compiles in YARA-X. Test in your environment before production use.
*/

rule ODIN_FortiGate_FG100E_PostExploit_C2_Kit
{
    meta:
        author = "Odin by Brandefense"
        monograph = "25 / 30"
        classification = "TLP:CLEAR"
        category = "staging_kit"
        description = "Matches FortiGate 100E (/fg100e/) post-exploitation controller and stage manifests or listings"
    strings:
        $fg1 = "/fg100e/" ascii
        $fg2 = "c2_server.py" ascii
        $st1 = "second_stage.bin" ascii
        $st2 = "agent.js" ascii
        $lg1 = "c2_stdout.log" ascii
    condition:
        filesize < 256KB and ($fg1 or $fg2) and ($st1 or $st2 or $lg1)
}

rule ODIN_Adaptix_MultiArch_Gopher_Build_Set
{
    meta:
        author = "Odin by Brandefense"
        monograph = "25 / 30"
        classification = "TLP:CLEAR"
        category = "multiarch_staging"
        description = "Matches manifests or listings that index gopher builds for three or more OS/CPU targets"
    strings:
        $a1 = "gopher_linux_amd64" ascii
        $a2 = "gopher_linux_arm64.elf" ascii
        $a3 = "gopher_macos_amd64.macho" ascii
        $a4 = "gopher_macos_arm64.macho" ascii
        $a5 = "gopher_windows_amd64.exe" ascii
        $a6 = "gopher_windows_arm64.exe" ascii
    condition:
        filesize < 512KB and 3 of ($a*)
}

rule ODIN_Beacon_DNS_HTTP_IAT_Staging_Manifest
{
    meta:
        author = "Odin by Brandefense"
        monograph = "25 / 30"
        classification = "TLP:CLEAR"
        category = "beacon_kit"
        description = "Matches modular Windows HTTP, DNS, shellcode, and IAT-evasive beacon staging manifests next to helper scripts"
    strings:
        $b1 = "beacon_win_x64_iat.exe" ascii
        $b2 = "beacon_dns_x64.dll" ascii
        $b3 = "beacon_http_x64_shellcode.bin" ascii
        $h1 = "execws.py" ascii
        $h2 = "oob_listener.py" ascii
    condition:
        filesize < 512KB and 2 of ($b*) and 1 of ($h*)
}

rule ODIN_OOB_IMAP_Canary_and_SSRF_Fuzz_Workbench
{
    meta:
        author = "Odin by Brandefense"
        monograph = "25 / 30"
        classification = "TLP:CLEAR"
        category = "recon_callback"
        description = "Matches OOB IMAP (:10143) canary listeners and SSRF callback fuzzing workbench artifacts"
    strings:
        $o1 = "imap_canary_" ascii
        $o2 = "oob_listener_10143" ascii
        $s1 = "ssrf_srv.log" ascii
        $s2 = "/tmp/listener.py" ascii
        $s3 = "/bb/fuzz.py" ascii
        $s4 = "rsyncgrab/loop.sh" ascii
    condition:
        filesize < 1024KB and (($o1 and $o2) or (2 of ($s*)))
}
