erek — Python Bindings for EREK
EREK (ECMAScript Reverse Engineering Kit) is a memory-safe, zero-recursion Rust framework for inspecting, lifting, analyzing, and decompiling precompiled mobile JavaScript / TypeScript / ArkTS bytecodes (.abc and .hbc) and application packages (.hap, .hsp, .app, .apk, .ipa).
Installation
pip install erek
Quick Start
import erek
# 1. Classify raw payload bytes by wire magic (never relies on file extensions)
info = erek.classify_payload(b"PANDA\x00\x00\x00\x11\x22\x33\x44\x0c\x00\x06\x00")
# -> {'kind': 'abc', 'version': '12.0.6.0'}
# 2. Inspect a .hap / .hsp / .app archive in memory (with IEEE CRC-32 & bomb limits)
with open("entry.hap", "rb") as f:
modules = erek.extract_abc_modules(f.read())
for mod in modules:
print(mod["container_path"], mod["entry_name"], len(mod["data"]))
# 3. Decode an ArkCompiler (.abc) method instruction stream
insns = erek.decode_abc_bytecode(bytes([0x64, 0x65])) # ldundefined; returnundefined
for insn in insns:
print(f"{insn['offset']:#06x}: {insn['text']}")
Links