/* Hagaseca / THost9 Android RAT loader (com.hagaseca.thost9), first seen over ADB 2026-11-30. Reference sample: 30f4e1bc0cd96d4210765b18533eb0c5343f155a36b1a567132538242487d09c (APK, 41681 bytes). Rules match the packing scheme and the family's own strings, not the file hash: - Hagaseca_THost9_APK_Packed unextracted APK (zip level) - Hagaseca_Loader_Dex outer classes.dex (hgl.* loader), strings single-byte XOR with a per-string key - Hagaseca_THost9_Stage2_Dex unpacked assets/hg (th9.* stager), also memory dumps - Hagaseca_XorGzip_Dex_Blob a stored blob whose first byte K is followed by a gzip header XORed with K Tested with YARA 4.5 on 2026-11-30. */ rule Hagaseca_THost9_APK_Packed { meta: description = "Hagaseca/THost9 packed Android RAT loader APK (unextracted)" date = "2026-11-30" sha256 = "30f4e1bc0cd96d4210765b18533eb0c5343f155a36b1a567132538242487d09c" strings: $sig1 = "META-INF/HAGASECA." ascii $pkg = "com.hagaseca." wide // resources.arsc is stored uncompressed $as1 = "assets/hg" ascii $rs1 = "res/string/l" ascii $rs2 = "res/xml/as.xml" ascii $rs3 = "res/xml-v22/as.xml" ascii condition: uint32(0) == 0x04034b50 and filesize < 2MB and ( $sig1 or $pkg or ( $as1 and $rs1 and $rs2 and $rs3 ) ) and $as1 } rule Hagaseca_XorGzip_Dex_Blob { meta: description = "Stored zip member assets/hg whose first byte is a XOR key and the rest a gzip stream XORed with it (Hagaseca second-stage container)" date = "2026-11-30" strings: $lfh = { 50 4B 03 04 [4] 00 00 [16] 09 00 [2] 61 73 73 65 74 73 2F 68 67 } // stored, name "assets/hg" condition: uint32(0) == 0x04034b50 and for any i in (1..#lfh) : ( // data starts after the 30-byte header + 9-byte name + extra field (uint8(@lfh[i] + 39 + uint16(@lfh[i] + 28)) ^ uint8(@lfh[i] + 40 + uint16(@lfh[i] + 28))) == 0x1f and (uint8(@lfh[i] + 39 + uint16(@lfh[i] + 28)) ^ uint8(@lfh[i] + 41 + uint16(@lfh[i] + 28))) == 0x8b and (uint8(@lfh[i] + 39 + uint16(@lfh[i] + 28)) ^ uint8(@lfh[i] + 42 + uint16(@lfh[i] + 28))) == 0x08 ) } rule Hagaseca_Loader_Dex { meta: description = "Hagaseca first-stage dex: reflective loader that XOR+gunzips an asset and splices it into dexElements" date = "2026-11-30" dex_sha256 = "225e258f8edd5f6697dd44f16bd8c03a94a40424a44e11ce89d361b26a653d60" strings: $c1 = "Lcom/hagaseca/loader/Main;" ascii $c2 = "Lhgl/a;" ascii $x1 = "makeInMemoryDexElements" xor(0x01-0xff) $x2 = "dexElements" xor(0x01-0xff) $x3 = "/.hg.db" xor(0x01-0xff) $x4 = "dalvik.system.BaseDexClassLoader" xor(0x01-0xff) $x5 = "makePathElements" xor(0x01-0xff) $g = "Ljava/util/zip/GZIPInputStream;" ascii condition: uint32(0) == 0x0a786564 and filesize < 1MB and ( ( any of ($c*) and 2 of ($x*) ) or ( $g and 4 of ($x*) ) ) } rule Hagaseca_THost9_Stage2_Dex { meta: description = "Hagaseca/THost9 second stage (th9.* stager: keeper, accessibility shell, tc9.dex fetch over websocket)" date = "2026-11-30" dex_sha256 = "9cd3a954e807a3d596401b43e8820ca6ee76119d4dfc60afe0eaaf054e2c2ab5" strings: $p1 = "HAGASECA: GOODNIGHT" ascii $x1 = "com.hagaseca.Keeper" xor(0x01-0xff) $x2 = "com.hagaseca.Stager" xor(0x01-0xff) $x3 = "com.hagaseca.as_server" xor(0x01-0xff) $x4 = "hg_as > " xor(0x01-0xff) $x5 = "hg-token" xor(0x01-0xff) $x6 = "hg-type" xor(0x01-0xff) $x7 = "com.hagaseca.tc9.Main" xor(0x01-0xff) $x8 = "hagaseca.com" xor(0x01-0xff) $x9 = "enabled_accessibility_services" xor(0x01-0xff) $xa = "/.hg.dp" xor(0x00-0xff) $xb = "tc9.dex" xor(0x01-0xff) condition: filesize < 5MB and ( ( $p1 and 2 of ($x*) ) or 4 of ($x*) ) }