/*
   Odin by Brandefense - Monograph 59 (PandaV7 Panels & Mobile RAT Clusters) YARA Suite
   4 filesize-bounded structural rules covering cached PandaV7 web panel HTML, sideloaded Android
   AccessibilityService/overlay abuse, DeviceAdmin boot persistence, and non-standard port C2 configs.
*/

rule ODIN_PandaV7_Web_Management_Panel_HTML
{
    meta:
        author = "Odin by Brandefense"
        monograph = "59"
        description = "Detects cached or captured PandaV7 web management panel HTML and login bundle markers"
        date = "2026-11-24"
    strings:
        $t1 = "<title>PandaV7</title>" ascii
        $p1 = "/api/" ascii
        $p2 = "password" ascii nocase
        $p3 = "token" ascii nocase
    condition:
        filesize < 2MB and $t1 and 2 of ($p*)
}

rule ODIN_Android_APK_Accessibility_and_Overlay_Abuse
{
    meta:
        author = "Odin by Brandefense"
        monograph = "59"
        description = "Detects Android manifest structures combining AccessibilityService binding, screen overlays, and SMS or install permissions"
        date = "2026-11-24"
    strings:
        $a1 = "android.permission.BIND_ACCESSIBILITY_SERVICE" ascii wide
        $o1 = "android.permission.SYSTEM_ALERT_WINDOW" ascii wide
        $s1 = "android.permission.RECEIVE_SMS" ascii wide
        $s2 = "android.permission.READ_SMS" ascii wide
        $s3 = "android.permission.REQUEST_INSTALL_PACKAGES" ascii wide
    condition:
        filesize < 50MB and $a1 and $o1 and 1 of ($s*)
}

rule ODIN_Android_RAT_DeviceAdmin_and_Boot_Persistence
{
    meta:
        author = "Odin by Brandefense"
        monograph = "59"
        description = "Detects Android manifest or DEX artifacts pairing DeviceAdminReceiver privileges with boot and foreground persistence"
        date = "2026-11-24"
    strings:
        $d1 = "android.permission.BIND_DEVICE_ADMIN" ascii wide
        $d2 = "android.app.action.DEVICE_ADMIN_ENABLED" ascii wide
        $b1 = "android.intent.action.BOOT_COMPLETED" ascii wide
        $f1 = "android.permission.FOREGROUND_SERVICE" ascii wide
    condition:
        filesize < 50MB and $d1 and $d2 and $b1 and $f1
}

rule ODIN_Android_RAT_NonStandard_Port_C2_Config
{
    meta:
        author = "Odin by Brandefense"
        monograph = "59"
        description = "Detects extracted mobile RAT DEX or configuration files pairing Android HTTP clients with TCP 3000/3002 endpoints and capture commands"
        date = "2026-11-24"
    strings:
        $rt1 = "okhttp3" ascii
        $rt2 = "Dalvik" ascii
        $pt1 = ":3000/" ascii
        $pt2 = ":3002/" ascii
        $cap1 = "accessibility" ascii nocase
        $cap2 = "keylog" ascii nocase
        $cap3 = "screencap" ascii nocase
        $cap4 = "sms_intercept" ascii nocase
    condition:
        filesize < 10MB and ($rt1 or $rt2) and 1 of ($pt*) and 2 of ($cap*)
}
