Decryption and confrontation analysis of a certain auxiliary ANP shell
AnProtector VM v2.3 shell structure restoration technology review
This article is a pure packer (Packer / VM Protect) structural analysis and unpacking research record. It only focuses on the protection mechanism itself and does not involve any business functions, countermeasures or usage methods of the protected program. All addresses and offsets are derived from static bit-level scanning and structural closure verification of samples, which are used to understand the implementation principle of the shell.
- Sample basic information
item value
File (disguised suffix)
True format ELF64 AArch64 PIE (ET_DYN, e_machine=0xB7)
Size / SHA-256 77,217,940 B / 909AEC05DA0D22F375AAF258B5885202DE3F14D7A7B259C1EC57983D4F1EF94B
Entry 0x28F6A60
Compiler clang 18.0.4 + LLD (r522817d)
Protective shell AnProtector VM v2.3 (magic 0xA73C5E19)
- Overall conclusion (read here first)
This is a multi-layered containerized protection, with approximately 20.28MB (27.5%) of the 77MB file being nested payloads. The shell itself is made of three parts:
Plain text business segment .text (16.7MB): Native ARM64 code such as authorized clients, which is not virtualized and can be decompiled directly.
.AnProtector.text (7.35MB): VM dispatcher + 3919 handler templates, clear text ARM64, self-contained, no PLT calls.
.AnProtector (179KB): 13 descriptors + 13 VM contexts (bytecode body).
Key judgment: AnProtector's VM only protects 13 authorization/permission subsystem functions, and the rest of the business code is clear text. The real names of these 13 functions are even left in .symtab by the compiler, which is the biggest information leakage point in the entire shell.
Draw 6.1 (Android ARM64 PIE container)
│
├─ .text 16,767,852 B R-X plain text ARM64 - native business code
│ └─ .symtab retains the real names of 13 VMized functions
│
├─ .AnProtector.text 7,355,856 B R-X plaintext dispatcher + handler template
├─ .AnProtector 179,600 B RW 13 Descriptors + 13 VM Contexts (bytecode)
│
└─ .rodata embeds 9 complete ELFs (all cut out, see §6)
- 13 VMized functions (.symtab directly gives the real names)
.symtab (file offset 0x4733D90, 14 entries) was not cleared by the shell. The 13-symbol st_value exactly matches each of the 13 independently measured VM native return addresses:
VM# native entry size demangle post real function
6 0x34C43F8 1588 kxnv3::Client::Impl::Initialize(std::string&)
5 0x34C4BCC 320 kxnv3::Client::Impl::StartConnectionWatchdog()
3 0x34C4DF4 276 kxnv3::Client::Impl::ConnectionWatchdogLoop()
4 0x34C5044 120 kxnv3::Client::Impl::ConnectionValid()
7 0x34C50BC 112 kxnv3::Client::Impl::Reject(Result const&)
2 0x34C512C 840 kxnv3::Client::Impl::AcceptSession(Reply const&, bool, Failure&)
1 0x34C5474 108 kxnv3::Client::Impl::HandleError(Result const&)
8 0x3511974 1848 kxnv3::detail::Verify(std::string const&, nlohmann::json const&, Config const&, std::array<unsigned char,32> const&, long, Reply&, Failure&)
9 0x3512598 2960 kxnv3::detail::VerifyTermination(json const&, Config const&, std::array<u8,32> const&, ...)
10 0x357A314 228 kxnv3::detail::ReadDeviceIdentity(Config const&, DeviceIdentity&, std::string&)
11 0x35E7A6C 716 kxnv3::detail::ConfigureServerIdentity(...)
12 0x35E7D38 1040 kxnv3::detail::VerifyServerIdentity(...)
13 0x35E8148 2008 kxnv3::detail::WriteVerifiedTls(...)
Conclusion: The scope of VM protection is concentrated on the permission subsystem of TLS client + JSON verification + device fingerprint + server certificate pinning + 32-byte signature verification, and has nothing to do with the rest of the business logic.
Additional correction: I once misread the 14×24B structure of 0x4733D90 as "13 overlay length tables", and later confirmed that it is ELF .symtab, and the st_info/st_shndx field happens to look like 0x000E0202.
- AnProtector mechanism restoration
3.1 Three-register ABI springboard
The 13 springboards are located at 0x4707B60..0x4707DD0, the step size is 0x30, and the templates are consistent:
sub sp, sp, #0x10000
str x9, [sp]
str x14, [sp, #8] ; Native return address (call_site + 0x1C)
str x15, [sp, #0x10] ; VM context (magic 0xA73C5E19)
str x16, [sp, #0x18] ; block length descriptor
adrp x16, ... ; add x16, ... ; -> .AnProtector descriptor slot
adrp x15, ... ; add x15, ... ; -> .AnProtector context
adrp x14, ... ; add x14, ... ; -> .text return address
b 0x400D864; Unified distribution entrance
0x400D864 is the flower instruction entry: b 0x4035000 is the real dispatcher, and the other two are ldr xzr + SVE garbage instructions (ld1rqb).
3.2 White-box constant decryption primitive
8 16-byte nibble fully sorted lists are stored at 0x412A000 (sorted(T)==range(16) has been verified one by one):
T0 0c05060b09000a0d030e0f0804070102
T1 050e0f080c01020d0b0406030007090a
T2 0a0307000f06010c0d0e080b04090205
T3 03060e010c0f05020a0d000b07080904
T4 03070609000508020a0e0d040b0c010f
T5 040e07000b0502010603080c0d0a090f
T6 0602080e0f070a04050b0301000c0d09
T7 0c0b010a07080005020f06090d0e0304
There are 132 adrp x9,#0x412A000 in the dispatcher (each one is decrypted inline, step size 0x200). The algorithm is:
x8 = sp + C1 ; x8 += C2 ; x8 *= C3
for i in 0..15: # 16 rounds
nib = (x8 >> 4i) & 0xF
acc |= T[k][nib] << DEST_BIT[i] # DEST_BIT = 12,40,4,32,60,24,52,16,44,8,36,0,28,56,20,48
x8 = ((acc + K) * M) mod 2^64
KeySource = SP (relevant to ASLR). A bit-level scan of all 3,905,804 instructions in .text confirmed:
There are only 13 B/BLs that fall into the protection section (i.e. the VM springboard itself);
ADRP hit protection section 0;
Of the 297,404 R_AARCH64_RELATIVE entries, 0 pointer slots are provided for 13 VM entries;
.AnProtector.text has 0 calls to PLT (completely self-contained);
The 24 init_array functions are all plain C++ static initialization and don't decrypt anything.
⇒ There is no init-period key; decryption is done lazily inside the dispatcher and the key is derived by the runtime SP.
3.3 .AnProtector.text component division
Interval size feature judgment
0x4004000–0x400E000 40KB br=243 / blr=504 / ret=314 Dispatcher Core
0x400E000–0x4650000 6.3MB 605,026 items b + 1,153 b.cond + tbz/tbnz bit test handler template (token-threaded)
0x4650000–0x4688000 220KB blr x16, mrs x17, TPIDR_EL0 handler executor
0x4688000–0x4707000 ~512KB contains 208,896B uniform random blocks, undetermined
0x4707B60–0x4707DD0 624B 13×0x30 13 springboards
Hard evidence for deduplication: 0x40 block duplication rate 75.9% (same branch sequence repeated 144 times, zero padding 2578 times); 0x100 block 41.3%; 0x400 block 95.3% Unique ⇒ Templated generated code.
0x4200000 Typical form: b #+0xC8 / tbnz w15, #0xb / tdz w14, #0xe - bit-level decoding of the original ARM64 instruction machine word.
3.4 13 VM contexts (length closure check passed)
stub descriptor slot block length context next block Δ
0 0x4707B60 0x4708000 23845 0x470A8A0 0x47105C8 −3
1 0x4707B90 0x4708320 1110 0x47105C8 0x4710A20 −2
2 0x4707BC0 0x4708640 6692 0x4710A20 0x4712448 −4
3 0x4707BF0 0x4708960 47016 0x4712448 0x471DBF0 0
4 0x4707C20 0x4708C80 3216 0x471DBF0 0x471E880 0
5 0x4707C50 0x4708FA0 1578 0x471E880 0x471EEB0 −6
6 0x4707C80 0x47092C0 3294 0x471EEB0 0x471FB90 −2
7 0x4707CB0 0x47095E0 28250 0x471FB90 0x47269F0 −6
8 0x4707CE0 0x4709900 1031 0x47269F0 0x4726DF8 −1
9 0x4707D10 0x4709C20 2584 0x4726DF8 0x4727810 0
10 0x4707D40 0x4709F40 7010 0x4727810 0x4729378 −6
11 0x4707D70 0x470A260 14036 0x4729378 0x472CA50 −4
12 0x4707DA0 0x470A580 29504 0x472CA50 0x4733D90 0
0x472CA50 + 0x7340 = 0x4733D90 is exactly the end of the .AnProtector section ⇒ descriptor u32, which is the real block length (the difference −1…−6 is tail-aligned).
Header 0x200 structure: u32 magic | u16 ver=2 | u16 sub=3 | 16B random material per function | u32 [XX]1F[YY]00 | u16 function number 1..0xC6 | u16 0x0100 | ....
Bytecode body non-cleartext ARM64: udf 8–21%, 13 blocks without ARM64 preamble; body entropy 6.29–7.41 (significantly lower than true ciphertext 7.99) ⇒ weak transformation / custom encoding.
- .rodata exact partition (33.6MB)
Interval size entropy χ² ≤16B Repeat judgment
0x6F00F0–0x7732C0 537KB 7.56 935K — C++ string pool (mbedTLS 3.x, expand 32-byte k)
0x7732C0–0x16D0000 15.6MB 7.80–8.00 2K–45K 0.006–1.3% 35 legal PNGs (RGBA/8bit, total 11.645MB)
0x131E420–0x1385xxx 443KB — — — Nested rendering library ELF
0x138A6B0–0x13E0xxx 357KB — — — Nested Auxiliary ELF
0x13E2000–0x16B8000 2.97MB 7.910 415,646 — R1: Weak transformation/heterogeneous packaging (non-standard container)
0x16BDF00–0x20B7xxx 10.4MB — — — Kernel loader ELF (contains 6 embedded modules)
0x20BA0F0–0x26260F0 5.422MB 7.99997 204 0.0003% R2: AES-CTR / ChaCha20 level stream encryption
0x26260F0–0x288E77C 2.4MB 6.62–7.42 1.5M–3.9M 1–4% Plain/Mixed
R2 hard evidence: χ²=204 (df=255, expected 255±22.6), zero percentage 0.39%=1/256, repeated 16B chunks 1/355,569 (random expected), no gzip/zstd/xz/lz4/brotli/lzma/snappy/zip headers, no 16B grouping cycles.
No 256-byte S-boxes in the entire library (16B for all scans, 0 hits) ⇒ AES goes ARMv8 Crypto extension (AESE/AESMC), or ChaCha20 (string pool expands 32-byte k as sigma constant).
- .data is the runtime decryption area (RELA disproof)
.rela.dyn = 298,478 items: RELATIVE 297,404 / ABS64 1,065 / GLOB_DAT 9.
RELATIVE = 0 entries falling into R1 / R2 / .AnProtector.text / .AnProtector ⇒ These areas do not have pointers repaired by the dynamic linker.
283,747 / 297,404 RELATIVE addends exceed the image range (> 0x4A00000), all falling in .data (only 42 of the 283,789 slots are valid) ⇒ .data is the runtime decryption product area, and the RELA table is filled with garbage addends for anti-analysis.
1,065 ABS64 all point to sym[2]=__cxa_atexit, addend is a random 64-bit ⇒ anti-analysis padding.
DT_INIT / DT_FINI / DT_FINI_ARRAY / DT_SONAME / DT_RPATH are all missing; DT_INIT_ARRAY=0x38F94A0 (24 items) has all 0s in the file and is filled in by RELA.
0 exported symbols (.dynsym 251 entries = 1 null + 250 SHN_UNDEF), no JNI_OnLoad, no main.
The compiler leaves 13 real names in .symtab - the shell's biggest information leakage point.
init_array 24 items (RELA solved):
0x038F0034 0x038F0378 0x038B7EB0 0x028F6B60 0x028F6F30 0x0291D564
0x029AAE20 0x02AD965C 0x02B124D4 0x02B53ABC 0x02B5B3FC 0x02C6FE48
0x03015B80 0x03178EB4 0x03229688 0x0329DA1C 0x03363230 0x03396928
0x033EE834 0x03643EB4 0x0366F1AC 0x036A6934 0x037EF0C8 0x03802D7C
- Nested payload cutout (9 ELFs, 20.28MB total)
.rodata embeds 9 complete ELFs, all of which have been verified for self-consistency and cut out:
File Size Description
nested_exec_016bdf00.elf 10,464,560 B kernel module loader + ARM64 instruction level emulator (including 6 .paradise_module.*)
paradise_5.10.252.ko 1,663,520 B ET_REL
paradise_5.15.202.ko 1,715,536 B ET_REL
paradise_6.1.166.ko 1,713,968 B ET_REL
paradise_6.6.127.ko 1,610,736 B ET_REL
paradise_6.12.76.ko 1,668,208 B ET_REL
paradise_6.18.32.ko 1,624,304 B ET_REL
nested_so_0131e420.so 443,024 B SONAME = libkx_sf_render_r3.so
nested_exec_0138a6b0.elf 356,592 B SELinux relabel/execmem/ptrace helper
Note: The above nested loads are only listed as part of the shell container structure, and their internal operations and countermeasures are beyond the scope of this article.
- Unpacking conclusion matrix
Layer Status Means / Description
.text 16MB business code ✅ Plain text, can be decompiled main_image_0_38F54A0.bin (raw arm64, entry 0x28F6A60)
13 VM function semantics ✅ The real name has been restored. .symtab directly gives the kxnv3::* full signature
.AnProtector.text 7MB ✅ Plain text ARM64 dispatcher + handler template, cut out
Dispatcher constant decryption primitive ✅ Complete algorithm 8 nibble tables + affine, see §3.2
13 Context structure ✅ Completely solved Header 0x200 + body, length closure check passed
9 nested ELFs ✅ All cut out 3 user mode + 6 kernel modules, 20.28MB
13 VM bytecode bodies ⚠️ Need to simulate and execute SP derived key, statically undecipherable; body entropy 6.3–7.4 description can be captured
R2 5.4MB ⚠️ Strong streaming encryption ChaCha20/AES-CTR; key runtime derivation
R1 2.97MB ⚠️ Weak transformation / heterogeneous packaging χ²=415,646
.data runtime decryption area ⚠️ 283,747 out-of-bounds RELATIVE
- Product list
Nested payloads (nested\, 9, total 20.28MB)
nested_exec_016bdf00.elf 10,464,560 B kernel loader + ARM64 emulator (including 6 .paradise_module.*)
paradise_5.10.252.ko 1,663,520 B
paradise_5.15.202.ko 1,715,536 B
paradise_6.1.166.ko 1,713,968 B
paradise_6.6.127.ko 1,610,736 B
paradise_6.12.76.ko 1,668,208 B
paradise_6.18.32.ko 1,624,304 B
nested_so_0131e420.so 443,024 B = libkx_sf_render_r3.so
nested_exec_0138a6b0.elf 356,592 B = SELinux relabel/execmem/ptrace helper
manifest.json
Master image cut out (unpacked\)
main_image_0_38F54A0.bin 59,724,960 B raw ARM64, entry 0x28F6A60
anprotector_text.bin 7,355,856 B raw ARM64, dispatcher 0x4035000
anprotector_overlay.bin 179,600 B 13 descriptors + 13 contexts
vmctx\ctx00..ctx12_*.bin 13 VM contexts (including 0x200 header)
unpack_report.txt
Tools (draw61_re\)
anprotector_unpack.py ELF survey / stub decoding / context parsing / replacement table / encrypted partition / cut out
nested_elf_carve.py Nested ELF self-consistency verification + precise cutout + manifest
ko_analyze.py paradise.ko symbol/section/string surface reduction
- Remaining executable routes (shell level)
A. Static decompilation (covers 95% of the code, can be done immediately)
analyzeHeadless <PROJ> <NAME> -import unpacked/main_image_0_38F54A0.bin \
-processor AARCH64:LE:64:v8A -loader BinaryLoader \
-loader-baseAddr 0x0 -loader-entryPoint 0x28F6A60
B. Unicorn static simulation (attack 13 VM bytecode bodies)
from unicorn import Uc, UC_ARCH_ARM64, UC_MODE_ARM, UC_HOOK_CODE, UC_HOOK_MEM_WRITE
mu = Uc(UC_ARCH_ARM64, UC_MODE_ARM)
for base, size in [(0x0,0x38F54A0),(0x38F94A0,0x1FB60),(0x391C230,0x4AF368),
(0x4004000,0x703DD0),(0x4708000,0x2BD90)]:
mu.mem_map(base, (size+0xFFF)&~0xFFF)
mu.mem_map(0x7F000000, 0x1000000) # stack (SP is the key source, fixed SP is the fixed key)
mu.reg_write(UC_ARM64_REG_SP, 0x7FFFFFF0)
PAC/BTI press mnemonic in UC_HOOK_CODE to skip: paciasp/autiasp/bti/pacia/autia
for stub in (0x4707B60,0x4707B90,0x4707BC0,0x4707BF0,0x4707C20,0x4707C50,0x4707C80,
0x4707CB0,0x4707CE0,0x4707D10,0x4707D40,0x4707D70,0x4707DA0):
mu.emu_start(stub, 0, count=50_000_000) # Dump target at area 0x4650000 br x16
Fixed SP ⇒ Key fixed ⇒ Reproducible decryption. This is the shortest path to breach the 13 VM bodies.
C. Runtime dump (get all plaintext)
Break in the handler executor area (0x4650000) and dump the decrypted x16 target.
- Unknown items (strictly label, do not exaggerate)
The encoding method of 13 VM bytecode bodies - the SP derived key has been confirmed; the specific transformation is not solved and requires §9-B simulation execution.
Algorithm and key derivation of R2 (0x20BA0F0–0x26260F0, 5.42MB) - strong flow encryption has been verified (χ²=204); bind_thread_pacga_key prompts PACGA derivation but not verification.
The exact transformation of R1 (0x13E2000–0x16B8000, 2.97MB) - weak transformation / heterogeneous packing, undetermined.
.AnProtector.text 208,896B uniformly random block of 0x46D4000–0x4707000 - undetermined.
Table of 8-byte XOR-encoded pointers for 0x4707000–0x4707B60 - structure recognized, semantics unresolved.
Table of 12 bytes/item starting from context header +0x20 - not solved, needs to be dynamically verified in conjunction with dispatcher fetch logic.
.BTF type base address ↔ .symtab's p_<hash> real name mapping - the starting alignment of the BTF type area is biased and needs to be recalculated and aligned in FUNC order.
Attached: Summary of several design features of the shell
Selective virtualization: Only 13 functions of the license verification subsystem are put into the VM, and large areas of business code are kept in plain text, reducing shell size and performance overhead.
Key-tied SP (ASLR): There is no static key, decryption is performed lazily within the dispatcher, the key is derived from the runtime stack pointer, and static cannot be decrypted directly.
Self-contained dispatcher: .AnProtector.text does not call PLT and does not rely on external imports, which facilitates overall relocation.
Anti-analysis filling: RELA table is filled with out-of-bound addend and random ABS64, and .data is disguised as decryption product area, interfering with dynamic link analysis.
Information leakage point: .symtab has not been cleared, directly exposing the real names and signatures of 13 protected functions, which is a weakness in shell protection.
please Log in or Register an account Participate in discussions, download exclusive add-ons or unlock level posts.