/*
   Odin by Brandefense - Monograph 34 / 35 YARA Artifact Suite
   Scope: Three unvalidated structural hunts for Nginx GeoIP edge configuration text,
          multi-bundle PEM TLS certificate manifests, and multi-ABI Android
          Apktool build specifications.
   Classification: TLP:CLEAR
*/

rule ODIN_Cloned_Nginx_GeoIP_APK_Delivery_Config
{
    meta:
        author = "Odin by Brandefense"
        monograph = "34 / 35"
        classification = "TLP:CLEAR"
        disposition = "HUNT_CLONED_NGINX_EDGE_CONFIG"
        description = "Matches Nginx edge configuration text combining ngx_http_geoip_module.so and proxy_pass with GeoIP variables or SQL-filter regexes"
    strings:
        $geo = "ngx_http_geoip_module.so" ascii
        $var1 = "$geoip_country_code" ascii
        $var2 = "$geoip_org" ascii
        $sql1 = "select|union" ascii nocase
        $sql2 = "$query_string" ascii
        $ngx = "proxy_pass" ascii
    condition:
        filesize < 128KB and $geo and $ngx and ($var1 or $var2 or ($sql1 and $sql2))
}

rule ODIN_Cloned_Nginx_Multi_PEM_TLS_Manifest
{
    meta:
        author = "Odin by Brandefense"
        monograph = "34 / 35"
        classification = "TLP:CLEAR"
        disposition = "HUNT_PAIRED_EDGE_TLS"
        description = "Matches Nginx SSL configuration blocks declaring multiple PEM certificate and key directives"
    strings:
        $ssl1 = "ssl_certificate" ascii
        $ssl2 = "ssl_certificate_key" ascii
        $pem = ".pem" ascii
    condition:
        filesize < 64KB and #ssl1 >= 4 and #ssl2 >= 2 and $pem
}

rule ODIN_MultiABI_APK_Repack_Build_Spec
{
    meta:
        author = "Odin by Brandefense"
        monograph = "34 / 35"
        classification = "TLP:CLEAR"
        disposition = "HUNT_REPACKAGED_MULTI_ABI_APK_SPEC"
        description = "Matches Android build or Apktool specification files referencing all four NDK ABIs alongside manifest or tool entries"
    strings:
        $tool1 = "apktool" ascii nocase
        $tool2 = "AndroidManifest.xml" ascii
        $abi1 = "arm64-v8a" ascii
        $abi2 = "armeabi-v7a" ascii
        $abi3 = "x86" ascii
        $abi4 = "x86_64" ascii
    condition:
        filesize < 512KB and ($tool1 or $tool2) and $abi1 and $abi2 and $abi3 and $abi4
}
