
ARM64 ELF Virtual Machine Protection System
ARM64 ELF Virtual Machine Protection System
Translate ARM64 native instructions into custom VM bytecode for function-level code protection
π¨π³ δΈζζζ‘£ β’ Features β’ Architecture β’ Quick Start β’ Usage β’ License
VMPacker is a Virtual Machine Protection (VMP) system for ARM64 (AArch64) Linux ELF binaries. It decodes target function's native ARM64 instructions into an intermediate representation, translates them into custom VM bytecode, and injects an embedded VM interpreter into the ELF file. At runtime, protected functions are executed by the VM interpreter instead of natively.
ARM64 Native Code β Decode β Translate β Custom VM Bytecode
β
Original ELF β Inject β VM Interpreter Stub
| Layer | Technique | Description |
|---|---|---|
| VM Protection | Custom ISA | Randomly mapped opcodes β reverse engineers cannot directly identify instruction semantics |
| OpcodeCryptor | Per-instruction opcode encryption | enc[pc] = op[pc] ^ (key ^ (pc * 0x9E3779B9)) |
| Bytecode Reversal | Execution order reversal | Instructions stored in reverse order; interpreter traverses backwards |
| Token Entry | 3-instruction trampoline | Original function replaced with tokenized entry, hiding actual bytecode location |
| Indirect Dispatch | Function pointer jump table | Filled at runtime on the stack, breaking IDA cross-references |
![]() |
![]() |
![]() |
| Function List | Analysis & Selection | Protection Options |
![]() |
![]() |
|
| Real-time Logs | Protection Complete |
vmp/
βββ cmd/vmpacker/ # CLI entry point
β βββ main.go # CLI argument parsing + orchestration
β βββ vm_interp.bin # Compiled VM interpreter (GCC, go:embed)
β
βββ pkg/ # Go core library
β βββ arch/arm64/ # ARM64 architecture support
β β βββ decoder.go # Table-driven instruction decoder (implements vm.Decoder)
β β βββ decode_*.go # Decode pattern tables (DP-IMM/DP-REG/Branch/LdSt)
β β βββ translator.go # ARM64 β VM bytecode translator
β β βββ tr_alu.go # ALU instruction translation
β β βββ tr_branch.go # Branch instruction translation
β β βββ tr_loadstore.go # Memory instruction translation
β β βββ tr_bitfield.go # Bitfield instruction translation
β β βββ tr_special.go # Special instructions (ADRP/ADR)
β βββ vm/ # VM ISA definitions
β β βββ types.go # Shared types + interfaces (Decoder/Translator/Packer)
β β βββ opcodes.go # 58+ VM opcode definitions (randomly mapped values)
β β βββ disasm.go # VM bytecode disassembler
β βββ binary/elf/ # ELF binary manipulation
β βββ packer.go # ELF VMP injection (PT_NOTE hijack, trampoline generation)
β βββ trampoline.go # Trampoline code generation
β
βββ stub/ # C VM interpreter (compiled to PIC flat binary)
β βββ vm_interp_clean.c # Interpreter main loop + entry points
β βββ vm_types.h # VM CPU context (vm_ctx_t)
β βββ vm_opcodes.h # C-side opcode definitions (synced with opcodes.go)
β βββ vm_decode.h # Bytecode read utilities
β βββ vm_token.h # Token encode/decode + descriptor table
β βββ vm_dispatch.h # Indirect dispatch jump table
β βββ vm_crc.h # CRC32 integrity check
β βββ vm_sections.h # Handler section scattering macros
β βββ vm_interp.lds # Linker script
β βββ vm_handlers/ # Modular instruction handlers
β βββ h_alu.h # Arithmetic/logic operations
β βββ h_mem.h # Memory access
β βββ h_branch.h # Branch/jump
β βββ h_cmp.h # Compare/conditional
β βββ h_mov.h # Data movement
β βββ h_stack.h # Stack (PUSH/POP)
β βββ h_system.h # System (SVC/MRS/BLR/BR/RET)
β
βββ vmp-gui/ # Wails GUI frontend
β βββ frontend/ # Vue 3 + Element Plus
β βββ backend/ # Go backend bindings
β
βββ build/ # Pre-compiled tools + test artifacts
The project uses an interface-driven modular architecture, making it easy to extend to new ISAs and binary formats:
// Architecture decoder interface β extensible to x86, RISC-V
type Decoder interface {
Decode(raw uint32, offset int) Instruction
InstName(op int) string
}
// Bytecode translator interface
type Translator interface {
Translate(instructions []Instruction) (*TranslateResult, error)
}
// Binary format injector interface β extensible to PE, Mach-O
type Packer interface {
Process() error
}
graph LR
A[Input ELF] --> B[Locate Target Function]
B --> C[Extract ARM64 Instructions]
C --> D[Decode ARM64]
D --> E[Translate to VM Bytecode]
E --> F[XOR Encrypt Bytecode]
F --> G[Inject VM Interpreter]
G --> H[Generate Trampoline]
H --> I[Replace Function Entry]
I --> J[Output Protected ELF]