Compare commits

..
4 Commits
Author SHA1 Message Date
root 93ec493d02 Absorb game-reserve's Unity/Lua and AssetBundle reverse engineering
Adds references/unity-lua-and-assetbundles.md: Unity + Lua containers, the Lua 5.1
header-byte tamper, the loader's bytecode-only check, the CRC manifest the game
actually reads, UnityFS partial-encryption windows, rebuild traps (layout loss,
dependency null, compressed == raw), TextAsset read-back, and half-encrypted Mono
assemblies behind a publisher shell.

Extends framework-runtimes with LayaAir Conch (DCC checksum and loader patch),
recon with resource completeness and the encryption map, repack-and-sign with
package rename, split-apk with the narrow apktool merge, dex-patching with
call-deletion instead of method rewrite, and packers with PairIP as a
target-selection signal. Adds pitfalls P51-P53 and two symptom rows.

Registration: one reference row, two capability rows (both partial/unverified),
two evidence-summary rows, two route-inventory rows, two coverage bullets, one
known-limitation bullet, and EXTENSION-game-reserve-2026-11.md. Gates and pytest
green.
2026-11-09 20:35:44 +08:00
root 90d9bd3e57 Audit the ref drop folder a third time, and measure what it can measure
ref/ still held the sixteen write-ups absorbed on 2026-10-24, with unchanged mtimes, so this pass
re-read them instead of re-absorbing. Nine generalisable mechanisms were still missing: Pyarmor's
outer container layer and its three nonce scopes (plus the live dump being structurally incomplete),
fixed-width arithmetic in the 12-byte key VM, Python compiled to native extensions, the rebuilt
libil2cpp ELF fingerprint (JNI_OnLoad / own DT_INIT / SHT_LOUSER), a container VM's block schedule,
driving String::NewLen over every literal index as an oracle, VMs that live in the managed layer,
array literals materialised by InitializeArray instead of .rodata, framework crypto primitives as
the hook target, a comparison gate as a prefix oracle, and the debugger's own stop policy
(SIGPWR/SIGXCPU suspend-to-crash, one database per activity).

One absorbed claim was wrong and is corrected: python-bytecode-recovery section 5 said an unset
nonce[15] decrypts the first block plausibly and then diverges. Counter mode has no such state --
the same nonce differing in that one byte changes the keystream from block 0, measured at 16/16
bytes.

verify_ref_claims_10c.py carries the three device-free checks. Its first draft was decorative -- the
comparison check counted work inside the loop it was measuring -- so the comparators are now
compiled at -O2, every check has a negative control that must come out empty, and the verdict
travels as a return value rather than through a global list. tests/unit/test_verify_ref_claims_10c.py
injects the wrong claim into each check and requires the failure.

Registration: two capability rows (il2cpp-managed-layer-bytecode-vm unverified,
comparison-cost-oracle observed for the host half), two evidence-summary rows, one new and three
extended route-inventory rows, three coverage bullets. SKILL.md and routing.md unchanged; the record
is EXTENSION-ref-absorption-2026-10c.md. Gates and pytest green (796 passed).
2026-10-27 00:33:49 +08:00
root 068280a180 Verify the absorbed claims on the host and label them per claim
Adds docs/tool-verification/fixtures/verify_absorbed_claims.py: seven device-free checks covering the mask identity, the PKCS#7 length law, zero-fill versus skipped offsets, the hidden-salt search, compression drift, Python percent-encoding, and AES CTR/CBC/ECB separation.

The AES run falsified an absorbed claim: zero prefix-XOR does not imply a stream cipher (CBC and ECB show it too). The discriminator is a one-byte flip -- 1 changed byte for CTR, all following blocks for CBC, one block for ECB -- and protocol-reverse section 7 now states that, with the capability row recording the correction.

Labels are now per claim rather than per section: observed where a host command produced output, inferred for rules derived from the mechanisms, unverified for anything needing a device, a JDK, a lz4 binding or a VM sample. native-vm-recovery's claim-strength paragraph is aligned with the repository definition, and the cipher row moves to inferred.

Gates and pytest green.
2026-10-25 12:19:37 +08:00
root 45ba13c0f3 Absorb three write-ups on dump timing, native VM devirtualization and encrypted bodies
vm1: dump window at android_dlopen_ext entry, raw-syscall reader, zero-filled holes; predicate-first patching with tiered ordering; module-filtered signal attribution.

vm2: devirtualization to a straight-line (op, args) program with constant table, output map and template; version binding; per-node validation.

vm3: three black-box cipher probes, involution wrappers, encoding/compression drift; a certificate-derived salt inside the signature digest.

Also adds pitfalls P49-P50, three capability rows (all partial/unverified), the evidence/route records and EXTENSION-ref-absorption-2026-10b.md. Renumbers native-vm-recovery section 11 to 12. Gates and pytest green.
2026-10-25 12:10:41 +08:00
37 changed files with 2136 additions and 35 deletions

No files matched your search

+4
View File
@@ -38,6 +38,10 @@ tools/
# resting on "nobody has added them yet". # resting on "nobody has added them yet".
.ref/ .ref/
# A public skill clone read by the 2026-11 game-reserve absorption pass. Same rule: the method
# and the anonymised record ship, the upstream tree does not.
game-reserve/
# sandbox installs made while testing `npx skills add .` against this repo # sandbox installs made while testing `npx skills add .` against this repo
.claude/ .claude/
.agents/ .agents/
+7
View File
@@ -200,6 +200,13 @@ references/ loaded on demand, one topic each
dnSpy-Unity-mono patch that makes a retail Mono player accept a dnSpy-Unity-mono patch that makes a retail Mono player accept a
debugger, a run-time class lookup over frida-il2cpp-bridge, and debugger, a run-time class lookup over frida-il2cpp-bridge, and
the audit probes when the deliverable is a report the audit probes when the deliverable is a report
unity-lua-and-assetbundles.md
the Unity that is neither plain Mono nor IL2CPP: Lua logic in a
bundle (xLua/tolua/SLua), the Lua 5.1 header-byte tamper, bundle
CRC in the manifest the game actually reads, partial-encryption
windows, UnityFS rebuild traps (layout loss, stripped dependency
null, compressed == raw), TextAsset read-back, and half-encrypted
Mono assemblies behind a publisher shell
il2cpp-protected-metadata.md il2cpp-protected-metadata.md
when that pair is not readable: absent, 0-byte, encrypted or when that pair is not readable: absent, 0-byte, encrypted or
embedded metadata, the consumer-side dump, version-independent embedded metadata, the consumer-side dump, version-independent
+6
View File
@@ -120,6 +120,12 @@ references/ 按需加载,每个文件一个主题
用 Il2CppDumper 导出这一对文件、按能成功的顺序把表导入 IDA、 用 Il2CppDumper 导出这一对文件、按能成功的顺序把表导入 IDA、
让零售 Mono 播放器接受调试器的 dnSpy-Unity-mono 补丁、 让零售 Mono 播放器接受调试器的 dnSpy-Unity-mono 补丁、
基于 frida-il2cpp-bridge 的运行时类查找,以及交付物是报告时的审计探针 基于 frida-il2cpp-bridge 的运行时类查找,以及交付物是报告时的审计探针
unity-lua-and-assetbundles.md
既不是纯 Mono 也不是 IL2CPP 的 Unity:逻辑在 Lua bundle 里
(xLua/tolua/SLua)、Lua 5.1 头字节篡改、游戏真正读取的 manifest
CRC、局部加密窗口、UnityFS 重建陷阱(布局丢失、依赖被剥后返回
null、压缩大小等于原始大小)、TextAsset 读回,以及发行方壳后面的
半加密 Mono 程序集
il2cpp-protected-metadata.md il2cpp-protected-metadata.md
当这一对不可读时:缺失、0 字节、加密或内嵌的 metadata、 当这一对不可读时:缺失、0 字节、加密或内嵌的 metadata、
从消费端 dump、不信任版本号的 header 定长、XOR/VM/XXTEA 从消费端 dump、不信任版本号的 header 定长、XOR/VM/XXTEA
@@ -21,7 +21,7 @@ postings; no sample, tool output or target fact from them entered the repository
| W1: full arm64 custom-VM recovery (long-form) | 0x00–0x1A method narrative | `references/native-vm-recovery.md` (existence signals, dispatcher separation, partial deflattening, relocation tables, PC proofs, descriptor/ISA cautions, clean-re-VM loop) | | W1: full arm64 custom-VM recovery (long-form) | 0x00–0x1A method narrative | `references/native-vm-recovery.md` (existence signals, dispatcher separation, partial deflattening, relocation tables, PC proofs, descriptor/ISA cautions, clean-re-VM loop) |
| W2: VMP interpreter recovery with trace-driven IR lifting | anchor/trace/lifting narrative | `references/native-vm-recovery.md` (register anchoring + triple verification, nested segment stacks, STORE-backward slicing, byte provenance, IR shape), `vm_handler_slice.py` nested-loop diagnostic | | W2: VMP interpreter recovery with trace-driven IR lifting | anchor/trace/lifting narrative | `references/native-vm-recovery.md` (register anchoring + triple verification, nested segment stacks, STORE-backward slicing, byte provenance, IR shape), `vm_handler_slice.py` nested-loop diagnostic |
| W3: login-capture war story (packed + MADP/Weex + gomobile) | route-by-route复盘 | `references/pitfalls.md` P43–P46; the stack-ABI note in `references/hardware-watchpoints.md` | | W3: login-capture war story (packed + MADP/Weex + gomobile) | route-by-route复盘 | `references/pitfalls.md` P43–P46; the stack-ABI note in `references/hardware-watchpoints.md` |
| W4: manual OLLVM deflattening | predicate algebra + IDA scripting | cross-checked against existing content; its MOV/MOVK constant-propagation state mapping is referenced as the static counterpart in `native-vm-recovery.md` §11 — no new file | | W4: manual OLLVM deflattening | predicate algebra + IDA scripting | cross-checked against existing content; its MOV/MOVK constant-propagation state mapping is referenced as the static counterpart in `native-vm-recovery.md` §12 — no new file |
## 2. The one code change, and why — observed ## 2. The one code change, and why — observed
@@ -54,7 +54,7 @@ spin-loop note on the real code path. Both regressions are now pinned by tests.
plaintext boundary; a RegisterNative inventory is one run for a full method table). plaintext boundary; a RegisterNative inventory is one run for a full method table).
- W4's full IDA script: the technique is named (state-register MOV/MOVK constant propagation, - W4's full IDA script: the technique is named (state-register MOV/MOVK constant propagation,
CMP-site collection, predecessor walk past blocks with no CMP on the state register) and CMP-site collection, predecessor walk past blocks with no CMP on the state register) and
pointed at from `native-vm-recovery.md` §11; writing an IDA-independent implementation is a pointed at from `native-vm-recovery.md` §12; writing an IDA-independent implementation is a
future pass, not an absorbed claim. future pass, not an absorbed claim.
- Every sample identity in all four sources: anonymized by the authors, kept anonymized here; - Every sample identity in all four sources: anonymized by the authors, kept anonymized here;
`.ref/` (the local copies) is untracked and git-ignored in effect (never added). `.ref/` (the local copies) is untracked and git-ignored in effect (never added).
@@ -0,0 +1,113 @@
# EXTENSION — absorbing the reverse-engineering half of `game-reserve` (2026-11-09)
A public game-preservation skill was cloned at the repository root (`game-reserve/`). It is
mostly a workflow for turning a dead server into an offline build. That workflow is **not** what this
pass took. This pass read the case reports and the pitfalls for the reverse-engineering mechanisms
they contain and landed only those: how the Unity/Lua script layer is found and repaired, how
AssetBundles are checked and rebuilt, how a half-encrypted Mono assembly is read, how LayaAir's Conch
cache is recomputed, and what recon should measure before a route is chosen.
## Sources
- `game-reserve/` (the clone at the repository root) — its recon reference (logic-layer table,
encryption map, CRC log, resource-completeness check), four anonymised case reports (Unity + Lua,
LayaAir + JS, Unity Mono + SLua, native Kotlin), and its patch/pitfalls notes (UnityFS rebuild
traps, TextAsset read-back, hot-update merge, R8 minSdk branches, `os.date` race).
All are public secondary sources. Their case reports are `observed` **by their authors**; nothing in
this repository executed them. Identifiers, package names, hosts, keys, offsets and the source's own
scripts were deliberately not copied.
## What was added
One new reference file, because the topic had no owner:
| File | Covers | Why no existing file owned it |
|---|---|---|
| `references/unity-lua-and-assetbundles.md` | Unity + Lua (xLua/tolua/SLua) container discovery, script decryption and Lua 5.1 header repair, loader bytecode-only check, AssetBundle CRC source, UnityFS partial-encryption windows, bundle rebuild traps (layout loss, stripped dependency null, compressed == raw), added/replaced TextAsset read-back, half-encrypted Mono assemblies and the publisher shell | `unity-runtime.md` owns Mono/IL2CPP and `il2cpp-protected-metadata.md` owns protected metadata; neither owns a Lua layer or UnityFS container editing. `packers.md` owns generic shell identification, not the Mono-assembly decryptor shape |
Existing topic files were extended, not duplicated:
- `references/framework-runtimes.md` — a **LayaAir native (Conch)** section: identification, the
path-addressed cache, the DCC filetable checksum, metadata regeneration from shipped content, the
loader patch and the startup-delay race, plus the Laya render-loop freeze and poisoned-XHR shapes.
- `references/recon.md` — Unity + Lua and LayaAir rows in the code-location table, and a
**§1c** for resource completeness and the encryption map (manifest diff, player backup, entropy is
not encryption, fixed prefixes, config-table field check, separate "unreadable" from "not in hand").
- `references/repack-and-sign.md` — **renaming the package** across binary AXML, the `resources.arsc`
package block and the launcher label, with the validation that both builds coexist.
- `references/split-apk.md` — the narrow manual resource merge through `apktool` that the source's
native case used, with the condition that makes it safe and the collision that stops it.
- `references/dex-patching.md` — deleting specific calls from an original smali method instead of
hand-rewriting a lifecycle method, removing the argument-preparation instructions, and putting new
logic in an extra dex behind one `invoke-static`.
- `references/packers.md` — PairIP as a target-selection signal (Play licensing plus partial code
virtualization): prefer an older/regional build without it rather than fighting a re-signed suicide.
- `references/pitfalls.md` — **P51** (R8 deleted the low-API branch when `minSdk` was lowered),
**P52** (a decompiled Lua file does not match its name because the writer's `read()` returns the
template/original bytes) and **P53** (a retained AssetBundle returns null after its dependency was
stripped).
- `SKILL.md` and `references/routing.md` — two symptom rows: a Lua decompiler rejecting every
script with `non-standard lua format`, and a re-signed Unity/Mono build exiting cleanly with code
4 two seconds in.
## Deliberately not absorbed
- **The offline-revival workflow itself**: feasibility verdicts, fake local servers, virtual-clock
testing, player-order playtest, save-preserving release, media/OCR recovery, distribution and the
unattended-run playbook. It is a legitimate body of work, but it is a product workflow rather than
an APK-reverse mechanism, and the first pass that imported it was corrected for exactly that.
- **Target-specific constants**: package names, hosts, keys, offsets, counts, paths and the source's
scripts.
- **The source's local-server implementation**: `RPCWaitSend` handling, entity-property bags and the
rest belong to a game-revival project, not to this skill's protocol-reverse files.
- **The media/OCR and night-shift stacks**: no script surface is imported that this pass cannot test.
## Registration surface updated
- `references/routing.md`: one reference-index row; two symptom rows mirrored from `SKILL.md`.
- `README.md` and `README.zh-CN.md`: one entry in the structure block.
- `evidence/capability-matrix.json`: `unity-lua-and-assetbundle-recovery` and
`layaair-conch-dcc-recovery`, both `partial` / `route_measured: false` / `unverified`.
- `references/evidence-summary.md`: the same two rows.
- `references/coverage/route-inventory.md` and `coverage-and-limits.md`: two documented-route rows
and two bullets.
- `evidence/known-limitations.md`: one "never exercised" bullet.
- `.gitignore`: the upstream clone is ignored, so a later `git add -A` cannot commit it.
## Verification
None of the absorbed reverse-engineering mechanisms is `observed` in this repository. No Unity or
LayaAir package was decrypted, no bundle was rebuilt, no Mono assembly was reconstructed, and no
device build was installed. The checks performed here are structural: the new file and every changed
section resolve, the symptom mirror agrees, and the registration surface names the new capability.
## What would change a label
- **Unity + Lua**: decrypt one anonymous Unity+Lua package, decompile a script, patch one anchor,
rebuild the bundle, install it and show the changed behaviour after a cold start, with a control
build. That moves the Lua half toward `observed`.
- **UnityFS**: rebuild one bundle with the same layout and show it loads; then reproduce the
compressed-size-equals-raw crash in a control and fix it in one field. The single-field experiment is
the cheapest.
- **Mono half-encryption**: reconstruct one PE header from the documented landmarks and have a
decompiler open it; the shell-recovery half additionally needs the original process.
- **LayaAir DCC**: recompute the filetable for a package and show the engine accepts the regenerated
metadata offline. The checksum algorithm is arithmetic and can be host-tested on synthetic files;
the full route still needs a package.
## Gate status
Run after the change:
```text
python check_repo.py && python check_refs.py && python check_routing.py \
&& python check_commands.py && python check_budget.py && python -m pytest -q
```
Result on 2026-11-09: `check_repo` 0 problems; `check_refs` 489 reachable references, 0 dangling,
0 warnings; `check_routing` coherent (72 symptom rows, 63 reference rows, 64 script rows);
`check_commands` 196 checked, 0 drift; `check_budget` 448 lines / ~12,987 tokens, 0 failures,
0 warnings; `pytest` 796 passed, 209 skipped, 25 xfailed. A green run proves the inventory resolves
and the mirrors agree; it says nothing about whether a decrypted script or a rebuilt bundle works,
which is what the labels above are for.
@@ -0,0 +1,168 @@
# EXTENSION — second reference absorption from `ref/*` (2026-10-25)
This pass read three public Chinese write-ups dropped in `ref/` and absorbed their *mechanisms* into
the files that already own the topics. None was run end to end; a host-level pass (§Verification pass)
settles the claims that need no device. The record exists so a later reader can tell what changed and
on what footing.
## Sources
Three files, described by shape. Titles, authors, product names, package identifiers and every
per-build address are omitted; none was copied onto the tracked surface.
| File | What it is |
|---|---|
| `vm1.md` | A dual-library commercial shell on ARM64: two SOs, one owning Java/ART checks, the other owning an `init_proc` scheduler with inline-shellcode `exit_group`, three watchdog threads and SMC. Covers dump timing, a syscall-level reader, single-predicate patching and a tiered patch order |
| `vm2.md` | A white-box VM protecting one signing routine: threaded-code interpreter, tens of thousands of obfuscated nodes, and a devirtualization to a straight-line `(op, args)` program with constant table, output map and fixed template |
| `vm3.md` | A native signer behind a JNI shim plus an encrypted body: package/signature checks during `JNI_OnLoad`, an emulator used as an oracle, a differential probe that classifies the cipher, an involution wrapper around a standard stream cipher, and Java/Python encoding drift |
All three are **public secondary sources**. Their own claims are `observed` by their authors; nothing
in them was reproduced here. Mechanisms that need a target are therefore `unverified`, the ordering
judgements built on them are `inferred`, and the host-checkable ones are settled in §Verification
pass. No text, code, key material, offset table or screenshot was
copied.
## What was added
No new reference files. Each mechanism was folded into the file that already owns its topic:
| File | Absorbs | Deliberately does not |
|---|---|---|
| `references/linker-and-soinfo-repair.md` §6.2–6.3 | the dump window that closes inside `JNI_OnLoad` when self-decryption and watchdog startup share it; the raw-syscall reader outside a self-hooked libc; zero-filling unreadable pages so segment offsets survive repair | claim that a dump taken at `android_dlopen_ext` entry is complete; name a specific reader |
| `references/native-tamper-and-suicide.md` §Which site | predicate-first patching (one verdict function versus many kill sites), the tiered grading with the per-tier reason, benign-value selection by caller branch, watchdog enumeration by probe, one tier per run | copy any sample's function table or addresses; assert that a predicate patch covers an unenumerated checker |
| `references/detection-and-anti-analysis.md` §Filter signals | module-filtered signal attribution: ART's implicit `SIGSEGV` on `boot*.oat`/`odex`/JIT pages is the runtime's, and a handler must forward anything outside the target module | claim the discrimination is measured; recommend swallowing runtime signals |
| `references/native-vm-recovery.md` §11 | devirtualization to a runnable program: symbolic input, constant folding, loop/branch elimination, the four artefacts (program, constant table, output map, template), version binding, per-node validation | claim the route works for a VM that reads device state or time; replace the IR-recovery sections |
| `references/protocol-reverse.md` §7 | three black-box probes (header length, determinism, one-byte diffusion width, length law), involution-wrapper algebra, fixed-permutation recognition, and the Java-`URLEncoder` / compression-byte drift that decides the last mile. The probe's original prefix-XOR-only claim was falsified by the host run below and the section now states the corrected discriminator | claim any cipher was classified; assume byte-identical compression is required |
| `references/signature-derived-keys.md` §Variant | a certificate-derived salt concatenated *inside* the digest: why black-box hash search cannot find it, how to read the cached buffer, how to verify on three triples, and the per-build consequence | present the captured constant as an algorithm |
| `references/pitfalls.md` P49–P50 | extraction length masquerading as an algorithm gap; an involution wrapper that cancels | duplicate P42's decoder-desync case or the §7 method |
## Registration surface updated
- `evidence/capability-matrix.json`: three rows — `native-dump-window-and-syscall-reader` and
`whitebox-crypto-devirtualization-to-program` are `partial` / `route_measured: false` / `unverified`;
`cipher-classification-by-differential-probe` is `partial` / `route_measured: false` / `inferred`
after the host checks below; two existing rows
(`native-terminate-path-neutralisation`, `signature-derived-keys`) had their `limits` extended
rather than duplicated.
- `references/evidence-summary.md`: three rows.
- `references/coverage/route-inventory.md`: three rows.
- `references/coverage-and-limits.md`: three absorbed-route bullets extended.
- `SKILL.md`, `routing.md`, both READMEs: unchanged. No file, script or symptom row was added, so the
symptom mirror and the reference/script inventories had nothing to learn.
## Verification pass — host, 2026-10-25
Purpose: separate what the write-ups report from what this host can show, and label per claim rather
than per section. Three tiers were applied: `observed` (a command ran here and its output is below),
`inferred` (follows from a mechanism or a neighbouring measurement), `unverified` (reported by
someone else, not reproduced). No device, protected sample or server was involved, so **no claim
about a target was upgraded**.
```bash
python3 docs/tool-verification/fixtures/verify_absorbed_claims.py
```
```text
PASS mask identity (protocol-reverse section 7, involution)
65536 eight-bit (x,m) pairs: 0 counterexamples
200000 random 16-bit pairs: 0 counterexamples
PASS PKCS#7 length law (protocol-reverse section 7, probe 3)
b=16, p=0..64: 0 mismatches
PASS unreadable page: skip shifts, zero-fill preserves (linker section 6.3)
expected offset 8199
skip -> 4103
zero-fill -> 8199
PASS hidden salt defeats a visible-parameter search (signature-derived-keys variant)
36 combinations over 3 algorithms and 4 field orders: 0 hits
with the salt included: match
PASS compressed bytes are implementation/parameter defined (protocol-reverse section 7)
level 1 = 49 bytes, level 9 = 48 bytes, identical = False
both round-trip to the payload
PASS Python percent-encoding differs from Java URLEncoder (protocol-reverse section 7)
quote = a%20b~%2A-_.
quote_plus = a+b~%2A-_.
Java keeps *-._ and encodes ~ as %7E -- not checked here (no JDK)
PASS AES mode separation (protocol-reverse section 7, probe 2)
ctr prefix-xor dirty=0/32 one-byte-flip changed=1/32
cbc prefix-xor dirty=0/32 one-byte-flip changed=32/32
ecb prefix-xor dirty=0/32 one-byte-flip changed=16/32
all three modes show zero prefix-XOR: that probe cannot separate them
7 check(s), 0 failed
RESULT=ok
```
### What the run falsified
The absorbed probe said *zeros over the common prefix ⇒ a stream cipher*. Measured on AES-128 with a
fixed IV, **CTR, CBC and ECB all produce zero prefix-XOR** (0 of 32 bytes differ): any deterministic
mode reproduces the ciphertext of a prefix, so the experiment only proves the absence of a
per-message nonce. The discriminator that does work is a one-byte plaintext flip: CTR changes exactly
1 byte, CBC changes every block from the flipped one onward (32 of 32 here), ECB changes exactly one
block (16 of 32, later blocks untouched). The reference now states the corrected procedure; the
capability row records the correction instead of the original claim.
**A label convention was corrected.** `native-vm-recovery.md`'s claim-strength paragraph called the
absorbed mechanics `inferred`. Under the repository's definition (`unverified` = reported by someone
else, not reproduced) the mechanics are `unverified`, and only the ordering judgements are
`inferred`. The paragraph and the checklist now say that; no capability row changed for it.
### Claims the run settles (host only)
| Claim | Where | Now |
|---|---|---|
| `(x & ~m) \| (~x & m) == x ^ m`, and the composition is an involution | `protocol-reverse.md` §7 | `observed` |
| PKCS#7 padded length is `b * ceil((len+1)/b)` | `protocol-reverse.md` §7 | `observed` |
| Zero-filling an unreadable page preserves later offsets; skipping shifts them | `linker-and-soinfo-repair.md` §6.3 | `observed` |
| An unknown salt inside the digest defeats a search over visible parameters | `signature-derived-keys.md` §Variant | `observed` |
| Two compressors/parameters can emit different valid bytes for one payload | `protocol-reverse.md` §7 | `observed` (general) |
| Python's encoder treats ` `, `*`, `~` differently from Java's | `protocol-reverse.md` §7 | `observed` (Python side) |
| CTR / CBC / ECB are separable by diffusion width, not by prefix-XOR | `protocol-reverse.md` §7 | `observed` |
### Claims that stay `unverified`, and what would move them
- **Device-side mechanisms** — the dump window inside `JNI_OnLoad`, watchdog startup, a protector
intercepting the dump reader. Needs a device and a protected sample: the experiments are the four
already listed under *What would change a label*.
- **The Java encoder mapping** — no JDK on the analysis host. One captured parameter from a real
request settles it; until then the mapping is quoted from the JDK contract.
- **liblz4 versus python-lz4** — no lz4 binding here. The general claim is `observed`; the specific
pair is not.
- **The devirtualization route** — needs a VM binary; nothing on this host can stand in for one.
## Deliberately not absorbed
- **Per-build constants and addresses**: function offsets, unified kill-site addresses, the 32-byte
salt value, the signing prefix and template string, the package identifier, the shell's own
`sub_*` names. They are only valid for one build and they carry identity.
- **Performance and effort claims** ("1 ms", "days to hours") — no measurement exists here to anchor
them.
- **The AI-assisted-analysis narrative** in one source: it is advice about tool use, not a reversing
mechanism, and it is not reproducible as written.
- **Thread and watchdog tables as data.** The *method* (enumerate by probe, then prove the set closed)
was absorbed; the table itself would invite applying one build's layout to another.
## What would change a label
One cheap experiment per row, on a device this record never had. The cipher row's host half is
already done (§Verification pass); what remains there is a real body and a real server.
- **Dump window:** dump one protected image at `android_dlopen_ext` entry, repair it, and open it in a
disassembler with the expected functions present; separately dump inside `JNI_OnLoad` and record
whether the process survives.
- **Patch grading:** run the same target twice — kill sites only, then the predicate only — and show
which one survives longer than the observed timer.
- **Devirtualization:** extract one program, run it against a device call on ten inputs, and show
per-node equality at three checkpoints.
- **Cipher classification:** classify one body with the three probes, then reproduce it and have the
server accept the request.
Until one of these is recorded, the matrix rows stay `partial` — `inferred` for the cipher row on the
host evidence, `unverified` for the other two — and none may be cited as support for a claim about a
target.
## Gate status
`check_repo.py`, `check_refs.py`, `check_routing.py`, `check_commands.py`, `check_budget.py` and
`pytest -q` were run after the change; the result is in the session record, not in this file. A green
run proves the inventory resolves; it says nothing about whether the mechanisms work.
@@ -0,0 +1,151 @@
# EXTENSION — third audit of the `ref/*` drop folder (2026-10-27)
`ref/` still held the sixteen write-ups absorbed on 2026-10-24 (`EXTENSION-ref-absorption-2026-10.md`).
Their mtimes were unchanged, and nothing in the folder matched the 2026-10-25 set that was absorbed in
place. So this pass was **not** a re-absorption: it re-read all sixteen, compared every generalisable
mechanism against what the skill already says, and ran the host-checkable part of what it found. Nine
mechanisms were still absent, one absorbed sentence turned out to be wrong, and one procedure is now
`observed` instead of `unverified`.
## Sources
The same sixteen files, in the same four groups as the 2026-10 record (Unity/IL2CPP nine, linker three,
x86 VM protector three, Pyarmor one). Titles, authors, product names and package identifiers are omitted
here for the same reason as before: they carry identity and nothing in the tracked surface needs them.
All are public secondary sources, `unverified` in this repository unless the verification pass below
says otherwise.
## What was added
No new reference files — every mechanism went into the file that already owns its topic.
| Mechanism | File | Why the existing text did not cover it |
|---|---|---|
| The shipped Pyarmor blob is wrapped once more: outer container → per-code-object → per-string, three nonce scopes on one master key, and a live dump is therefore structurally incomplete | `python-bytecode-recovery.md` §2.2 | §3 opened with "the protected file is a normal `.pyc` with extra fields", which is the second layer, not the file you are handed |
| Mirror the host register width, not just the register clobbers, when reimplementing the 12-byte key VM | `python-bytecode-recovery.md` §2.1 | §2.1 named the `idiv` clobber; 32-bit wrapping and truncating division were unstated, and they fail the same way |
| Python compiled away (Nuitka / Cython / `pyd`): no `.pyc` is not "no Python" | `framework-runtimes.md` identification table | the Python row implied the runtime always arrives as bytecode |
| A rebuilt `libil2cpp` announces itself in the ELF tables (`JNI_OnLoad` export, own `DT_INIT`/`init_array`, `SHT_LOUSER` section) | `il2cpp-protected-metadata.md` §1.1 | the triage table sent "registration search returns 0" straight to the live-image dump; the injected entry point is cheaper to find and is what the dumper's refusal is reacting to |
| A container VM's block schedule decides what a unit test is: fixed-size blocks with a truncated tail and no cross-block state vs a chained context | `il2cpp-protected-metadata.md` §3.2 | the section specified the container layout and stopped at "replay the program"; the call site is what says whether block 0 is a valid test |
| When the literal cipher lives in the VM, drive `String::NewLen` over every index instead of reversing the cipher — and use it as a completeness proof | `il2cpp-protected-metadata.md` §6 | the hook was documented as observation only; enumerating the index space is a different, stronger route |
| A VM can live in the managed layer: opcode array + cursor + `Dictionary<int, delegate>`, handler indices enrolled in the constructor | `unity-runtime.md` §when the managed layer is itself the interpreter | every VM file assumed a native interpreter; `native-vm-recovery.md` now says so explicitly and cross-links |
| Static array literals are field defaults materialised by `RuntimeHelpers::InitializeArray`, not bytes in `.rodata` | `unity-runtime.md` same section | the absence of a table in `.rodata` was being read as "derived at run time" |
| Hook the framework crypto primitive (BCL AES provider, `javax.crypto`), not the app's obfuscated wrapper | `unity-runtime.md` §5 | §5 polled the app's own class; the stability of framework class names under obfuscation is the point |
| A comparison gate is a prefix oracle: instrument the comparator's counter, and read the fail-path cost to decide whether the oracle is open | `account-gates.md` Step 2b | the file classified gates by authority and never considered that the comparison itself leaks the expected value |
| Debugger-side stop policy: `SIGPWR`/`SIGXCPU` suspend-to-crash, one database per activity, input injection into a paused process | `ida-so-debugging.md` §8 | the debuggable-side failure modes were documented; the failures caused by the debugger's own defaults were not |
### A claim that was corrected, not added
`python-bytecode-recovery.md` §5 said an unset `nonce[15]` "produces a stream that decrypts the first
block plausibly and then diverges". Counter mode does not have that state: the keystream for block *i*
is `E(nonce || counter_i)`, so a different nonce byte changes the output from block 0. Measured below.
The paragraph now says what happens (every block wrong; an unset tail makes the result
non-reproducible) and tells the reader to check a known prologue rather than "a plausible body".
## Registration surface updated
- `evidence/capability-matrix.json`: two rows, `il2cpp-managed-layer-bytecode-vm` (`partial`,
`route_measured: false`, `unverified`) and `comparison-cost-oracle` (`partial`,
`route_measured: false`, `observed` — the host half only).
- `references/evidence-summary.md`: the same two rows, with the same labels.
- `references/coverage/route-inventory.md`: one new row (the comparison oracle) and three extended rows
(Unity, protected IL2CPP, Python).
- `references/coverage-and-limits.md`: three bullets under "Covered by documented routes", each naming
which half is measured.
- `SKILL.md`, `routing.md`, both READMEs: unchanged. No file, script or symptom row was added, so the
symptom mirror and the inventories had nothing to learn. That is also why the token budget did not
move.
## Verification pass — host, 2026-10-27
```bash
python3 docs/tool-verification/fixtures/verify_ref_claims_10c.py
```
```text
PASS CTR: nonce tail changes block 0 (python-bytecode-recovery section 5)
keystream block 0 differs in 16/16 bytes
ciphertext block 0 differs in 16/16 bytes, blocks 1-2 in 32/32
negative control, nonce against itself: 0/48 bytes differ
so there is no "first block decrypts, rest diverges" state -- every block is wrong
PASS comparison cost is a prefix oracle (account-gates Step 2b)
prefix 0/15 -> early-exit 1, full pass 15
prefix 1/15 -> early-exit 2, full pass 15
...
prefix 15/15 -> early-exit 15, full pass 15
full pass over the same candidates: [15]
negative control, identical inputs through the early-exit build: 15 (must be 15)
early exit: work grows one unit per correct prefix byte; full pass: constant
PASS metadata header size by backward walk (il2cpp-protected-metadata section 2.1)
declared 0x1140, forward scan 0x1140, walk from 0x10c -> 0x1140
negative control, off-grid start 0x110 -> 0x1120 (must differ)
magic/version zeroed in this fixture: the walk uses only offset/count pairs
3 check(s), 0 skipped, 0 failed
RESULT=ok
```
Three labels changed as a result: the counter-mode statement in §5 is now `observed` (and corrected),
the comparison-cost separation in `account-gates.md` is `observed` for the synthetic case only, and
the backward header walk in §2.1 is `observed` on a synthetic header. **No claim about a target was
upgraded** — no device, sample or server was involved.
### The fixture was audited before it was trusted
The first draft passed all three checks and was still wrong in one of them: the comparison check
incremented its own counter inside the loop it was measuring, so `work == k + 1` restated the Python
source and could not fail for any real reason — the repository's "a limit that cannot fail is
decorative" defect, in a check that was about to carry an `observed` label. Three changes:
1. **Measured on compiled code.** The two comparators are now C, built with `-O2` and called through
`ctypes`; the question is what a compiler emits for `break` on mismatch, which an interpreted loop
cannot answer about itself. Without a compiler the check reports SKIP rather than PASS.
2. **Every check carries a negative control** that must come out empty: the same nonce twice (0/48
bytes differ), identical inputs through the early-exit build (15, i.e. a full pass), and an
off-grid walk start (`0x110` yields `0x1120` instead of `0x1140`).
3. **The verdict travels as a return value, not through a global list.** `main()` built its failure
count from the list `report()` appended to, so a check that returned False without printing would
have been invisible; it now counts the return values and reports skips separately.
`tests/unit/test_verify_ref_claims_10c.py` injects the wrong claim into each check and requires the
failure — full-pass mislabelled as early-exit, early-exit mislabelled as constant, an unchanged nonce,
an off-grid walk, a pair table whose declared and scanned lengths disagree — plus the skip semantics
(a host with no `openssl`/compiler exits 0 with SKIP) and the exit-code plumbing. The AES probe needs
`openssl`; the comparison probe needs a C compiler; the header check needs nothing.
## Deliberately not absorbed
- **Per-build constants and identities**: offsets, keys, package ids, function counts, the articles' own
scripts. Same rule as the two earlier passes.
- **Asset and media pipelines** (Live2D `moc3`, video reconstruction, Blender conventions) and the
CDN-manifest delta. One candidate survived this audit — "an index pulled from a device is a cache
subset, not the catalogue" — and was dropped deliberately: it is a provenance rule for a download
pipeline, and `server-config-and-updates.md` is not an asset-extraction file.
- **In-memory patch hygiene** (write the operand, restore `r-x`) from one article: the distinct part is
one sentence, and `native-and-so.md` already carries the "which copy is mapped" rule that decides
whether a patch matters at all. Recording it would have added a fourth file to a single idea.
- **Performance and effort claims**, and the articles' commentary about tooling quality.
## What would change a label
One experiment per row, none of which this record could run:
- **Managed-layer VM**: recover one opcode table from a `dump.cs` interpreter and show an instruction
stream that reproduces a known in-game value. That moves the row to `observed`; today only the shape
is documented.
- **Array literals**: hook `InitializeArray` on a live build and read back a key that the same build's
`.rodata` does not contain.
- **Comparison oracle**: run the counter against one real serial gate and show the work grows with the
correct prefix. On a device, use the comparator's counter, not the clock — a timing-only attempt is
expected to fail and would not move the row.
- **Pyarmor outer layer**: decrypt one shipped blob, show the pyc magic appearing only after the outer
pass, then decrypt one code object and run the recovered module.
- **Rebuilt `libil2cpp`**: `readelf` a stock library and the protected one side by side and show the
three markers absent/present.
## Gate status
`check_repo.py`, `check_refs.py`, `check_routing.py`, `check_commands.py`, `check_budget.py` and
`pytest -q` were run after the change and are green (796 passed, 209 skipped, 25 xfailed; eight of
those tests are the fixture's own falsifiability cases). A green run
proves the inventory resolves and the mirrors agree; it says nothing about whether any mechanism works
on a target, which is what the labels above are for.
+3 -2
View File
@@ -76,8 +76,8 @@ those are called out in the matrix rather than buried here.
## Absorption-pass record ## Absorption-pass record
A later pass absorbed mechanics from external skill repositories (`reverse-skill`, A later pass absorbed mechanics from external skill repositories (`reverse-skill`,
`awesome-game-security`, `android-reverse-engineering-claude-skill`, `MobileRE-Skill`), keeping each `awesome-game-security`, `android-reverse-engineering-claude-skill`, `MobileRE-Skill`, `game-reserve`),
project's own discipline: only the phase, the checklist and the command pattern cross over, with the keeping each project's own discipline: only the phase, the checklist and the command pattern cross over, with the
source URL and the access date recorded, and nothing vendored as a runtime dependency. These files source URL and the access date recorded, and nothing vendored as a runtime dependency. These files
live here rather than in the skill because two of them corrected a claim the repository had already live here rather than in the skill because two of them corrected a claim the repository had already
written down. written down.
@@ -89,6 +89,7 @@ written down.
| `EXTENSION-detection-pipeline.md` | Naming the check that fires: three arms on a public MASTG target (control alive, probe arm dead in ≈300 ms via `strstr("frida")`, with the `TracerPid=0` versus 4-frida-mappings asymmetry), `svc_scan.py`'s two decoders agreeing on an identical 214-site set, the layered Java-to-svc descent, and the ptrace-free dump boundary on targets whose dex is deflated inside the APK | | `EXTENSION-detection-pipeline.md` | Naming the check that fires: three arms on a public MASTG target (control alive, probe arm dead in ≈300 ms via `strstr("frida")`, with the `TracerPid=0` versus 4-frida-mappings asymmetry), `svc_scan.py`'s two decoders agreeing on an identical 214-site set, the layered Java-to-svc descent, and the ptrace-free dump boundary on targets whose dex is deflated inside the APK |
| `EXTENSION-dexsql.md` | The SQL query layer adopted as a **third indexer** beside rasc/droidasc/ddc: identical class-definition sets on four archives (zero differences either way), the string xref agreement and the `=` versus `LIKE` match-semantics trap, `decode` against `ddc disasm` line for line, and the persistent cache measured as **not** a speed switch | | `EXTENSION-dexsql.md` | The SQL query layer adopted as a **third indexer** beside rasc/droidasc/ddc: identical class-definition sets on four archives (zero differences either way), the string xref agreement and the `=` versus `LIKE` match-semantics trap, `decode` against `ddc disasm` line for line, and the persistent cache measured as **not** a speed switch |
| `EXTENSION-ref-absorption-2026-10.md` | Sixteen public write-ups in four groups (Unity/IL2CPP metadata protection, linker-level SO packing, VM protector idioms, Pyarmor bytecode), the four reference files they became, the registration surface that changed, and the one cheap experiment that would move each row off `unverified` | | `EXTENSION-ref-absorption-2026-10.md` | Sixteen public write-ups in four groups (Unity/IL2CPP metadata protection, linker-level SO packing, VM protector idioms, Pyarmor bytecode), the four reference files they became, the registration surface that changed, and the one cheap experiment that would move each row off `unverified` |
| `EXTENSION-game-reserve-2026-11.md` | The reverse-engineering half of a public game-preservation skill: Unity + Lua script extraction and the Lua 5.1 header tamper, AssetBundle CRC and UnityFS rebuild traps, half-encrypted Mono assemblies, LayaAir Conch DCC checksums, plus recon/repack/split/dex/packer additions — all absorbed as `unverified`, since no package was rebuilt here |
## Hardware-layer pass record ## Hardware-layer pass record
@@ -0,0 +1,153 @@
#!/usr/bin/env python3
"""Re-run the host-checkable claims absorbed from ref/* on 2026-10-25.
These are the claims that can be settled without a device, a protected sample or a server. Each
check prints what it measured and whether the claim in the reference survived it. The AES probes
need `openssl`; without it they report SKIP rather than passing.
Usage:
python3 docs/tool-verification/fixtures/verify_absorbed_claims.py
"""
import hashlib
import math
import random
import shutil
import subprocess
import sys
import urllib.parse
import zlib
PAGE = 4096
KEY = '000102030405060708090a0b0c0d0e0f'
IV = KEY
results = []
def report(name, ok, detail):
results.append((name, ok))
print(('PASS ' if ok else 'FAIL ') + name)
for line in detail:
print(' ' + line)
def mask_identity():
bad = sum(1 for x in range(256) for m in range(256)
if ((x & ~m) | (~x & m)) & 0xFF != x ^ m)
random.seed(1)
bad16 = 0
for _ in range(200000):
x, m = random.getrandbits(16), random.getrandbits(16)
if ((x & ~m) | (~x & m)) & 0xFFFF != x ^ m:
bad16 += 1
report('mask identity (protocol-reverse section 7, involution)', bad == 0 and bad16 == 0,
['65536 eight-bit (x,m) pairs: %d counterexamples' % bad,
'200000 random 16-bit pairs: %d counterexamples' % bad16])
def padding_length():
bad = [n for n in range(0, 65)
if n + (16 - n % 16) != 16 * math.ceil((n + 1) / 16)]
report('PKCS#7 length law (protocol-reverse section 7, probe 3)', not bad,
['b=16, p=0..64: %d mismatches' % len(bad)])
def zero_fill():
img = bytearray(3 * PAGE)
img[2 * PAGE + 7] = 0xAB
skipped = img[:PAGE] + img[2 * PAGE:]
filled = img[:PAGE] + bytearray(PAGE) + img[2 * PAGE:]
ok = skipped.index(0xAB) != 2 * PAGE + 7 and filled.index(0xAB) == 2 * PAGE + 7
report('unreadable page: skip shifts, zero-fill preserves (linker section 6.3)', ok,
['expected offset %d' % (2 * PAGE + 7),
'skip -> %d' % skipped.index(0xAB),
'zero-fill -> %d' % filled.index(0xAB)])
def hidden_salt():
p, b, t = b'api=search', b'{"q":"x"}', b'1729000000'
salt = bytes.fromhex('00112233445566778899aabbccddeeff')
target = hashlib.md5(p + b + t + salt).hexdigest()
tried = hits = 0
for alg in (hashlib.md5, hashlib.sha1, hashlib.sha256):
for sep in (b'', b'&', b'|'):
for parts in ((p, b, t), (t, b, p), (p, t, b), (b, p, t)):
tried += 1
hits += alg(sep.join(parts)).hexdigest() == target
ok = hits == 0 and hashlib.md5(p + b + t + salt).hexdigest() == target
report('hidden salt defeats a visible-parameter search (signature-derived-keys variant)', ok,
['%d combinations over 3 algorithms and 4 field orders: %d hits' % (tried, hits),
'with the salt included: match'])
def compression_drift():
data = b'{"items":[' + b'{"id":1,"name":"x"},' * 40 + b']}'
a, b = zlib.compress(data, 1), zlib.compress(data, 9)
ok = a != b and zlib.decompress(a) == data and zlib.decompress(b) == data
report('compressed bytes are implementation/parameter defined (protocol-reverse section 7)', ok,
['level 1 = %d bytes, level 9 = %d bytes, identical = %s' % (len(a), len(b), a == b),
'both round-trip to the payload'])
def percent_encoding():
q = urllib.parse.quote('a b~*-_.')
qp = urllib.parse.quote_plus('a b~*-_.')
ok = q == 'a%20b~%2A-_.' and qp == 'a+b~%2A-_.'
report('Python percent-encoding differs from Java URLEncoder (protocol-reverse section 7)', ok,
['quote = ' + q, 'quote_plus = ' + qp,
'Java keeps *-._ and encodes ~ as %7E -- not checked here (no JDK)'])
def aes_enc(mode, data):
cmd = ['openssl', 'enc', '-aes-128-' + mode, '-K', KEY, '-iv', IV, '-nopad']
run = subprocess.run(cmd, input=data, capture_output=True)
if run.returncode:
raise RuntimeError(run.stderr.decode('utf-8', 'replace'))
return run.stdout
def aes_modes():
if not shutil.which('openssl'):
report('AES mode separation (protocol-reverse section 7, probe 2)', True,
['SKIP: openssl not found'])
return
p1 = b'A' * 32
p2 = b'A' * 32 + b'B' * 16
flipped = bytearray(p1)
flipped[5] ^= 0xFF
flipped = bytes(flipped)
def dirty(a, b):
return sum(1 for i in range(min(len(a), len(b))) if a[i] != b[i])
rows = []
ok = True
for mode in ('ctr', 'cbc', 'ecb'):
c1, c2, cm = aes_enc(mode, p1), aes_enc(mode, p2), aes_enc(mode, flipped)
px = dirty(c1, c2[:len(c1)])
width = dirty(c1, cm)
rows.append('%-3s prefix-xor dirty=%d/32 one-byte-flip changed=%d/32' % (mode, px, width))
if px != 0:
ok = False
ok = ok and rows[0].endswith('1/32') and rows[1].endswith('32/32') and rows[2].endswith('16/32')
report('AES mode separation (protocol-reverse section 7, probe 2)', ok,
rows + ['all three modes show zero prefix-XOR: that probe cannot separate them'])
def main():
print('== host checks for the 2026-10-25 absorption ==')
mask_identity()
padding_length()
zero_fill()
hidden_salt()
compression_drift()
percent_encoding()
aes_modes()
failed = [name for name, ok in results if not ok]
print('')
print('%d check(s), %d failed' % (len(results), len(failed)))
print('RESULT=%s' % ('ok' if not failed else 'failed'))
return 0 if not failed else 1
if __name__ == '__main__':
sys.exit(main())
@@ -0,0 +1,227 @@
#!/usr/bin/env python3
"""Re-run the claims added by the 2026-10-27 ref/* audit pass that need no device.
Three claims, all of which the reference files now call 'observed (host)':
1. python-bytecode-recovery.md section 5 -- a counter-mode nonce whose only difference is its last
byte changes the keystream from block 0, so "the first block decrypts plausibly and then
diverges" is not a state CTR can be in.
2. account-gates.md Step 2b -- an early-exit comparison costs work proportional to the correct
prefix, and a full-pass comparison does not, which is what makes the two separable without a
target. Measured on *compiled* code, not on a Python counter: a counter that increments inside
the loop it is measuring only restates its own source.
3. il2cpp-protected-metadata.md section 2.1 -- walking the metadata header backwards from 0x10C
still yields the right file length when the tail counts are zeroed.
Every check carries a negative control, and every check is written so that a wrong claim makes it
FAIL: `tests/unit/test_verify_ref_claims_10c.py` injects the wrong claim into each one and requires
the failure. A check that cannot fail is decorative.
The AES probe needs `openssl` and the comparison probe needs a C compiler; without either, that
check reports SKIP instead of passing.
Usage:
python3 docs/tool-verification/fixtures/verify_ref_claims_10c.py
"""
import ctypes
import os
import shutil
import struct
import subprocess
import sys
import tempfile
KEY = '000102030405060708090a0b0c0d0e0f'
def report(name, ok, detail):
"""Print one verdict and pass it through. `ok is None` means the host cannot run the check.
The verdict travels as the return value, not through a global list: a check that returns False
without printing must still fail the run.
"""
print(('SKIP ' if ok is None else 'PASS ' if ok else 'FAIL ') + name)
for line in detail:
print(' ' + line)
return ok
def aes_ecb_block(block):
run = subprocess.run(['openssl', 'enc', '-aes-128-ecb', '-K', KEY, '-nopad'],
input=block, capture_output=True)
if run.returncode:
raise RuntimeError(run.stderr.decode('utf-8', 'replace'))
return run.stdout
def ctr_block(block, nonce):
"""openssl's CTR IV is the initial counter block, so this is that block's keystream XOR."""
run = subprocess.run(['openssl', 'enc', '-aes-128-ctr', '-K', KEY, '-iv', nonce.hex(), '-nopad'],
input=block, capture_output=True)
if run.returncode:
raise RuntimeError(run.stderr.decode('utf-8', 'replace'))
return run.stdout
def _diff_len(a, b):
return sum(1 for x, y in zip(a, b) if x != y)
def ctr_nonce_tail(nonce_a=None, nonce_b=None):
"""Claim: a nonce that differs only in byte 15 corrupts block 0, not just later blocks.
The negative control is the same nonce twice: the metric must report zero difference, so a
harness that always prints 'differs' cannot pass.
"""
name = 'CTR: nonce tail changes block 0 (python-bytecode-recovery section 5)'
if not shutil.which('openssl'):
return report(name, None, ['openssl not found: cannot run this check on this host'])
base = bytes(range(12)) + b'\x00\x00\x00'
n_zero = nonce_a if nonce_a is not None else base + b'\x00'
n_two = nonce_b if nonce_b is not None else base + b'\x02'
plain = b'A' * 48
ks_zero, ks_two = aes_ecb_block(n_zero), aes_ecb_block(n_two)
block0_ks = _diff_len(ks_zero, ks_two)
c_zero, c_two = ctr_block(plain, n_zero), ctr_block(plain, n_two)
first = _diff_len(c_zero[:16], c_two[:16])
later = _diff_len(c_zero[16:48], c_two[16:48])
control = _diff_len(c_zero, ctr_block(plain, n_zero))
ok = block0_ks == 16 and first == 16 and later == 32 and control == 0
return report(name, ok,
['keystream block 0 differs in %d/16 bytes' % block0_ks,
'ciphertext block 0 differs in %d/16 bytes, blocks 1-2 in %d/32' % (first, later),
'negative control, nonce against itself: %d/48 bytes differ' % control,
'so there is no "first block decrypts, rest diverges" state -- every block is wrong'])
C_EARLY = """
int cmp_work(const unsigned char *a, const unsigned char *b, int n) {
int work = 0;
for (int i = 0; i < n; i++) {
work++;
if (a[i] != b[i]) break;
}
return work;
}
"""
C_FULL = """
unsigned sink;
int cmp_work(const unsigned char *a, const unsigned char *b, int n) {
int work = 0;
unsigned diff = 0;
for (int i = 0; i < n; i++) {
work++;
diff |= (unsigned)(a[i] ^ b[i]);
}
sink ^= diff;
return work;
}
"""
def _build(lib_source, tmpdir, tag):
src = os.path.join(tmpdir, tag + '.c')
so = os.path.join(tmpdir, 'lib' + tag + '.so')
with open(src, 'w') as fh:
fh.write(lib_source)
cc = shutil.which('gcc') or shutil.which('cc') or shutil.which('clang')
run = subprocess.run([cc, '-O2', '-shared', '-fPIC', '-o', so, src],
capture_output=True)
if run.returncode:
raise RuntimeError(run.stderr.decode('utf-8', 'replace'))
lib = ctypes.CDLL(so)
lib.cmp_work.restype = ctypes.c_int
lib.cmp_work.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int]
return lib.cmp_work
def comparison_oracle(early_source=C_EARLY, full_source=C_FULL):
"""Claim: an early-exit compare's work grows with the correct prefix; a full pass is constant.
Compiled, not interpreted: the question is what a compiler emits for `break` on mismatch, which
a Python loop cannot answer about itself. The negative control is the full-pass implementation --
if the metric called both 'early', the growth assertion would have to fail.
"""
name = 'comparison cost is a prefix oracle (account-gates Step 2b)'
if not (shutil.which('gcc') or shutil.which('cc') or shutil.which('clang')):
return report(name, None, ['no C compiler found: cannot measure compiled output'])
secret = b'ACTIVATION-CODE'
n = len(secret)
rows = []
with tempfile.TemporaryDirectory() as tmp:
early = _build(early_source, tmp, 'early')
full = _build(full_source, tmp, 'full')
grew = True
for k in range(0, n + 1):
cand = secret[:k] + b'\x00' * (n - k)
e = early(cand, secret, n)
rows.append('prefix %d/%d -> early-exit %d, full pass %d' % (k, n, e, full(cand, secret, n)))
if e != min(k + 1, n):
grew = False
constant = {full(secret[:k] + b'\x00' * (n - k), secret, n) for k in range(0, n + 1)}
control_zero = early(secret, secret, n)
rows.append('full pass over the same candidates: %s' % sorted(constant))
rows.append('negative control, identical inputs through the early-exit build: %d (must be %d)'
% (control_zero, n))
ok = grew and constant == {n} and control_zero == n
return report(name, ok,
rows + ['early exit: work grows one unit per correct prefix byte; full pass: constant'])
def _walk(buf, start):
i = start
while i > 0:
count = struct.unpack_from('<i', buf, i)[0]
if count:
return struct.unpack_from('<i', buf, i - 4)[0] + count
i -= 8
return None
def header_walk(pairs=None, start=0x10C):
"""Claim: the backward walk from 0x10C sizes a header whose magic and tail are zeroed.
Ground truth is computed twice: from the pair table that built the fixture, and by an
independent forward scan (max of offset+count). The negative control is a walk on an off-grid
start -- it must disagree, otherwise "steps of 8" is not what the check is testing.
"""
name = 'metadata header size by backward walk (il2cpp-protected-metadata section 2.1)'
if pairs is None:
pairs = [(0x1100, 0x40), (0x10C0, 0x20), (0x10A0, 0x10),
(0x1090, 0x08), (0x1088, 0x08), (0x1080, 0x08)]
end = 0x10C
header = bytearray(0x200)
for idx, (offset, count) in enumerate(pairs):
struct.pack_into('<i', header, end - 8 * idx, count)
struct.pack_into('<i', header, end - 8 * idx - 4, offset)
declared = pairs[0][0] + pairs[0][1]
forward = max(offset + count for offset, count in pairs)
walked = _walk(header, start)
off_grid = _walk(header, start + 4)
ok = walked == declared == forward and off_grid != declared
return report(name, ok,
['declared %#x, forward scan %#x, walk from %#x -> %#x'
% (declared, forward, start, walked),
'negative control, off-grid start %#x -> %#x (must differ)'
% (start + 4, off_grid),
'magic/version zeroed in this fixture: the walk uses only offset/count pairs'])
def main():
print('== host checks for the 2026-10-27 ref audit pass ==')
verdicts = [check() for check in (ctr_nonce_tail, comparison_oracle, header_walk)]
skipped = sum(1 for v in verdicts if v is None)
failed = sum(1 for v in verdicts if v is False)
print('')
print('%d check(s), %d skipped, %d failed' % (len(verdicts), skipped, failed))
print('RESULT=%s' % ('ok' if not failed else 'failed'))
return 0 if not failed else 1
if __name__ == '__main__':
sys.exit(main())
+2
View File
@@ -252,6 +252,8 @@ unread in this repository.
| A `dlopen`-able `.so` will not load after a custom loader, or a repaired `soinfo` resolves symbols to garbage | `linker-and-soinfo-repair.md` — bias versus base, `seg_page_offset`, the defining library's bias, `APS2` packed relocs, the minimal `soinfo` field set, and the dump window after `LoadSegments` | | A `dlopen`-able `.so` will not load after a custom loader, or a repaired `soinfo` resolves symbols to garbage | `linker-and-soinfo-repair.md` — bias versus base, `seg_page_offset`, the defining library's bias, `APS2` packed relocs, the minimal `soinfo` field set, and the dump window after `LoadSegments` |
| A native trace has no `cmp`/`sub`/`jcc` — only `and/or/not/shr/neg`, a flags slot, and a `ret` that lands at a VM entry | `vm-protector-analysis.md` — virtual eflags is data, NAND lowering, branchless select, data-anchored breakpoints, and trace-then-search-by-constant; dispatcher slicing stays in `native-vm-recovery.md` | | A native trace has no `cmp`/`sub`/`jcc` — only `and/or/not/shr/neg`, a flags slot, and a `ret` that lands at a VM entry | `vm-protector-analysis.md` — virtual eflags is data, NAND lowering, branchless select, data-anchored breakpoints, and trace-then-search-by-constant; dispatcher slicing stays in `native-vm-recovery.md` |
| The logic you need is Python bytecode — a `.pyc`/PyInstaller/Pyarmor payload rather than Java, Dart or native | `python-bytecode-recovery.md` — key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing and the extra-section TLV; static and offline, then call the recovered module | | The logic you need is Python bytecode — a `.pyc`/PyInstaller/Pyarmor payload rather than Java, Dart or native | `python-bytecode-recovery.md` — key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing and the extra-section TLV; static and offline, then call the recovered module |
| A Lua decompiler rejects every script with **`non-standard lua format: <n>`** | `unity-lua-and-assetbundles.md` §2 — a changed Lua 5.1 header byte, not encryption |
| A re-signed Unity/Mono build exits cleanly with code 4 about two seconds in, with no Java exception | `unity-lua-and-assetbundles.md` §5 — a publisher shell owns the process |
## Gates — clear these before you patch, in order ## Gates — clear these before you patch, in order
@@ -250,7 +250,7 @@
"docs/tool-verification/EXTENSION-benchmark-l1-l3.md section 3 (repository root, not shipped)", "docs/tool-verification/EXTENSION-benchmark-l1-l3.md section 3 (repository root, not shipped)",
"tests/benchmark.md row B2 (repository root, not shipped)" "tests/benchmark.md row B2 (repository root, not shipped)"
], ],
"limits": "The tooling works; the patch does not. Writes landed 0.04-0.05 s after resume and survived detach, and the patched run and a read-and-write-back control both still died with SIGABRT at the same site: neutralising the terminate routine plus both of its branch inputs was insufficient, and the region is a dense cluster of mov w0,#imm ; ret stubs. Holding the process paused until the patch lands structurally cannot work, because a frozen process has no libraries mapped. On that target the pristine original already reports tamper, so no clean baseline exists there. No surviving-target result is claimed." "limits": "The tooling works; the patch does not. Writes landed 0.04-0.05 s after resume and survived detach, and the patched run and a read-and-write-back control both still died with SIGABRT at the same site: neutralising the terminate routine plus both of its branch inputs was insufficient, and the region is a dense cluster of mov w0,#imm ; ret stubs. Holding the process paused until the patch lands structurally cannot work, because a frozen process has no libraries mapped. On that target the pristine original already reports tamper, so no clean baseline exists there. No surviving-target result is claimed. Site selection is a separate claim: the predicate-first rule and the tiered grading (added 2026-10-25) are absorbed from a write-up and unverified here -- no graded patch set was run, and the ordering judgement is inferred."
}, },
{ {
"capability": "native-instruction-tracing-stalker", "capability": "native-instruction-tracing-stalker",
@@ -654,7 +654,7 @@
"evidence_not_shipped": [ "evidence_not_shipped": [
"docs/tool-verification/README.md (repository root, not shipped)" "docs/tool-verification/README.md (repository root, not shipped)"
], ],
"limits": "The offline candidate path from an APK and the authoritative live read are both documented in the reference; neither has a public-target measurement here. The failure shape is a rebuilt APK that installs, launches, and then fails every signed request, which is easy to report as a server problem and is not one." "limits": "The offline candidate path from an APK and the authoritative live read are both documented in the reference; neither has a public-target measurement here. The failure shape is a rebuilt APK that installs, launches, and then fails every signed request, which is easy to report as a server problem and is not one. A second variant -- a certificate-derived salt concatenated inside the digest, invisible to any black-box search -- is documented from the same 2026-10-25 write-up and likewise unmeasured."
}, },
{ {
"capability": "blocked-react-native-ios", "capability": "blocked-react-native-ios",
@@ -982,6 +982,54 @@
], ],
"limits": "Parsing of all three recovery sources (@DebugMetadata c=, @Metadata d2 first non-stdlib descriptor, jadx 'renamed from' comments), the third-party skip list and the map-file round trip are observed on embedded fixtures only. The upstream recovery-rate claims (30-50% of classes overall, ~100% of *Repository/*ViewModel/*Impl, ~80% of data-class DTOs) are unverified here: no real obfuscated Kotlin app was run through the script. Method and field names are never recovered; heavily inlined shapes can surface under a wrong primary class, so every mapping row is a hint. The script reads decompiled sources, not the dex: a decompiler that drops annotations removes the source entirely." "limits": "Parsing of all three recovery sources (@DebugMetadata c=, @Metadata d2 first non-stdlib descriptor, jadx 'renamed from' comments), the third-party skip list and the map-file round trip are observed on embedded fixtures only. The upstream recovery-rate claims (30-50% of classes overall, ~100% of *Repository/*ViewModel/*Impl, ~80% of data-class DTOs) are unverified here: no real obfuscated Kotlin app was run through the script. Method and field names are never recovered; heavily inlined shapes can surface under a wrong primary class, so every mapping row is a hint. The script reads decompiled sources, not the dex: a decompiler that drops annotations removes the source entirely."
}, },
{
"capability": "native-dump-window-and-syscall-reader",
"group": "native",
"status": "partial",
"route_measured": false,
"strength": "unverified",
"benchmark_rows": [],
"evidence": [
"references/linker-and-soinfo-repair.md",
"references/advanced-unpacking.md"
],
"evidence_not_shipped": [
"ref/vm1.md (repository root, git-ignored, not shipped): 2026-10-25 write-up on a dual-library commercial shell"
],
"limits": "Operating rules only, absorbed 2026-10-25 and never exercised here: the dump window that closes inside JNI_OnLoad when self-decryption and watchdog startup share that function, the raw-syscall reader that stays outside a self-hooked libc, and zero-filling unreadable pages so segment offsets survive repair. The zero-fill/offset consequence is observed on a synthetic three-page image (marker at 8199 zero-filled, 4103 skipped); the window, the reader and the target behaviour are unverified, and the placement rule is inferred from the linker arithmetic."
},
{
"capability": "whitebox-crypto-devirtualization-to-program",
"group": "native-dynamic",
"status": "partial",
"route_measured": false,
"strength": "unverified",
"benchmark_rows": [],
"evidence": [
"references/native-vm-recovery.md",
"references/vmp-differential-analysis.md"
],
"evidence_not_shipped": [
"ref/vm2.md (repository root, git-ignored, not shipped): 2026-10-25 write-up on a white-box VM protecting one signing routine"
],
"limits": "The route -- symbolic input, constant folding, loop and branch elimination, an (op, args) straight-line program plus its constant table, output map and output template -- is absorbed from one write-up and never run. It applies only to a deterministic, input-driven function: device id, time or nonce inputs become captured constants, and the claim then degrades to reproducing one device. The program is version-bound; no extract was produced here."
},
{
"capability": "cipher-classification-by-differential-probe",
"group": "protocol",
"status": "partial",
"route_measured": false,
"strength": "inferred",
"benchmark_rows": [],
"evidence": [
"references/protocol-reverse.md",
"references/signature-derived-keys.md"
],
"evidence_not_shipped": [
"ref/vm3.md (repository root, git-ignored, not shipped): 2026-10-25 write-up on a native signer and an encrypted request body"
],
"limits": "Three black-box probes -- header length, output determinism, and one-byte diffusion width, plus the length law -- the involution-wrapper algebra, and Java-versus-Python encoding plus compression drift. Host-checked on AES-128 through openssl and on synthetic inputs: the probes separate CTR, CBC and ECB (1 / all-following / one block changed per flipped byte), the mask identity has zero counterexamples over 65,536 eight-bit pairs and 200,000 random 16-bit pairs, the length law holds for b=16, and zlib levels 1 and 9 emit different valid streams for one payload. The probe this row originally described (prefix XOR implies a stream cipher) was falsified by that run -- CBC and ECB also show zero prefix-XOR at a fixed IV -- and the reference now carries the corrected discriminator. No target body was classified, and no server was tested for whether it compares compressed bytes or only the decompressed payload."
},
{ {
"capability": "websocket-long-connection-analysis", "capability": "websocket-long-connection-analysis",
"group": "protocol", "group": "protocol",
@@ -996,6 +1044,73 @@
"715494637/reverse-skill (no license file): jsr-reverse/references/protocol-and-long-connection.md -- methodology only absorbed 2026-10-20, no text copied" "715494637/reverse-skill (no license file): jsr-reverse/references/protocol-and-long-connection.md -- methodology only absorbed 2026-10-20, no text copied"
], ],
"limits": "The state-chain method (capture handshake, first business frame, heartbeat/ack, renewal, error; record the connection as a dependency chain; separate message families; split envelope from payload before body semantics) is absorbed from a browser-WebSocket reference and was never run on an Android long-connection target here. The Android capture points in the section (OkHttp WebSocket listener surfacing, native/QUIC transports never transiting Java) are inferred from documented APIs, not measured. Frame bodies that are protobuf do inherit the measured schema-free decoder from protocol-reverse.md section 1; that is the only measured part of the route." "limits": "The state-chain method (capture handshake, first business frame, heartbeat/ack, renewal, error; record the connection as a dependency chain; separate message families; split envelope from payload before body semantics) is absorbed from a browser-WebSocket reference and was never run on an Android long-connection target here. The Android capture points in the section (OkHttp WebSocket listener surfacing, native/QUIC transports never transiting Java) are inferred from documented APIs, not measured. Frame bodies that are protobuf do inherit the measured schema-free decoder from protocol-reverse.md section 1; that is the only measured part of the route."
},
{
"capability": "il2cpp-managed-layer-bytecode-vm",
"group": "runtime",
"status": "partial",
"route_measured": false,
"strength": "unverified",
"benchmark_rows": [],
"evidence": [
"references/unity-runtime.md",
"references/native-vm-recovery.md",
"references/vmp-differential-analysis.md"
],
"evidence_not_shipped": [
"ref/unity12.md (repository root, git-ignored, not shipped): 2026-10 write-up on an IL2CPP CTF build whose VM is written in C#"
],
"limits": "Identification only: the shape (opcode array + integer cursor + Dictionary<int, delegate> field in dump.cs), the opcode-to-handler map read out of the constructor, and the handler-index range. Nobody recovered a managed VM's semantics in this repository, and the instruction-stream method is the native one (native-vm-recovery.md section 11) applied to a stream read statically. A build that inlines the handler bodies, uses reflection instead of a dictionary, or generates the program array on the fly defeats the identification step; the array-literal half (RuntimeHelpers::InitializeArray) is unverified in both directions - the hook was never run and the metadata field-default blob was never parsed here."
},
{
"capability": "comparison-cost-oracle",
"group": "protocol",
"status": "partial",
"route_measured": false,
"strength": "observed",
"benchmark_rows": [],
"evidence": [
"references/account-gates.md",
"references/vm-protector-analysis.md"
],
"evidence_not_shipped": [
"ref/vmp1.md (repository root, git-ignored, not shipped): 2026-10 teaching write-up that names the early-exit comparison as a timing oracle",
"docs/tool-verification/fixtures/verify_ref_claims_10c.py and EXTENSION-ref-absorption-2026-10c.md section Verification pass (repository root, not shipped)"
],
"limits": "The measured half is host-side and synthetic: an early-exit byte compare costs k+1 comparisons for a k-byte correct prefix over k=0..8 while an MD5-then-compare costs a constant 16, so the closed and open cases are separable without a target. Nothing was run against a real serial, licence or activation gate. Reading the comparator's counter requires a hook on the comparison itself; wall-clock timing on a device is not the measured form and is expected to be dominated by scheduler and JIT noise. A remote check is a rate-limited network experiment and a value the server also holds is not releaseable client-side, so the route stops at local gates."
},
{
"capability": "unity-lua-and-assetbundle-recovery",
"group": "unpacking",
"status": "partial",
"route_measured": false,
"strength": "unverified",
"benchmark_rows": [],
"evidence": [
"references/unity-lua-and-assetbundles.md",
"references/unity-runtime.md",
"references/repack-and-sign.md"
],
"evidence_not_shipped": [
"game-reserve/ (repository root, untracked, not shipped): anonymised Unity + Lua and Unity Mono + SLua case reports; absorbed 2026-11-09"
],
"limits": "Absorbed only: locating a Lua container on top of Unity, header-byte repair, loader bytecode-only check, bundle CRC source, UnityFS partial-encryption windowing, UnityFS rebuild traps (layout loss, dependency null, compressed==raw), added/replaced TextAsset read-back, and half-encrypted Mono assemblies behind a publisher shell. No Unity package was decrypted, no bundle rebuilt and no assembly reconstructed here; every route is unverified. It assumes the Lua bytecode opcodes are not shuffled and that the bundle's container format is one UnityPy can parse."
},
{
"capability": "layaair-conch-dcc-recovery",
"group": "runtime",
"status": "partial",
"route_measured": false,
"strength": "unverified",
"benchmark_rows": [],
"evidence": [
"references/framework-runtimes.md",
"references/recon.md"
],
"evidence_not_shipped": [
"game-reserve/ (repository root, untracked, not shipped): anonymised LayaAir native + JS case report and DCC notes; absorbed 2026-11-09"
],
"limits": "Absorbed only: Conch identification, the path-addressed cache layout, the DCC filetable checksum (8-byte little-endian word XOR plus tail), regenerating the four metadata files from shipped content, and the loader patch plus its startup-delay race. No LayaAir package was reversed here, and the checksum was reverse-engineered by the source against its own package, not measured in this repository."
} }
] ]
} }
@@ -115,7 +115,12 @@ built on them has nothing to check itself against.
- **No real OLLVM trace and no trace pipeline verified on a device.** Exclusion keeps a target alive - **No real OLLVM trace and no trace pipeline verified on a device.** Exclusion keeps a target alive
but does not restore event delivery, and a zero-event trace is a boundary to identify rather than a but does not restore event delivery, and a zero-event trace is a boundary to identify rather than a
recipe to follow. recipe to follow.
- **The Unity + Lua / AssetBundle and LayaAir Conch routes were never exercised here.** The Lua
header repair, bundle CRC selection, UnityFS partial-encryption windowing, bundle rebuild traps,
TextAsset read-back, half-encrypted Mono assemblies and the LayaAir DCC checksum are absorbed from
two public case reports; no Unity or LayaAir package was decrypted, rebuilt or installed in this
repository. Treat every step in `references/unity-lua-and-assetbundles.md` and
`references/framework-runtimes.md` §LayaAir native (Conch) specifics as `unverified`.
## Conclusions that changed — an older copy may still state the old one ## Conclusions that changed — an older copy may still state the old one
Each of these was a claim this skill used to make and no longer does. If you are reading a copy or a Each of these was a claim this skill used to make and no longer does. If you are reading a copy or a
@@ -83,6 +83,42 @@ Watch for a **"skip"/"later" path the app already has**, and for **which actions
gates**. Binding is often required for a subset (password change, deletion, payment) while the rest of gates**. Binding is often required for a subset (password change, deletion, payment) while the rest of
the app is unaffected; releasing it globally changes what the app believes about account safety. the app is unaffected; releasing it globally changes what the app believes about account safety.
## Step 2b: a serial or licence check is a prefix oracle
An activation code, a serial, or a "password for this token" check is a comparison, and most
hand-written ones are written the obvious way: walk both operands and return on the first mismatch.
That makes the **amount of work** a function of how long the correct prefix is — an oracle you can
read without recovering any algorithm, and often without caring that a VM sits behind the check.
Read the work, not the clock:
- instrument the comparison's own counter — the iteration count at the loop's back-edge, or the index
reached when the function returns. That number is deterministic. Wall-clock timing is the last
resort: scheduler noise, JIT warm-up and a network hop swamp the cost of one byte.
- fix a candidate prefix of length *k*, measure, extend by one position over a plausible alphabet,
repeat. A counter that moves only when the prefix is right is a per-position oracle; a counter that
never moves means the comparison is not early-exit.
- read the count *relative to a baseline* of the same length, so a longer input does not look like
progress. (`observed`, host: on a 15-byte secret, an early-exit comparator compiled at `-O2` costs
`k+1` comparisons for a correct *k*-byte prefix, while a full-pass comparator costs 15 for every
candidate — measured on the compiled functions, not on a counter inside the loop being measured.
See the EXTENSION record.)
**The mirror rule decides whether the algorithm matters at all.** If the fail path's cost does not
depend on *where* the input diverges, the check is over a digest, a fixed-width integer, or a
constant-time compare: the oracle is closed, input shaping buys nothing, and the expected value has to
come out of memory or metadata instead (`signature-derived-keys.md` for the case where it is built
from the signing certificate). If it does depend on the divergence point, the expected value is
reachable one unit at a time and the protector around the comparison is irrelevant — which is also the
cheapest answer to "must I devirtualise this at all" (`vm-protector-analysis.md`).
Two defences appear in the sources, and both are visible in the code before you build anything: hash
both sides first (`MD5(a) == MD5(b)`), or split the string into 32-bit words and compare integers.
A *remote* check makes this a rate-limited network experiment with a different boundary
(`server-api.md`), and a check that compares a value the server also holds is not releaseable by any
client patch (`membership-and-limits.md`). Keep the oracle work on a local gate.
## Step 3: what NOT to do ## Step 3: what NOT to do
These are the tempting moves that produce a worse artifact than doing nothing: These are the tempting moves that produce a worse artifact than doing nothing:
@@ -114,7 +114,10 @@ its own strength note at the top.
- **Instruction-level tracing and de-obfuscation** — the OLLVM shapes, a Stalker trace, the - **Instruction-level tracing and de-obfuscation** — the OLLVM shapes, a Stalker trace, the
trace-to-CFG route, and the measured boundaries in `native-dbi-and-deobfuscation.md`. trace-to-CFG route, and the measured boundaries in `native-dbi-and-deobfuscation.md`.
- **Protocol reversing beyond REST** — protobuf without a schema, gRPC frame capture, the QUIC/HTTP3 - **Protocol reversing beyond REST** — protobuf without a schema, gRPC frame capture, the QUIC/HTTP3
limit, native-side certificate pinning (`protocol-reverse.md`). limit, native-side certificate pinning, and — for an opaque body — classifying the primitive by
differential probes (header length, determinism, diffusion width, the length law) before implementing
it
(`protocol-reverse.md`).
- **What to do when userspace hooking provably cannot reach the check** — raw `svc` syscalls, - **What to do when userspace hooking provably cannot reach the check** — raw `svc` syscalls,
`init_array`-early detection, and the kernel-route map with its version gate `init_array`-early detection, and the kernel-route map with its version gate
(`kernel-and-environment-hardening.md`). (`kernel-and-environment-hardening.md`).
@@ -136,8 +139,22 @@ its own strength note at the top.
(`scripts/vm_handler_slice.py`). (`scripts/vm_handler_slice.py`).
- **Native VM recovery procedure** — the full method (dispatcher-layer separation, register - **Native VM recovery procedure** — the full method (dispatcher-layer separation, register
anchoring with triple verification, nested segment stacks, STORE-backward slicing, clean-re-VM anchoring with triple verification, nested segment stacks, STORE-backward slicing, clean-re-VM
validation) absorbed from two public write-ups; every step `inferred`, none run here validation) plus a devirtualization end state that emits a runnable straight-line program with its
(`native-vm-recovery.md`). constant table, output map and template; absorbed from public write-ups, every step `inferred` and
none run here (`native-vm-recovery.md`).
- **A VM written in the managed layer** — IL2CPP builds whose interpreter is C#: the `dump.cs` shape
(opcode array + cursor + `Dictionary<int, delegate>`), the opcode→handler map read out of the
constructor, and array literals materialised by `RuntimeHelpers::InitializeArray` rather than stored
in `.rodata`; identified only, no managed VM was recovered here (`unity-runtime.md`,
`native-vm-recovery.md`).
- **Comparison gates as prefix oracles** — instrument the comparator's own counter, grow the prefix one
position at a time, and decide from the fail-path cost whether the oracle is open (early exit) or
closed (digest / fixed-width / constant-time). The cost separation is host-measured on synthetic
compares; no real gate was attacked, and a remote check is a different, rate-limited experiment
(`account-gates.md`).
- **Pyarmor builds that wrap the whole file** — three nonce scopes (outer container, per code object,
per string) sharing one master key, and why a live dump is structurally incomplete; the
counter-mode half is host-measured, the layering itself is absorbed (`python-bytecode-recovery.md`).
- **JS VMP (jsvmp) recovery** — reading logic protected as a private JS opcode stream: recognition - **JS VMP (jsvmp) recovery** — reading logic protected as a private JS opcode stream: recognition
signals, the call-it-first route (AST restore + environment fill), stack- and register-machine signals, the call-it-first route (AST restore + environment fill), stack- and register-machine
reading procedures, AST instruction extraction with register/immediate typing, the four reading procedures, AST instruction extraction with register/immediate typing, the four
@@ -180,8 +197,10 @@ its own strength note at the top.
- **Linker-level SO unpacking and `soinfo` repair** — the `dlopen` pipeline as a loader - **Linker-level SO unpacking and `soinfo` repair** — the `dlopen` pipeline as a loader
specification, `load_bias` and segment arithmetic including `seg_page_offset`, `DT_*` parsing, specification, `load_bias` and segment arithmetic including `seg_page_offset`, `DT_*` parsing,
relocation targets and the defining-library-versus-caller bias, the minimal `soinfo` repair set, relocation targets and the defining-library-versus-caller bias, the minimal `soinfo` repair set,
anti-dump header XOR detected by ELF invariants, and the dump window at `LoadSegments`. Source- anti-dump header XOR detected by ELF invariants, the dump window at `LoadSegments`, the narrower
reading synthesis plus a Frida cookbook; no loader was reimplemented here window that closes inside `JNI_OnLoad` when self-decryption and watchdog startup share that
function, a raw-syscall reader outside a self-hooked libc, and zero-filled unreadable pages.
Source-reading synthesis plus two write-ups; no loader was reimplemented here
(`linker-and-soinfo-repair.md`). (`linker-and-soinfo-repair.md`).
- **VM protector analysis** — envelope triage, VM_DATA/VM_CONTEXT/vEIP/vStack anatomy, data-anchored - **VM protector analysis** — envelope triage, VM_DATA/VM_CONTEXT/vEIP/vStack anatomy, data-anchored
breakpoints, forged-return recognition, trace-then-search-by-constant, virtual eflags as writable breakpoints, forged-return recognition, trace-then-search-by-constant, virtual eflags as writable
@@ -201,7 +220,17 @@ its own strength note at the top.
(`kernel-event-injection.md`, `scripts/kernel_instrument_scaffold.py`). (`kernel-event-injection.md`, `scripts/kernel_instrument_scaffold.py`).
- **Working from the phone itself** — MT Manager, its APK MCP surface, LSPosed Manager, on-device - **Working from the phone itself** — MT Manager, its APK MCP surface, LSPosed Manager, on-device
data inspection (`on-device-tooling.md`, `scripts/mt_mcp_probe.py`). data inspection (`on-device-tooling.md`, `scripts/mt_mcp_probe.py`).
- **Unity + Lua and AssetBundle recovery** — finding a Lua container on top of Unity, repairing the
Lua 5.1 header byte, checking the loader's bytecode-only flag, reading the CRC manifest the game
actually reads, bounding a partial-encryption window, rebuilding a UnityFS bundle without losing
its layout or dependency edges, verifying added/replaced TextAsset read-back, and reading
half-encrypted Mono assemblies behind a publisher shell. Absorbed from two anonymised case reports;
no package was decrypted or bundle rebuilt here, so every step is `unverified`
(`unity-lua-and-assetbundles.md`).
- **LayaAir native (Conch) DCC recovery** — Conch identification, the path-addressed cache, the
filetable checksum, regenerating metadata from shipped content, and the loader patch with its
startup-delay race. Absorbed from one case report; no LayaAir package was reversed here
(`framework-runtimes.md` §LayaAir native (Conch) specifics).
## Dependencies this skill does not ship — name them before the workflow starts ## Dependencies this skill does not ship — name them before the workflow starts
- **JS AST rewriting needs node + babel** (`@babel/parser`/`traverse`/`generator`) — the detector - **JS AST rewriting needs node + babel** (`@babel/parser`/`traverse`/`generator`) — the detector
@@ -26,6 +26,7 @@ the evidence record condensed in `references/evidence-summary.md` §Where the fu
| Flutter / Dart AOT | analysing and patching `libapp.so` **given a snapshot dump** | `dart-aot.md` | | Flutter / Dart AOT | analysing and patching `libapp.so` **given a snapshot dump** | `dart-aot.md` |
| Runtime and server side | Frida analysis, API probing, feature-scoped TLS failures, update/forced-upgrade neutralisation | `dynamic-frida.md`, `server-api.md`, `tls-and-cert.md`, `updates-and-forced-upgrade.md` | | Runtime and server side | Frida analysis, API probing, feature-scoped TLS failures, update/forced-upgrade neutralisation | `dynamic-frida.md`, `server-api.md`, `tls-and-cert.md`, `updates-and-forced-upgrade.md` |
| Verification discipline | the claim ladder, control builds, capture-and-look, bounded waits | `verification.md`, `long-task-discipline.md` | | Verification discipline | the claim ladder, control builds, capture-and-look, bounded waits | `verification.md`, `long-task-discipline.md` |
| A comparison gate as an oracle | instrument the comparator's own counter (not the clock), grow the correct prefix one position at a time, and read the fail-path cost to decide whether the oracle is open or the check is over a digest — host-measured on synthetic compares, no real gate attacked | `account-gates.md` |
## Also covered, by documented routes — mostly *inferred* rather than measured ## Also covered, by documented routes — mostly *inferred* rather than measured
@@ -52,15 +53,20 @@ route was not measured on this repository's evidence**. Treat them as leads with
| JS AST pre-deobfuscation | family detection + per-family pass order + safe-rewrite rules; detector shipped and fixture-tested, rewriting needs node+babel (not shipped) — `js-ast-deobfuscation.md`, `js_obf_detect.py` | | JS AST pre-deobfuscation | family detection + per-family pass order + safe-rewrite rules; detector shipped and fixture-tested, rewriting needs node+babel (not shipped) — `js-ast-deobfuscation.md`, `js_obf_detect.py` |
| Kotlin original-name recovery | obfuscated→original class map from `@DebugMetadata`/`@Metadata` in any jadx export; parsing fixture-tested, recovery rates upstream-claimed — `kotlin-name-recovery.md`, `kotlin_name_recovery.py` | | Kotlin original-name recovery | obfuscated→original class map from `@DebugMetadata`/`@Metadata` in any jadx export; parsing fixture-tested, recovery rates upstream-claimed — `kotlin-name-recovery.md`, `kotlin_name_recovery.py` |
| Long-connection (WebSocket) analysis | state chains, message families, envelope/payload split — absorbed methodology, never run on an Android target here — `protocol-reverse.md` | | Long-connection (WebSocket) analysis | state chains, message families, envelope/payload split — absorbed methodology, never run on an Android target here — `protocol-reverse.md` |
| Unity (Mono and IL2CPP) | backend identification, Il2CppDumper over `libil2cpp.so` + `global-metadata.dat`, the IDA import order, a run-time lookup over frida-il2cpp-bridge, the dnSpy-Unity-mono patch — absorbed, nothing run here — `unity-runtime.md` | | Unity (Mono and IL2CPP) | backend identification, Il2CppDumper over `libil2cpp.so` + `global-metadata.dat`, the IDA import order, a run-time lookup over frida-il2cpp-bridge, the dnSpy-Unity-mono patch, and a VM that lives in the managed layer (opcode array + cursor + `Dictionary<int, delegate>` in `dump.cs`, handler indices from the constructor, array literals via `InitializeArray`) — absorbed, nothing run here — `unity-runtime.md` |
| Protected IL2CPP metadata | when the pair is not readable: consumer-side dump, header sizing without trusting the version, XOR/VM/XXTEA containers, the live-image dump and ELF repair — absorbed, nothing run here — `il2cpp-protected-metadata.md` | | Protected IL2CPP metadata | when the pair is not readable: consumer-side dump, header sizing without trusting the version, XOR/VM/XXTEA containers, the live-image dump and ELF repair, and the ELF fingerprint of a rebuilt `libil2cpp` (`JNI_OnLoad` / own `DT_INIT` / `SHT_LOUSER`) — absorbed, nothing run here — `il2cpp-protected-metadata.md` |
| Linker-level SO unpacking and repair | the `dlopen` pipeline as a loader spec, load_bias/segment arithmetic, `DT_*` and relocation rules, `soinfo` repair, anti-dump header XOR — source-reading synthesis, no loader reimplemented — `linker-and-soinfo-repair.md` | | Linker-level SO unpacking and repair | the `dlopen` pipeline as a loader spec, load_bias/segment arithmetic, `DT_*` and relocation rules, `soinfo` repair, anti-dump header XOR — source-reading synthesis, no loader reimplemented — `linker-and-soinfo-repair.md` |
| VM protector analysis | virtual eflags, NAND lowering, branchless select, data-anchored breakpoints and trace search by constant — absorbed from x86 VMProtect samples, never run on Android here — `vm-protector-analysis.md` | | VM protector analysis | virtual eflags, NAND lowering, branchless select, data-anchored breakpoints and trace search by constant — absorbed from x86 VMProtect samples, never run on Android here — `vm-protector-analysis.md` |
| Python bytecode / Pyarmor | key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing and the extra-section TLV — absorbed, no sample unpacked here — `python-bytecode-recovery.md` | | Python bytecode / Pyarmor | key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing, the extra-section TLV, and the outer container layer with its three nonce scopes — absorbed, no sample unpacked here; the counter-mode nonce behaviour is host-measured — `python-bytecode-recovery.md` |
| Attaching a real debugger to a `.so` | IDA `dbgsrv` with the ABI match, wait-for-debugger plus the JDWP handshake, and the `extractNativeLibs="false"` failure where no breakpoint binds — `ida-so-debugging.md` | | Attaching a real debugger to a `.so` | IDA `dbgsrv` with the ABI match, wait-for-debugger plus the JDWP handshake, and the `extractNativeLibs="false"` failure where no breakpoint binds — `ida-so-debugging.md` |
| Kernel-side event injection | watchpoints and register rewrites from a driver, as gated templates — `kernel-event-injection.md` | | Kernel-side event injection | watchpoints and register rewrites from a driver, as gated templates — `kernel-event-injection.md` |
| Working from the phone itself | MT Manager edit/repack/sign and its APK MCP, LSPosed Manager, Termux — `on-device-tooling.md` | | Working from the phone itself | MT Manager edit/repack/sign and its APK MCP, LSPosed Manager, Termux — `on-device-tooling.md` |
| Unity + Lua scripts and AssetBundle rebuilds | find/decrypt the Lua container, repair a Lua 5.1 header, locate the live CRC manifest, bound a partial-encryption window, rebuild a UnityFS bundle without losing layout/dependencies, verify TextAsset read-back, and recover half-encrypted Mono assemblies behind a publisher shell — absorbed from two case reports; nothing was run here — `unity-lua-and-assetbundles.md` |
| LayaAir native (Conch) DCC recovery | Conch identification, path-addressed cache, DCC filetable checksum and metadata regeneration, and the loader patch with its startup-delay race — absorbed; no LayaAir package was reversed here — `framework-runtimes.md` §LayaAir native (Conch) specifics |
| Publishing without publishing the target | the leak scanner, the do-not-anonymize list, and the graded precedent library — `desensitization-and-leak-scans.md`, `scripts/scan_leaks.py`, `precedents/` | | Publishing without publishing the target | the leak scanner, the do-not-anonymize list, and the graded precedent library — `desensitization-and-leak-scans.md`, `scripts/scan_leaks.py`, `precedents/` |
| Native dump window and syscall reader | dump at `android_dlopen_ext` entry when self-decryption and watchdog startup share `JNI_OnLoad`; read via raw syscalls; zero-fill unreadable pages so offsets survive repair — absorbed, nothing run here — `linker-and-soinfo-repair.md` |
| White-box crypto devirtualization | fold a deterministic VM transform into a straight-line `(op, args)` program plus constant table, output map and template, pinned to one build — absorbed, no extract produced — `native-vm-recovery.md` |
| Cipher classification by differential probe | header length, determinism, one-byte diffusion width and the length law separate CTR/CBC/ECB; involution wrappers cancel; encoding/compression drift is the last mile — probes host-checked on AES-128, no target classified — `protocol-reverse.md` |
## Dependencies this skill does not ship ## Dependencies this skill does not ship
@@ -257,6 +257,29 @@ shipped library. A crash frame in JIT output cannot be mapped to a file offset.
API where the framework compiles reflection at runtime, and treat "the frame has no file" as a fact API where the framework compiles reflection at runtime, and treat "the frame has no file" as a fact
about compilation, not as a hidden module. about compilation, not as a hidden module.
### Filter signals by module before believing them
A process under instrumentation produces signals that are not the target's. ART takes an implicit
`SIGSEGV` for null and bounds checks inside `boot*.oat`, `*.odex` and anonymous JIT pages, and resumes
the thread in its own handler. A deliberate crash, a protector's kill and the runtime's own fault can
all reach your observer looking identical: "signal 11". (`unverified`: documented ART behaviour plus the
source's observation — no trace of it was taken in this record.)
The tuple that discriminates is **(signal, faulting address, faulting module)**, not the signal number.
Count a signal only when the address resolves inside the library you are studying; log the rest and
let them through untouched.
Two consequences:
- **Do not install a handler that swallows what the runtime expects to handle.** ART's implicit faults
are how its null checks work; swallowing them turns a healthy process into a mysterious hang. A
handler that intercepts signals has to forward anything whose faulting module is not the target.
(`inferred`.)
- **A `boot*.oat` or `odex` frame in a crash record is the runtime's, not the shell's.** Chasing it
produces "the VM is corrupting memory" when the truth is that the VM's own fault handling ran.
(`inferred`: a consequence of the attribution rule, not a case measured here.)
### Stage 6: the precise stop, and the static alternative to it ### Stage 6: the precise stop, and the static alternative to it
**Input signal:** a named module + offset from Stage 2, Stage 3 or Stage 5. **Action:** neutralise **Input signal:** a named module + offset from Stage 2, Stage 3 or Stage 5. **Action:** neutralise
@@ -180,6 +180,32 @@ Patch spec format for `patch_smali.py`:
] ]
``` ```
### Deleting calls instead of rewriting the method
For a large lifecycle method (`onCreate`, an Application initialiser, a main-screen controller), do
not hand-write the whole body in smali. The source's native case tried that and produced two failure
classes: `VerifyError` from a `invoke-static/range` whose argument registers were placed at the
wrong end of the range, and a missing repository initialiser that surfaced later as
`lateinit property ... has not been initialized`.
The safer shape:
1. **Keep the original method body.** Remove `.line` directives only for the purpose of matching.
2. **Delete the specific calls** (network, analytics, push, billing, account) with multi-line anchors,
and assert each anchor matches exactly once.
3. **Delete the instructions that existed only to prepare that call** — the `move-object` and
`check-cast` pairs that feed its arguments. Leaving them is harmless only if their registers stay
live; removing the call and leaving a half-built argument list is how verification fails.
4. **Put new logic in a Java class** compiled with `javac` + `d8` into an extra `classesN.dex`;
the smali edit becomes one `invoke-static` line. The new class is testable on the host and does not
disturb register allocation in the original method.
5. **Find the real input point, not every consumer.** In the source's case the dead profile supplied
"current character" and "language"; changing those two getters to read local settings made the
whole default-model and greeting chain work without touching the model loader.
Verify with `dex_classdiff`, install, cold-start, and exercise the exact entry that used the deleted
call. A build that verifies can still have removed an initialiser that only one screen needs.
## Finding the call site ## Finding the call site
Reverse-lookup from a smali tree or a set of disassembled dex: Reverse-lookup from a smali tree or a set of disassembled dex:
@@ -58,6 +58,8 @@ next** — and points at the one section that says "the full record is elsewhere
| Hardware memory watchpoints (ptrace) | The encoders and refusals are host-tested and the emitted helper compiles as a static aarch64 ELF; **no watchpoint was ever armed on a device**, and the route leaves `TracerPid` visible by design | partial | unverified | `references/hardware-watchpoints.md`, `scripts/hw_watch.py` | | Hardware memory watchpoints (ptrace) | The encoders and refusals are host-tested and the emitted helper compiles as a static aarch64 ELF; **no watchpoint was ever armed on a device**, and the route leaves `TracerPid` visible by design | partial | unverified | `references/hardware-watchpoints.md`, `scripts/hw_watch.py` |
| Differential trace reduction | First divergence, divergent regions and per-side unique blocks measured on synthetic flattened-dispatcher fixtures, in both Stalker and wrapped-log grammars; no real-target producer (Stalker pair or cs_etm decode) has fed it yet | partial | observed | `references/ete-diff-tracing.md`, `scripts/trace_diff.py` | | Differential trace reduction | First divergence, divergent regions and per-side unique blocks measured on synthetic flattened-dispatcher fixtures, in both Stalker and wrapped-log grammars; no real-target producer (Stalker pair or cs_etm decode) has fed it yet | partial | observed | `references/ete-diff-tracing.md`, `scripts/trace_diff.py` |
| ETE hardware tracing | Gates and capture wrapper host-measured to the no-device boundary; no coresight capture or decode ever ran here, and `--control` exists to say so on a real device in one command | blocked | unverified | `references/ete-diff-tracing.md`, `scripts/ete_capture.py` | | ETE hardware tracing | Gates and capture wrapper host-measured to the no-device boundary; no coresight capture or decode ever ran here, and `--control` exists to say so on a real device in one command | blocked | unverified | `references/ete-diff-tracing.md`, `scripts/ete_capture.py` |
| A VM written in the managed layer (IL2CPP C#) | Identified, not recovered: opcode array + cursor + `Dictionary<int, delegate>` in `dump.cs`, handler indices read out of the constructor, array literals taken from `InitializeArray` rather than `.rodata` | partial | unverified | `references/unity-runtime.md`, `references/native-vm-recovery.md` |
| Comparison gate as a prefix oracle | Host half measured: an early-exit compare costs k+1 comparisons for a k-byte correct prefix (k=0..8) while an MD5-then-compare is constant; no serial or licence gate was attacked | partial | observed | `references/account-gates.md` |
| SPE/BRBE sampling and crash forensics | The address→symbol loop is host-verified on a real cross-compiled `.so`; SPE/BRBE mechanisms are documented-and-gated, never captured here | partial | unverified | `references/hardware-sampling-and-crash.md`, `scripts/trace_addr2sym.py` | | SPE/BRBE sampling and crash forensics | The address→symbol loop is host-verified on a real cross-compiled `.so`; SPE/BRBE mechanisms are documented-and-gated, never captured here | partial | unverified | `references/hardware-sampling-and-crash.md`, `scripts/trace_addr2sym.py` |
| Interpreter-trace de-virtualization | Dispatcher slicing, signature clustering and the opcode trajectory measured on synthetic interpreter traces; the calibration facts come from a public IR-VM's source, and no hardened binary was traced | partial | observed | `references/ete-diff-tracing.md` §5, `scripts/vm_handler_slice.py` | | Interpreter-trace de-virtualization | Dispatcher slicing, signature clustering and the opcode trajectory measured on synthetic interpreter traces; the calibration facts come from a public IR-VM's source, and no hardened binary was traced | partial | observed | `references/ete-diff-tracing.md` §5, `scripts/vm_handler_slice.py` |
| Native VM recovery procedure | The full method is absorbed from two public write-ups (dispatcher-layer separation, register anchoring with triple verification, nested segment stacks, STORE-backward slicing, clean-re-VM validation); no step was executed by this repository | partial | inferred | `references/native-vm-recovery.md` | | Native VM recovery procedure | The full method is absorbed from two public write-ups (dispatcher-layer separation, register anchoring with triple verification, nested segment stacks, STORE-backward slicing, clean-re-VM validation); no step was executed by this repository | partial | inferred | `references/native-vm-recovery.md` |
@@ -81,6 +83,11 @@ next** — and points at the one section that says "the full record is elsewhere
| Attaching IDA's debug server to a `.so` | Documented route only: ABI-matched `dbgsrv`, root server, wait-for-debugger plus the JDWP handshake that releases the process, and the `extractNativeLibs="false"` failure where no breakpoint binds. Never run here; neither source targeted a hardened app | partial | unverified | `references/ida-so-debugging.md` | | Attaching IDA's debug server to a `.so` | Documented route only: ABI-matched `dbgsrv`, root server, wait-for-debugger plus the JDWP handshake that releases the process, and the `extractNativeLibs="false"` failure where no breakpoint binds. Never run here; neither source targeted a hardened app | partial | unverified | `references/ida-so-debugging.md` |
| React Native / Hermes, iOS | Outside this skill: the runtime can be identified, the logic recovery is not covered | blocked | unverified | `references/framework-runtimes.md`, `references/coverage-and-limits.md` | | React Native / Hermes, iOS | Outside this skill: the runtime can be identified, the logic recovery is not covered | blocked | unverified | `references/framework-runtimes.md`, `references/coverage-and-limits.md` |
| Defeating a server-side authority | Out of scope by design; report it as a residual rather than patching harder | blocked | unverified | `references/server-api.md`, `references/handoff-boundaries.md` | | Defeating a server-side authority | Out of scope by design; report it as a residual rather than patching harder | blocked | unverified | `references/server-api.md`, `references/handoff-boundaries.md` |
| Native dump window and syscall reader | Absorbed operating rules: dump at `android_dlopen_ext` entry because the window closes inside `JNI_OnLoad`, a raw-syscall reader outside a self-hooked libc, and zero-filled holes so repair keeps offsets. Zero-fill offset arithmetic host-checked on a synthetic image; the window itself never exercised here | partial | unverified | `references/linker-and-soinfo-repair.md` §6.2 |
| White-box crypto devirtualization to a program | Absorbed route: symbolic input, constant folding, a straight-line `(op, args)` program plus its constant table, output map and template; version-bound, deterministic functions only. No extract was produced here | partial | unverified | `references/native-vm-recovery.md` §11 |
| Cipher classification by differential probe | Method: header length, determinism, one-byte diffusion width and the length law separate CTR, CBC and ECB (the earlier prefix-XOR-only claim was falsified and is corrected); involution wrappers cancel; Java/Python encoding and compression drift decide the last mile. Probes and algebra host-checked on AES-128 and synthetic inputs; no target body classified | partial | inferred | `references/protocol-reverse.md` §7 |
| Unity + Lua scripts and AssetBundle rebuilds | Absorbed: Locating a Lua container on top of Unity, the Lua 5.1 header-byte tamper, loader bytecode-only check, the CRC manifest the game actually reads, UnityFS partial-encryption windows, rebuild traps (layout loss, dependency null, compressed == raw), TextAsset read-back, and half-encrypted Mono assemblies behind a publisher shell. No package was decrypted or bundle rebuilt here | partial | unverified | `references/unity-lua-and-assetbundles.md` |
| LayaAir native (Conch) DCC recovery | Absorbed: Conch identification, the path-addressed cache, the DCC filetable checksum, regenerating metadata from shipped content, the loader patch, and the startup-delay race. No LayaAir package was reversed here | partial | unverified | `references/framework-runtimes.md` §LayaAir native (Conch) specifics |
## Where the full record lives — repository root, not shipped ## Where the full record lives — repository root, not shipped
@@ -18,6 +18,7 @@ Signals in the APK:
| Cordova / Ionic | `assets/www/`, `cordova.js` | | Cordova / Ionic | `assets/www/`, `cordova.js` |
| Xamarin / .NET | `libmonodroid.so`, `assemblies/` in the APK | | Xamarin / .NET | `libmonodroid.so`, `assemblies/` in the APK |
| Python (Chaquopy / Kivy / BeeWare) | `libpython3.*.so`, `assets/` with `.pyc`/`.pyz`, `pyarmor`/`__pyarmor__` bootstrap → `python-bytecode-recovery.md` | | Python (Chaquopy / Kivy / BeeWare) | `libpython3.*.so`, `assets/` with `.pyc`/`.pyz`, `pyarmor`/`__pyarmor__` bootstrap → `python-bytecode-recovery.md` |
| Python compiled away (Nuitka / Cython / `pyd`) | `libpython3.*.so` **or** a bare CPython dependency, no `.pyc`/`.pyz` anywhere, and `PyInit_*` exports in a target `.so` → the bytecode route has no input; the bodies are native (`native-and-so.md`) |
A `classes.dex` that is small relative to the total payload is another strong hint that the real code A `classes.dex` that is small relative to the total payload is another strong hint that the real code
lives elsewhere. lives elsewhere.
@@ -92,6 +93,49 @@ workflow, and how to patch this layer safely.
- **The metadata can be encrypted while the `.so` is not, or the reverse.** Check each file's magic - **The metadata can be encrypted while the `.so` is not, or the reverse.** Check each file's magic
before concluding the dump failed; the two failures have different routes. before concluding the dump failed; the two failures have different routes.
## LayaAir native (Conch) specifics
LayaAir's native shell is a recognisable shape: `lib/<abi>/liblayaair.so` plus `libv8*.so`, a
`assets/scripts/` directory (`index.js`, `apploader.js`, `config.js`), an `assets/config.ini`,
and a cache tree `assets/cache/https.__<host>_<path>/`. If those are present, the game logic is
JavaScript and the engine is Conch, not a WebView.
- **Cache file names are content-addressed by path, not by content:** each relative path (leading `/`)
is named `'%08x' % crc32(path)`. The same directory holds `allfiles.txt`, `filetable.txt`,
`filetable1.txt`, `filetable.bin` and `assetsid.txt`.
- **The game's logic is usually one plaintext compressed file:** `js/bundle.js`. Before reversing it,
fetch `js/bundle.js.map` from the same CDN path if it exists — in the source's project it contained
470 TypeScript source files, which is the source, not a reconstruction.
- **DCC checksums are recomputed by the engine, not trusted from the table.** `filetable.txt` is a
`ffeeffee 1` header, the assets id split over two lines, then one `fileid chksum` line per file.
The checksum is XOR over 8-byte blocks of little-endian `uint32` words, with the remaining 0–7
bytes XORed individually. The source matched 8,940 of 8,943 files. The engine recomputes it from the
file's content; a mismatch makes it re-download, so offline it fails with
`JsAppCache::loadCachedURL Error, no cache data` or `Load start url error`.
- **Do not copy the CDN's file table.** The source found its values inconsistent with the file contents
(same content, different checksum). Recompute every checksum from the bytes you are shipping and
regenerate all four metadata files, then `bundle.js` can be edited freely.
- **The loader is plain JS and lives outside the cache** (`index.js` under `assets/scripts/`). It calls
`updateDcc()`; offline that fails and, if a cached id exists, the app exits with
`onLayaInitError`. Patch the loader to skip the update but **re-create the side effect it had**:
`cache.setResourceID('appurl', urlpath)`. Then keep a delay of roughly three seconds before
starting: in the source, the network update had been hiding a startup race, and an instant start
crashed in `JCScriptRuntime::dispatchLayaGLBuffer` on the GL thread (x86 and arm), with or without
any offline JS module. Prove it with a control build that contains only the loader patch.
- **`loadLib()` is asynchronous.** A hook installed before `loadLib('js/bundle.js')` returns sees no
`Laya` object; poll until the engine exists, then install the hook.
- **A local module is loaded by `require("offline_server")`**, which Conch resolves from
`assets/scripts/`, the same way the game's own modules load.
**Failure shape to remember:** one uncaught exception in a Laya render callback freezes the game,
because the main loop is `requestAnimationFrame(loop)` and an exception stops the next frame. The
symptom is a frozen or black screen while the debug channel still answers; the check is
`Laya.timer.currFrame` not increasing. Wrapping `Laya.stage._loop` in try/catch is a diagnostic
guard, not a fix for the underlying null asset. Mocked XHR responses can also poison a pooled
`HttpRequest` instance — clear the own properties you defined in `open()` or every later request
on that instance fails instantly. These are engine-side behaviours from the source's case, not
measured here.
## Locating logic without symbols ## Locating logic without symbols
- **Strings first.** User-visible text (dialog bodies, feature labels) is the cheapest anchor in any - **Strings first.** User-visible text (dialog bodies, feature labels) is the cheapest anchor in any
@@ -6,9 +6,10 @@ it so. `dynamic-frida.md` owns hooking; `hardware-watchpoints.md` owns observati
attached at all; this file owns the debug-server route and the two preconditions that decide whether attached at all; this file owns the debug-server route and the two preconditions that decide whether
it works. it works.
**Claim strength.** Absorbed from two public walkthroughs (2024-07, plus a MuMu-emulator note), both **Claim strength.** Absorbed from three public walkthroughs (2024-07, plus a MuMu-emulator note and
against CTF apps that were already debuggable, and neither reproduced here. Commands on which the two a 2026 Unity session), all against CTF apps that were already debuggable, and none reproduced here.
agree are stated plainly; the single-source details are marked *unverified*; anything this file adds The debugger-side signal policy in §8 is one source's account, `unverified`. Commands on which the
sources agree are stated plainly; the single-source details are marked *unverified*; anything this file adds
as judgement is marked *inferred*. as judgement is marked *inferred*.
## 1. Two manifest facts decide everything ## 1. Two manifest facts decide everything
@@ -127,9 +128,31 @@ discipline as `long-task-discipline.md` §single-variable discipline, applied to
- `am start -D` is visible to the platform and puts the process in a debuggable state that the app can - `am start -D` is visible to the platform and puts the process in a debuggable state that the app can
query, so "the app behaves differently only while I debug it" is a real observation, not a mistake. query, so "the app behaves differently only while I debug it" is a real observation, not a mistake.
## 8. Boundary ## 8. Stops that are the debugger's, not the target's
Both sources are emulator or AVD walkthroughs on CTF apps with `debuggable` already set; neither Most "the target crashed" observations in a debug session are properties of the debugger's own
settings. Three that cost a whole session:
- **A platform signal is not target logic.** A Unity-backed app under IDA repeatedly stops on
`SIGPWR`/`SIGXCPU`-class signals it never handles, because the platform raises them and the app
ignores them. With the default *suspend on this signal* the pause **is** the crash: the process is
stopped somewhere it cannot make progress, the watchdog or runtime aborts, and the abort takes IDA
down with it. Set those signals to *pass to application* (report on log or silent). After that the
same signal costs a log line instead of a session, and the only thing that changed was your
debugger.
- **One database per activity.** Attaching and detaching from the database you used for static
analysis tends to hang on exit or leave it unusable — and the annotations are the expensive part.
Copy the database (or keep a separate debug-only one) and leave the static one read-only.
- **Interacting with a paused process is input injection.** Clicking around the app while it is
stopped delivers real input into the frozen process and reproduces the same hang/crash class.
Resume, then interact; do not "help" a suspended app.
Nothing here is about anti-debug: if the process dies while it is *stopped*, suspect the debugger's
signal policy before suspecting the target.
## 9. Boundary
All three sources are emulator or AVD walkthroughs on CTF apps with `debuggable` already set; none
exercised a hardened target, and this record did not run the route at all. `unverified`: the exact exercised a hardened target, and this record did not run the route at all. `unverified`: the exact
`dbgsrv` filenames per IDA release, the `chmod` mode, the debugger menu labels across 7.x and 8.x, and `dbgsrv` filenames per IDA release, the `chmod` mode, the debugger menu labels across 7.x and 8.x, and
whether an on-disk `.so` outranks the in-APK copy on a hardened build. What would make the route whether an on-disk `.so` outranks the in-APK copy on a hardened build. What would make the route
@@ -40,6 +40,27 @@ embeds the metadata in the `.so` with the rest of the header intact.
**A 0-byte metadata file is a positive finding, not a missing file.** It means the build does not **A 0-byte metadata file is a positive finding, not a missing file.** It means the build does not
use the file at all, so a static decryptor has nothing to decrypt. Look for the loader's output. use the file at all, so a static decryptor has nothing to decrypt. Look for the loader's output.
### 1.1 A rebuilt `libil2cpp` announces itself in the ELF tables
One build's own triage script flags three things before it parses anything: a `JNI_OnLoad` export, a
`DT_INIT`/`init_array` of the library's own, and an `SHT_LOUSER` section. None of the three is
something the engine's build path needs, so any of them is a candidate added step — read them as
heuristics, where a false positive costs one `readelf`:
```bash
readelf -sW libil2cpp.so | grep -i jnionload
readelf -dW libil2cpp.so | grep -Ei 'INIT|FINI'
readelf -SW libil2cpp.so | grep -w LOUSER # a section type, not a name
```
`JNI_OnLoad` means the library wants a JVM-side entry point, which is a JNI-sinking or loader shape
rather than something the engine itself calls through. An own `DT_INIT`/`init_array` is the earliest
place arbitrary code can run. `SHT_LOUSER` is a section the
linker reserves for the application — a convenient place to park a payload, and a common marker in
this family. Read these tables **before** hunting ciphertext: the injected entry is where metadata and
code are decrypted, and it is also what a dumper's "this file may be protected" refusal is reacting to.
Then continue at §2 and anchor on the consumer rather than the file.
## 2. Anchor on the consumer, not the path ## 2. Anchor on the consumer, not the path
The reliable address is the pointer *after* decryption and de-obfuscation. Two anchors exist, and The reliable address is the pointer *after* decryption and de-obfuscation. Two anchors exist, and
@@ -77,7 +98,10 @@ i -= 8
``` ```
This works when magic and version are zeroed, and it survives a version mismatch because it uses This works when magic and version are zeroed, and it survives a version mismatch because it uses
only offset/count pairs that are still laid out in the same order. Bound the loop (for example only offset/count pairs that are still laid out in the same order. (`observed`, host: on a synthetic
header whose magic and version are zeroed and whose tail counts are zero, the walk returns the true
length `0x1140` while a fixed mid-header pair returns `0x1098`; see
`docs/tool-verification/fixtures/verify_ref_claims_10c.py`.) Bound the loop (for example
`i > 0`), wrap reads in the platform's fault handler on Windows, and treat a non-monotone result as `i > 0`), wrap reads in the platform's fault handler on Windows, and treat a non-monotone result as
"this is not the header you think it is", not as a size. "this is not the header you think it is", not as a size.
@@ -131,6 +155,16 @@ self-describing container**. Dump the program table, name each case by its effec
program in Python. Do not single-step the VM instruction by instruction in a debugger; the table program in Python. Do not single-step the VM instruction by instruction in a debugger; the table
is the specification. is the specification.
**Read the call site before replaying, because the schedule decides what a unit test is.** One build
runs the interpreter once per fixed-size block — `apply(program, 0x40, table, out + i, min(0x40,
remaining))` in a loop — with the same constant table re-passed on every call and no state carried
between them. That makes one block a complete test: decrypt block 0, check the result against the
plaintext you already know it must contain (a magic, or the first string), and only then run the rest.
If the call site instead updates a context between iterations, the blocks are chained: no per-block
shortcut exists, replay must start at 0, and a mismatch at block 7 is a key/program error you cannot
localise by looking at block 7. The truncated tail is also worth reading explicitly, because a tail
handled as a full block shifts everything after the last boundary.
### 3.3 XXTEA with a length word ### 3.3 XXTEA with a length word
A resource-container sample used XXTEA: `delta = 0x9E3779B9`, `rounds = 6 + 52/n`, decrypt from A resource-container sample used XXTEA: `delta = 0x9E3779B9`, `rounds = 6 + 52/n`, decrypt from
@@ -237,6 +271,16 @@ re-imported metadata is silently corrupt and the dumper still accepts it.
Dump `index,hex` to CSV, decrypt offline, patch the metadata file, then re-run Il2CppDumper. This Dump `index,hex` to CSV, decrypt offline, patch the metadata file, then re-run Il2CppDumper. This
keeps the proof in one place: the tool either parses the patched file or it does not. keeps the proof in one place: the tool either parses the patched file or it does not.
**When the literal cipher lives inside the protected VM, do not reverse it — drive the runtime.**
`String::NewLen(ptr, len)` *is* the decryption oracle, and it takes exactly the two fields the literal
table stores. Enumerate `i` from 0 to `count-1` yourself, read `(dataOffset + dataIndex, length)`, call
the runtime entry for each, and collect the returned UTF-16 buffers. Three properties make this better
than either hooking natural calls or reimplementing the cipher: it is exhaustive rather than a sample
of what the app happened to load, it is a completeness proof for the table (every index either
decrypts or visibly fails), and it keeps you out of the VM. The cost is that the process must be
alive and past metadata init, so it is the wrong route when the question is what a dead sample
contains.
## 7. Adjacent artifacts that fail the same way ## 7. Adjacent artifacts that fail the same way
These are not metadata, but they are the next files the same build protects, and the diagnostic These are not metadata, but they are the next files the same build protects, and the diagnostic
@@ -13,7 +13,8 @@ source-reading write-ups (Android 5.0 and 8.x `bionic/linker`) and one Frida coo
was reimplemented and no dump was produced here. Source citations are `unverified` against your was reimplemented and no dump was produced here. Source citations are `unverified` against your
tree until you open the matching AOSP tag. The *arithmetic* (bias, page offset, relocation target) tree until you open the matching AOSP tag. The *arithmetic* (bias, page offset, relocation target)
is `inferred` from that source and should be checked with one control load before it is trusted. is `inferred` from that source and should be checked with one control load before it is trusted.
The `soinfo` offsets quoted below are explicitly version-specific and are examples, not constants. The `soinfo` offsets quoted below are explicitly version-specific and are examples, not constants. The dump-window and reader rules in §6.2–6.3 were added 2026-10 from a write-up
on a dual-library commercial shell; they are `unverified` operating rules, not measurements.
## 1. The pipeline, as a specification for a loader ## 1. The pipeline, as a specification for a loader
@@ -186,6 +187,51 @@ Deleting the header instead of XORing it is a weaker defence but a nastier sympt
*cleanly* rejected, so the analyst blames the dump site. If the dump site is right and the header *cleanly* rejected, so the analyst blames the dump site. If the dump site is right and the header
is missing, the correct conclusion is "the shell removed it", not "the dump was early". is missing, the correct conclusion is "the shell removed it", not "the dump was early".
### 6.2 The window can close inside `JNI_OnLoad`
The dump points above are ordered by *how much of the image exists*. A protector that modifies itself
adds a second axis: *how long the process lives*. A shell that decrypts its own code in
`JNI_OnLoad` (SMC) and starts watchdog threads from the same function leaves exactly one interval in
which both hold — segments mapped, SMC not yet run. Dumping after `dlopen` returns is late twice
over: the self-decryption has completed, and the watchdog is already armed by the time any
post-return hook runs.
So: hook `android_dlopen_ext`, and dump in `onEnter` when the target path matches. Treat "the image
is not relocated yet" as expected, and record the bias and relocation tables in the same pass
(§2, §4). An unrelocated dump plus its bias is recoverable; an unrelocated dump without one is not.
A dump taken *inside* `JNI_OnLoad` is the worst of both: the code is complete, so the dump looks
right, and the watchdog is up, so the process dies during the read. **If the target dies while you
dump and only then, this is the shape — not a broken tool.**
**Claim strength.** The window itself — SMC completing *and* watchdogs starting inside the same
`JNI_OnLoad` — is `unverified`: one write-up reports it and this record did not reproduce it. The
placement rule (dump in `onEnter`, keep the bias) is `inferred` from the arithmetic in §2 and §4. The
symptom is the source's report, also `unverified`.
### 6.3 Read with syscalls, and pad the holes
Two properties of the reader decide whether the dump is usable.
- **The reader must not travel through the library the protector hooks.** A shell that inline-hooks
libc's `open`/`read`/`write` sees your dump as one more caller and can refuse or terminate. A
raw-syscall reader (`svc #0` from a small stub, or a kernel-side reader) sits outside that
surface. This is `advanced-unpacking.md` §"Layered descent" applied to your own tooling: the layer
you read from is also the layer the target can watch. (`unverified` for the protector-hook claim;
the layer rule it extends is `measured` there.)
- **An unreadable page is a hole to fill, not a range to skip.** Skipping shifts every later byte
and produces a file that repairs into a plausible ELF with missing logic. Zero-filling preserves
offsets and sizes, so segment placement still works; record which ranges were unreadable so the
repair can be audited. A dump is evidence, and "these ranges were unreadable" belongs in it.
(`observed`, host: in a synthetic three-page image with one unreadable page, a marker meant for
offset 8199 lands at 8199 when the page is zero-filled and at 4103 when it is skipped — see the
EXTENSION record.)
Then repair the image with a tool that rebuilds what the loader would have written (program headers,
dynamic table, section headers). The repair consumes a file whose *offsets* are right; that is what
the zero-fill protects. (`inferred`: the offset/size argument above, not a repair run here.)
## 7. Timing: constructors and one-shot registrations ## 7. Timing: constructors and one-shot registrations
`dlopen` does not return until `CallConstructors` has run the dependencies' constructors, then the `dlopen` does not return until `CallConstructors` has run the dependencies' constructors, then the
@@ -159,6 +159,69 @@ terminate path is the end of the check; nothing downstream re-reads "did I die".
rather than assuming: after a successful suppression the app must reach its **normal UI and stay rather than assuming: after a successful suppression the app must reach its **normal UI and stay
there**, not loop through half-initialised states. there**, not loop through half-initialised states.
## Which site — and in what order
Patch sites are not interchangeable. Fixing the wrong one costs a day; fixing them in the wrong order
costs the same day twice, because you cannot tell which change mattered. Sort the candidates first.
### One predicate may be deciding for all of them
Group the branches you found by the function whose return value they test. When every detector funnels
into one `is_clean()`-shaped call, rewriting that return is the whole bypass: the kill sites are never
reached, and the branches you did not enumerate are covered too.
Two conditions, both required:
- the function is a **decision** (returns a verdict), not the **action** (performs the kill). Patching
an action changes the response; patching a decision changes the belief. The second is what makes a
bypass stable.
- you have checked its other callers. A predicate that also gates a feature will disable that feature
once it always returns clean. Enumerate the callers before you touch it — the xref list in the
disassembler, or the same caller enumeration `scripts/find_refs.py` does for dex methods.
(`unverified` that a given target funnels every detector through one predicate — that is the
source's finding. The decision-versus-action rule is `inferred` from it.)
### Grade the sites by what being wrong costs
| Tier | What it is | How to patch it | Why this order |
|---|---|---|---|
| **Tier 0** | terminate primitives: `exit_group`/`tgkill`/`kill` call sites, the shellcode executor, the unified kill point | replace with a no-op or a returning stub | until they stop, every other result is unobservable — the process dies first |
| **Tier 1** | decision functions: the shared predicate, each scanner (`/proc` walk, `TracerPid` read, module checksum) | return the benign value *for that caller's branch* | they are the belief; a clean verdict also skips the report path |
| **Tier 2** | auxiliary gates: adb/debug flags, telemetry, feature switches | only if observed to gate the thing you care about | unbounded work; most are inert in your environment |
The benign value is not always 0. Read the caller's branch: a "found something" scanner returns
non-zero, a "list of hits" scanner returns NULL, a "should continue" predicate returns 1. Returning
0 everywhere is a guess that happens to work half the time — and the failing half reads as a broken
patch instead of a wrong constant.
(`inferred`: the order follows from observability — a death at tier 0 hides every other result —
and the benign-value rule from the caller's branch. The tier vocabulary is the source's,
`unverified`; no graded set was run here.)
### Count the watchdogs before declaring the set closed
One kill site is rarely the only thread. The threads are distinguishable by what they *read*, not by
their names:
- a `/proc/self/task`, `/proc/self/fd` or `/proc/self/maps` walk — looking for your instrumentation;
- `TracerPid`, the parent pid, or a task in state `T` — looking for a debugger or a suspended process;
- a checksum over a loaded module — looking for a modified page.
Patch one and the app still dies, at a different delay, which reads as "the patch did not work" rather
than "there were three". After the tier 0/1 set, the process must survive longer than the **longest**
timer you have observed, not the first one.
(`unverified` for the probe inventory — source-reported for one shell; `inferred` for "identify a
thread by what it reads", which follows from the probe classes themselves.)
### One tier per run
Patch tier 0, run, record; then tier 1; then tier 2 only if needed. A build with all tiers changed at once cannot
tell you which one mattered, and the next failure is unattributable. This is the single-variable rule
of `pitfalls.md` P21 applied to a patch set. (`inferred`.)
## ELF hardening you will meet in these targets ## ELF hardening you will meet in these targets
Hardening libraries are not normal ELF files. Assume the following until measured otherwise. Hardening libraries are not normal ELF files. Assume the following until measured otherwise.
@@ -5,15 +5,19 @@ xvmp-class IR virtualizer, or any private-bytecode loop — and the question is
the handler soup to the guest program. This file owns the recovery procedure; the **capture** the handler soup to the guest program. This file owns the recovery procedure; the **capture**
half lives in `references/ete-diff-tracing.md`, the **slicing** tool in half lives in `references/ete-diff-tracing.md`, the **slicing** tool in
`scripts/vm_handler_slice.py`, and the OLLVM-only case in `scripts/vm_handler_slice.py`, and the OLLVM-only case in
`references/native-dbi-and-deobfuscation.md`. `references/native-dbi-and-deobfuscation.md`. If the interpreter is itself written in a managed
language — a C# class holding an opcode array plus a cursor under IL2CPP, or a JS dispatch loop — this
is the wrong file: `unity-runtime.md` §when the managed layer is itself the interpreter, and
`jsvmp-recovery.md`, own those shapes.
**Claim strength.** Every method step here is absorbed from two public reverse-engineering **Claim strength.** Every method step here is absorbed from two public reverse-engineering
write-ups (Kanxue, 2026-08/09, titles and authors anonymized in this record; one is a full write-ups (Kanxue, 2026-08/09, titles and authors anonymized in this record; one is a full
arm64 custom-VM recovery, the other a VMP interpreter recovery with trace-driven IR lifting). arm64 custom-VM recovery, the other a VMP interpreter recovery with trace-driven IR lifting).
The write-ups are `observed` by their authors; this repository has **never run any of these The write-ups are `observed` by their authors; this repository has **never run any of these
steps on a real VM target** — everything below is `inferred` from those write-ups, cross-read steps on a real VM target**, so the mechanics below are `unverified` here — reported, not
against the open xvmp source facts in `references/ete-diff-tracing.md` §5. The pipeline's reproduced — and the ordering judgements built on them are `inferred`, cross-read against the
host-tested pieces (trace parsing, slicing, diffing) carry their own labels where named. open xvmp source facts in `references/ete-diff-tracing.md` §5. The pipeline's host-tested pieces
(trace parsing, slicing, diffing) carry their own labels where named.
## 1. Deciding it is a VM at all ## 1. Deciding it is a VM at all
@@ -171,7 +175,50 @@ pre-IP and post-IP are both recorded (`0x2 -> 0x3`), the 200k-line IR sequence *
execution trace: +1 is fallthrough, jumps are branches, back-edges are loops — the guest CFG execution trace: +1 is fallthrough, jumps are branches, back-edges are loops — the guest CFG
falls out. That is the end state this file walks toward: the guest program as data. falls out. That is the end state this file walks toward: the guest program as data.
## 11. Where this repository's tools plug in ## 11. The other end state: a program you can run
Sections 1–10 aim at a guest program you can **read**. When the interpreter implements one
deterministic function — a request signer, a decoder, a checksum — the cheaper deliverable is a
program you can **run**, and the handler semantics never need to be understood. (`unverified`: one
write-up reports the route; this record did not run it.)
1. **Fix the boundary.** One native entry that takes a buffer in and produces a buffer out.
Everything inside is the VM; everything outside is protocol.
2. **Symbolic input, concrete everything else.** Seed the input bytes as symbols and run the VM (live,
or over the recorded trace). Constant-fold every node whose value does not depend on them; delete
loops and branches whose condition folds. What cannot fold is the part you must reproduce.
3. **What remains is straight-line.** An SSA list of `(op, args)`, where `args` are constants or the
indices of earlier nodes, and `op` is the ALU subset the real semantics needed — read input byte,
load from the constant table, add/sub, and/or/xor, shift, truncate, sign-extend. No loop, no
dispatcher, no handler table.
4. **Capture four artifacts together, from one trace.** They are only valid as a set:
- the program;
- the constant table and its base (program offsets are relative to it);
- the **output map** — which node byte lands at which output offset;
- the **output template** — the fixed characters the transform does not compute.
The map and the template are what people skip. Without them the transform is right and the string
is wrong, which looks like an off-by-one in the algorithm and is not.
5. **Implement it in tens of lines.** A loop over `(op, args)` with a value array. No emulator, no JNI,
no device — a function you can call at unit-test speed.
**Version binding.** The program is a property of one build. Store the library's fingerprint (size and
build id) beside it and re-extract on upgrade: the tables and the map move even when the algorithm
does not. Say which build a program came from; an extract with no fingerprint is not reproducible.
(`inferred` for the fingerprint discipline; `unverified` for the source's report that the tables move
on update.)
**Validation is per node, not per output.** Compare node values at several checkpoints against a
device run. A node that is right in value but wrong in width (32-bit truncation where the VM kept 64)
passes the final comparison on some inputs and fails on others — §9's failure seen from the other
side. (`inferred` from §9.)
**Boundary.** This route needs a deterministic, input-driven computation. If the VM folds in a device
id, a timestamp or a nonce, those become constants from one trace, and the honest claim is
"reproduces one device's answers", not "implements the algorithm". For a signer that is often exactly
enough, but the report has to say which claim it is making.
## 12. Where this repository's tools plug in
| Step | Tool | | Step | Tool |
|---|---| |---|---|
@@ -193,4 +240,5 @@ falls out. That is the end state this file walks toward: the guest program as da
- [ ] segments stacked if entry can nest (§7); slicer's nested-loop diagnostic honoured - [ ] segments stacked if entry can nest (§7); slicer's nested-loop diagnostic honoured
- [ ] operand slicing seeded on all STOREs; byte provenance (not value) decides folding - [ ] operand slicing seeded on all STOREs; byte provenance (not value) decides folding
- [ ] clean re-VM runs real bytecode against trace ground truth before any IR is trusted - [ ] clean re-VM runs real bytecode against trace ground truth before any IR is trusted
- [ ] labels: write-up methods `inferred`, shipped tools `observed` (host), no VM target run here - [ ] labels: write-up mechanisms `unverified`, ordering judgements `inferred`, shipped tools `observed` (host), no VM target run here
- [ ] if the deliverable is a callable signer/decoder: §11's four artifacts captured as a set, program pinned to a build fingerprint
+5
View File
@@ -88,6 +88,11 @@ rounds) re-deriving what a cleaner experiment would have shown in one run.
changes nothing about the shell. changes nothing about the shell.
- **Equal-length renames** keep binary XML chunk structure valid, so no manifest re-encoding is needed: - **Equal-length renames** keep binary XML chunk structure valid, so no manifest re-encoding is needed:
replace the name bytes in `AndroidManifest.xml` in place, size unchanged. replace the name bytes in `AndroidManifest.xml` in place, size unchanged.
- **A build with Google PairIP is usually the one to leave alone.** Look for `com.pairip` classes and
a `LicenseClient` before committing: it combines Play licensing with partial code virtualization and
terminates a re-signed process. If the app ships several variants, an older or regional build without
PairIP is a better target than an unwinnable one — that is target selection, not defeat. The source's
native case chose the older regional split build and accepted fewer cosmetics.
## Native libraries as a place to live ## Native libraries as a place to live
+125
View File
@@ -1471,3 +1471,128 @@ signature consequences — `signature-derived-keys.md`), or by giving the loader
`.so` extracted from the APK and call it the module: those addresses belong to a copy the process `.so` extracted from the APK and call it the module: those addresses belong to a copy the process
never mapped, so a breakpoint that does land is worse than one that does not. The full attach sequence never mapped, so a breakpoint that does land is worse than one that does not. The full attach sequence
is in `ida-so-debugging.md`. is in `ida-so-debugging.md`.
## P49. A reimplemented signer is byte-wrong, and the defect is in the extraction
**Symptom**
A reproduced signer emits a signature of the right shape and length and the server rejects it. Every
intermediate value looks sane; the difference is at the tail. The working hypothesis becomes "there is
a final MAC", then "a truncated hash", then "a per-version tweak", and each one gets its own day.
**Root cause**
The input to the pipeline is not byte-identical to the device's. The dump read two bytes past the real
buffer, or a length field in the container lies, or the buffer was copied at an unaligned offset. One
wrong byte early makes every later stage wrong, and the result still has the right shape.
**Why it is hard to see**
A wrong algorithm and a wrong input produce the same class of output: plausible, wrong, deterministic.
Byte-level total failure fits every hypothesis, so there is unlimited room for confirmation bias. And
the defect lives in memory, where you cannot diff it the way you diff two files.
**The rule**
**Prove each stage's input is byte-identical — length, alignment, encoding — before touching the
algorithm.** Compare stage inputs against the device, not final outputs; a stage-input diff localises
in minutes what an output diff cannot localise at all. P42 is the decoder-desync cousin; this one is
an extraction length. (`inferred` — a reasoning rule from how one byte propagates; no target case was
measured for this record.)
## P50. A "custom cipher" is a wrapper that cancels
**Symptom**
Reimplementing an odd transform produces output that is either double-transformed or exactly what the
standard primitive would have produced — the transform appears to do nothing, which reads as a missing
step rather than an extra one.
**Root cause**
An involution applied symmetrically. `(x & ~m) | (~x & m)` is `x ^ m` for a mask whose bits partition
the word; called on both the encrypt and the decrypt path, it cancels. A fixed keyless permutation is
the other member of the family: an encoding dressed as encryption.
**Why it is hard to see**
The function name and the bit arithmetic read as custom crypto, and the wrapper sits between you and
the primitive, so reading either alone misleads. A no-op transform is not something you expect to find
*inside* a protected algorithm, so it gets modelled as key mixing and carried through every later
step.
**The rule**
**Compose it with itself before reimplementing it** (`f(f(x)) == x`), and check whether the caller
invokes it on both paths. If it cancels, drop it and recover the standard primitive underneath; keep
the wrapper in the report, because it is the reason the algorithm looked unfamiliar. The method, with
the differential probes that identify the primitive underneath, is `protocol-reverse.md` §7; the
mask identity itself is host-checked there (`observed`: zero counterexamples over 65,536 eight-bit
pairs and 200,000 random 16-bit pairs).
## P51. The low-API branch you need was removed by R8
**Symptom**
A build with `minSdkVersion 29` is changed to 28 and installed on Android 9. It starts, then dies on
`No virtual method rebase()`, `registerActivityLifecycleCallbacks`, or `WindowInsets$Builder`; or it
runs but lifecycle events never arrive, so coroutines inside `lifecycleScope` never execute.
**Root cause**
R8 evaluated `if (SDK_INT >= 29)` as true for the declared `minSdk` and deleted the else branch. The
`$ApiNNImpl` fallbacks below 29, the old `WindowInsetsCompat` implementation, and the pre-29 path in
`ReportFragment.dispatch` (which became an empty function) are no longer in the dex.
**Why it is hard to see**
The APK installs and starts; only the path that needs the deleted branch fails. The stack names a
framework or AndroidX class, so the first hypothesis is an SDK/framework mismatch, not "our own build
deleted this code". The empty lifecycle method is silent: nothing throws, the observable is "the app
does nothing".
**The rule**
**Lowering `minSdk` is a code change, not a manifest edit.** Audit every `$ApiNNImpl` with N at or
above the original minSdk, the lifecycle dispatch, and `WindowInsetsCompat`; add a version guard that
returns the default on old devices and restore the old implementation. Test on the oldest API you
claim to support. Prefer a newer emulator over lowering the floor; if you must lower it, treat every
`SDK_INT` comparison as a branch you may have to re-create.
## P52. A decompiled Lua file does not match its filename
**Symptom**
A batch decompile produces valid Lua, but many files in different directories contain the same
unrelated script (the source found 112). The running game is fine, so the "source" is the only thing
that is wrong. A later variant: a script you replaced is not the script the build patched; constants
from the hot update disappear, and a runtime stack contains a function name that does not exist
anywhere in the decompiled source.
**Root cause**
The bundle writer cloned a template `TextAsset` and wrote new bytes with `save_typetree`; the
library's `read()` kept parsing the template object's original bytes. The same cache applies after a
hot-update merge: `set_raw`/replacement writes the new script, but `read()` still returns the packaged
old one, so a read-modify-write patch operates on the old file and silently overwrites the new one.
**Why it is hard to see**
Every file is syntactically valid Lua. Nothing in the pipeline reports an error; the only signal is
semantic — a function that should exist does not, or two entries share identical content. If the
analysis copy is wrong, the patch is written against a file the device never runs.
**The rule**
**Compare the entry name with the chunk name before analysing a batch.** Lua 5.1 bytecode stores
`@UI/...` immediately after the header; zero mismatches is the gate for trusting the export. In your
own bundle writer, keep a sidecar map of every written payload and make reads return it first, then
compare the bytes read back with the hot-update source. The quick runtime signal is a stack frame
naming a function absent from the "source" — that means you are reading the old script.
## P53. A retained AssetBundle returns null after stripping unused bundles
**Symptom**
You remove bundles that the package does not seem to use. The build installs and starts, but a bundle
you kept now loads as null or its assets are missing. There is no CRC error and the removed files are
not mentioned in the log.
**Root cause**
`AssetBundleManifest` still lists the removed bundle as a dependency of a retained one. Unity resolves
the dependency graph before loading; a missing edge makes the parent unavailable even though its own
bytes are intact.
**Why it is hard to see**
The failure is attributed to the bundle that is still present, or to the patch you just made. The
removed bundle is absent from the evidence by definition, and "the file exists" looks like proof that a
bundle should load.
**The rule**
**When you remove an AssetBundle, rebuild the dependency list in the manifest in the same step.**
Never treat file presence as loadability. Load each retained bundle in a control build and check for
null before signing; keep the removed-bundle list in the build record so a later change can rebuild
the graph.
@@ -369,7 +369,83 @@ frame's dependency set, and the envelope decodes stably across several samples.
is still "which state did this frame consume", no amount of body decoding helps — go capture the is still "which state did this frame consume", no amount of body decoding helps — go capture the
missing family first. missing family first.
## 7. Failure modes ## 7. Encrypted bodies — classify the primitive before you implement it
**Load this when** the body is opaque: a long base64/hex field in the query, a binary request body, a
fixed prefix on every response — and the transform lives in a native library or a helper class.
Three black-box experiments on captured pairs, before any static work. The probes themselves were
host-checked here on AES-128 through `openssl` (commands and output in the verification record,
`docs/tool-verification/EXTENSION-ref-absorption-2026-10b.md`, under "Verification pass"). What they prove
about *your* target is one step further, and stays `inferred` until you vary the key and the
request.
1. **Header length.** Encrypt two payloads under the same key and decode both. A constant first N
bytes ⇒ a deterministic header: fixed plaintext, or derived from the key/IV. A prefix that changes
when the key changes ⇒ keyed. A prefix that changes per request ⇒ a per-message nonce.
(`observed` on synthetic inputs.)
2. **Determinism, then diffusion width.** Encrypt `P` and `P || X`, and XOR the ciphertexts. Zeros
over the common prefix ⇒ the construction is deterministic under a fixed key and IV — **and that
is all it proves.** Measured: CTR, CBC and ECB all give zero prefix-XOR at a fixed IV, so this
experiment cannot separate a stream cipher from a block mode. (An earlier draft of this file said
it could; one run falsified it.) Repeat with a different IV: a CTR-style mode diverges, and so does
any mode that carries a per-message nonce.
The separation comes from a one-byte plaintext flip, counted over the ciphertext: **1 changed
byte** ⇒ a keystream independent of the plaintext (measured: CTR, 1 of 32); **every block from
that point on** ⇒ a chained mode (measured: CBC, 32 of 32); **exactly one block** ⇒ ECB (measured:
16 of 32, later blocks untouched). (`observed`, host.)
3. **Length law.** `len(c) = len(p)` ⇒ no padding — which fits CTR and a `nopad` block mode equally,
so it never decides alone. `len(c) = b * ceil((len(p)+1)/b)` ⇒ a padded block mode (PKCS#7;
checked for b = 16, p = 0…32). A compressed prefix with a constant length relation ⇒
compress-then-encrypt, and the plaintext you are looking for is the compressor's output.
(`observed`, host.)
The classification decides what you implement: a keystream cipher needs its keystream and nothing
else; a chained mode needs the mode and the IV; ECB needs neither to explain its structure. Skipping
this step is how a standard construction gets reimplemented as something exotic.
### A custom-looking transform may be a wrapper that cancels
Wrapper arithmetic is cheaper to check than to rewrite. Two shapes cover most of what looks strange:
- **Involution applied symmetrically.** A transform with `f(f(x)) == x` that is called on the way in
*and* on the way out contributes nothing. The common disguise is a mask pair:
`(x & ~m) | (~x & m)` is exactly `x ^ m`. Exhaustively checked here over all 8-bit `(x, m)` pairs
and 200,000 random 16-bit pairs: zero counterexamples, and the composition is an involution. If
both encrypt and decrypt call it, drop it and recover the standard primitive underneath.
(`observed`, host — the algebra; whether a target's wrapper is that shape is `inferred`.)
- **A fixed permutation.** The same 256-byte table applied to every input with no key dependence is
an encoding, not encryption. Index it out and compare against known S-boxes. (`inferred`.)
Test the composition before reimplementing: apply the function twice, and check whether the caller
uses it twice. If it cancels, the algorithm is standard and the reason it looked unfamiliar is now
written down.
### The last mile is encoding, not crypto
Two non-cryptographic differences fail signatures that are otherwise correct. Both are invisible in
the algorithm and both are cheap to eliminate:
- **The client's encoder may be Java's.** `URLEncoder` writes a space as `+`, leaves `*`, `-`, `_`,
`.` alone, and percent-encodes `~` as `%7E` with uppercase hex over UTF-8. Python's does the
opposite on two of those: measured on this host, `quote` gives `a%20b~%2A-_.` (space `%20`, `*`
encoded, `~` kept) and `quote_plus` gives `a+b~%2A-_.` (space `+`, `*` still encoded). Reimplement
what the client does and check it against one captured parameter, not against documentation.
(Python side `observed`; the Java side is `unverified` here — no JDK on the analysis host — and is
quoted from the JDK API contract, so confirm it on one captured value.)
- **Compressed bytes are implementation-defined.** Measured: `zlib.compress(data, 1)` and `(data, 9)`
produce different byte streams (49 vs 48 bytes) for the same payload, and both decompress to it.
Whether the difference breaks a signature is a property of the **server**: if it decompresses and
checks a CRC or the plaintext, byte equality is not required; if it compares the stored blob, it
is. One mutation tells you which. (The general claim is `observed`; the specific liblz4-vs-python-
lz4 divergence is `unverified` — no lz4 binding here.)
**Boundary.** None of the three experiments needs the `.so`; that is the point. When the keystream is
derived per message from a device secret, the native route comes back and §5's attribution applies.
(`inferred`.)
## 8. Failure modes
**A decode that looks valid but is not.** protobuf is self-synchronising enough that random bytes **A decode that looks valid but is not.** protobuf is self-synchronising enough that random bytes
often decode into a plausible-looking field list. Guard against it by (a) decoding several samples of often decode into a plausible-looking field list. Guard against it by (a) decoding several samples of
@@ -12,7 +12,9 @@ all.
sample was unpacked in this record. The general rules (static-first, self-describing TLV, sample was unpacked in this record. The general rules (static-first, self-describing TLV,
mirror-the-host-codegen) are `inferred` from that source. Version numbers matter: every branch mirror-the-host-codegen) are `inferred` from that source. Version numbers matter: every branch
below is gated on the `pycdc`/Python version, and applying a newer layout to an older file fails below is gated on the `pycdc`/Python version, and applying a newer layout to an older file fails
silently rather than loudly. silently rather than loudly. The three-scope nonce layering (§2.2) and the counter-mode correction
in §5 were added in the 2026-10 audit pass; the counter behaviour is `observed` on the host, the
layering itself is `unverified`.
## 1. Recognition ## 1. Recognition
@@ -65,9 +67,39 @@ The `idiv` side effect is the general lesson: when reimplementing a packer's VM,
code generation*, including register clobbers the author did not intend. A clean abstract code generation*, including register clobbers the author did not intend. A clean abstract
interpreter will produce a different key and every downstream field will decrypt to noise. interpreter will produce a different key and every downstream field will decrypt to noise.
Width is part of the same contract: the VM is a transcription of machine instructions, so each
operation must be evaluated at the host register width — a multiply keeps only the low 32 bits,
division is signed and truncates toward zero, and results wrap. Evaluating the same program with
Python's unbounded integers diverges after a few instructions and produces a key that is wrong in a
way that looks like a wrong nonce downstream, not like an arithmetic error.
### 2.2 The shipped blob is wrapped once more
The `.pyc` is the *inner* artefact. At least one build ships
`AES-CTR(master key, AST_nonce, pyc-with-encrypted-parts)`: the file on disk is not a pyc, its first
four bytes are not the marshal magic, and a parser pointed at it reports a corrupt header rather than
an encrypted file. Three scopes share one master key and are separated only by which nonce is used:
| Scope | Nonce | Plaintext it yields |
|---|---|---|
| outer container, whole file | `AST_nonce` from `RSA_KEY2`, `nonce[15] = 2` | the pyc: header, string blob, code section |
| each code object | 12 bytes sliced out of that object's own `m_code` (§5) | that object's bytecode |
| each string | `pyarmor_mix_str_aes_nonce` | that one literal |
The order is not a preference. Applying a code object's nonce to the on-disk bytes decrypts layer 1's
ciphertext with layer 2's stream and yields high-entropy bytes that look like a private opcode set, so
the failure is "this packer uses a custom ISA", which is the wrong conclusion. Peel the outer layer
first, then check for the pyc header, then parse (§3).
A live dump does not replace this pass either: the packer decrypts each code object when it is first
imported, so a process dump holds the objects that ran and leaves everything else as ciphertext. A
function missing from a dump means "not reached yet", not "not present" — force the modules to import
before calling a dump complete, and keep the static pass as the only complete route.
## 3. Parsing the code object ## 3. Parsing the code object
The protected file is a normal `.pyc` with extra fields, so the parser must be version-aware. **Once the outer layer is off (§2.2)**, the file is a normal `.pyc` with extra fields, so the parser
must be version-aware.
Fields that change and the versions that introduced them: Fields that change and the versions that introduced them:
| Field | Width / condition | | Field | Width / condition |
@@ -147,9 +179,16 @@ Then:
6. Replace the descriptor's first 8 bytes with the `"<COAddr>"` placeholder so a later re-run does 6. Replace the descriptor's first 8 bytes with the `"<COAddr>"` placeholder so a later re-run does
not treat runtime data as a key. not treat runtime data as a key.
The nonce construction is the part that is easy to get wrong: `nonce[15] = 2` is a domain The nonce construction is the part that is easy to get wrong, and the usual description of *how* it
separator, and using an all-zero tail produces a stream that decrypts the first block plausibly and fails is wrong: `nonce[15] = 2` is not a flag that only affects later blocks. In counter mode every
then diverges. block's keystream is `E(nonce || counter)`, so changing byte 15 changes the counter start and corrupts
**block 0 onward** — there is no "first block decrypts plausibly" state to catch you. (`observed`,
host: two 16-byte counter blocks differing only in byte 15 differ in 16 of 16 keystream bytes, so
the ciphertext differs from block 0 — see the EXTENSION record and
`docs/tool-verification/fixtures/verify_ref_claims_10c.py`.) What an *unset* tail does is worse in a different way: the leftover bytes
are whatever the buffer held, so the keystream is not reproducible at all and the same input decrypts
differently on two runs. Zero the buffer, set the byte, and check the first eight bytes of the result
against a known code-object prologue instead of trusting a plausible-looking body.
## 6. Decrypting strings ## 6. Decrypting strings
+47
View File
@@ -54,6 +54,51 @@ launch screen, popups and tab set are **client decisions** or **server data**,
which is the difference between a five-minute patch and a dead end. See which is the difference between a five-minute patch and a dead end. See
`server-config-and-updates.md`. `server-config-and-updates.md`.
## 1c. Resource completeness and the encryption map
Two questions are cheap on day one and expensive after a week of patching: **how much of the game is
in this APK**, and **what exactly is encrypted**. Answer both before choosing a route.
**Completeness.** A 1.2 GB package can be a quarter of the game. Find the game's own catalogue
(`manifest.*`, `AssetDatabase.manifest`, a version file, a native manifest) and diff it against the
files actually present, summed by directory. Then diff the content tables (costumes, characters,
levels) against entries that have a model or texture. In the source's micro-client case, the manifest
listed 42,700 bundles / 4.62 GB while the APK held 12,120 / 1.05 GB, and about 91% of the clothing
models were absent. The rest was downloaded on first launch and died with the server.
A player's app backup is often the only complete source; treat it as untrusted: identify the container
(headers, compression, encryption), verify every file against the backup's own manifest and MD5, and
confirm the APK inside is the **same build** — the source found a backup APK with the same version
name and versionCode but 1,518 differing files. Merge the hot-update layer (scripts, manifests, updated
bundles) into the package and make it survive the client's first-launch cleanup, or the files are
deleted before they are read. If the missing resources were never in any player's copy, stop and say so
rather than patching around a game that cannot be complete.
**Encryption map.** Do not answer "is anything else encrypted?" from memory. Spend half an hour:
1. **Classify every entry** — installed files plus the hot-update directory: size, first 16 bytes,
magic type, and entropy over the first 64 KB. The goal is zero "unknown" entries.
2. **High entropy is not encryption.** Compressed bundles, audio and textures all sit above 7.5.
Test whether the standard loader opens the file (a resource bundle that UnityPy loads is not
encrypted), whether a public header is present and plausible (e.g. `FSB5`), and whether a sample
decodes to a real image or sound.
3. **Judge text resources one by one** — readable text, a public binary format (skeleton, sound bank,
protobuf), or high entropy and a length that is a multiple of the block size (a cipher candidate).
4. **A fixed prefix is not encryption.** Several zero bytes at the start of every bundle are a common
anti-unpacker trick; count them in the original, skip them on read, preserve them on write.
5. **Check config tables by field**, not by vibe: decode with the protocol description, then scan for
field numbers the description does not contain. Zero unknown fields, and a re-serialization of the
same byte length, are two independent confirmations.
6. **Find the second copy.** Packages often contain an old config database while the phone's
hot-updated copy is newer. Compare row counts per table and build from the newer one.
7. **List runtime crypto points separately** — script load, login token, resource check, payment,
network packet — and record for each whether the offline route needs it.
8. **Separate "cannot decrypt" from "not in hand".** A server database or an unreadable private
directory is missing data, not an encryption problem; mixing the two produces a false "cracked".
The map is a deliverable: it lets a later reader see which conclusions were measured, which were
inferred, and which files nobody could open.
## 2. Is it packed? ## 2. Is it packed?
Read `AndroidManifest.xml` → `application android:name`. Read `AndroidManifest.xml` → `application android:name`.
@@ -129,6 +174,8 @@ Heuristic: the business dex mixes the app's package prefix (hundreds of hits) wi
| `libflutter.so` + `libapp.so` | **Flutter (Dart AOT)** — dex contains only a thin shell | | `libflutter.so` + `libapp.so` | **Flutter (Dart AOT)** — dex contains only a thin shell |
| `libil2cpp.so` + `assets/bin/Data/` | **Unity (IL2CPP)** — native | | `libil2cpp.so` + `assets/bin/Data/` | **Unity (IL2CPP)** — native |
| `libmono*.so` + `assets/bin/Data/Managed/` | **Unity (Mono)** — managed DLLs under `assets/` | | `libmono*.so` + `assets/bin/Data/Managed/` | **Unity (Mono)** — managed DLLs under `assets/` |
| `libunity.so` + a `luascript` bundle or thousands of Lua `TextAsset` entries | **Unity + Lua** (xLua / tolua / SLua) — the logic is in a bundle, not the assembly — `unity-lua-and-assetbundles.md` |
| `liblayaair.so` + `libv8*.so` + `assets/scripts/*.js` | **LayaAir native (Conch)** — JavaScript logic and a DCC cache — `framework-runtimes.md` §LayaAir native (Conch) specifics |
| `libreactnativejni.so` + `assets/index.android.bundle` | **React Native** — JS bundle under `assets/` | | `libreactnativejni.so` + `assets/index.android.bundle` | **React Native** — JS bundle under `assets/` |
| `libhermes.so` | **Hermes bytecode** | | `libhermes.so` | **Hermes bytecode** |
| Almost everything in `.so` | **Native** — different toolchain entirely | | Almost everything in `.so` | **Native** — different toolchain entirely |
@@ -206,6 +206,33 @@ Always pass the explicit range (Route B above) and read the scheme list from tha
Useful detail: keeping the same keystore across builds lets you iterate with `-r` and **preserve a logged-in session**, which matters a lot when the feature you are testing needs auth. Useful detail: keeping the same keystore across builds lets you iterate with `-r` and **preserve a logged-in session**, which matters a lot when the feature you are testing needs auth.
### Renaming the package so two builds coexist
Same package name plus a different signature is an install refusal, and uninstalling the official app
destroys its data. To install alongside it, rename the package in three places — a manifest-only edit
produces an APK that installs and then fails to find its own resources:
1. **Binary `AndroidManifest.xml`.** Rebuild the UTF-16 string pool and replace the package name and
**every string that carries its prefix** (permissions, provider authorities, the file provider, the
push `C2D_MESSAGE` permission, and similar). Enumerate the suffixes from a table rather than
guessing; update the chunk sizes and the file size; assert that no occurrence of the old name
remains. Do not rename Java class names.
2. **The `resources.arsc` package block.** Its name is a fixed 128-UTF-16-character field. Miss it
and the build installs but resource resolution fails at start — the same symptom as a missing
resource, far from the cause.
3. **The launcher label**, in the arsc UTF-8 string pool. This can be replaced in place only when the
new label is not longer than the old one.
Then grep Java/smali for quoted package-name literals and change build scripts to read the name from
one variable instead of hardcoding it. The app's data directory becomes
`Android/data/<new-package>/`, so old saves are not carried over — say so in the install notes.
Verify with `aapt dump badging` (package and label), then install both builds on one device: the new
one must reach its main screen and read/write a save while the official one remains installed. The
source's LayaAir/Conch case also had to change the arsc package name (Android 9+ compares it when
resolving resources); hardcoded private-directory paths used a build-time placeholder, and the local
licence value derived from `ANDROID_ID` did not change with the package name, while saves did.
### Vendor install interception (OEM shells) ### Vendor install interception (OEM shells)
Some ROMs route `adb install` through their own "security centre", which can return Some ROMs route `adb install` through their own "security centre", which can return
+3
View File
@@ -90,6 +90,8 @@ reference file is not named here, or when a script is not named here.
| A `dlopen`-able `.so` will not load after a custom loader, or a repaired `soinfo` resolves symbols to garbage | `linker-and-soinfo-repair.md` — bias versus base, `seg_page_offset`, the defining library's bias, `APS2` packed relocs, the minimal `soinfo` field set, and the dump window after `LoadSegments` | | A `dlopen`-able `.so` will not load after a custom loader, or a repaired `soinfo` resolves symbols to garbage | `linker-and-soinfo-repair.md` — bias versus base, `seg_page_offset`, the defining library's bias, `APS2` packed relocs, the minimal `soinfo` field set, and the dump window after `LoadSegments` |
| A native trace has no `cmp`/`sub`/`jcc` — only `and/or/not/shr/neg`, a flags slot, and a `ret` that lands at a VM entry | `vm-protector-analysis.md` — virtual eflags is data, NAND lowering, branchless select, data-anchored breakpoints, and trace-then-search-by-constant; dispatcher slicing stays in `native-vm-recovery.md` | | A native trace has no `cmp`/`sub`/`jcc` — only `and/or/not/shr/neg`, a flags slot, and a `ret` that lands at a VM entry | `vm-protector-analysis.md` — virtual eflags is data, NAND lowering, branchless select, data-anchored breakpoints, and trace-then-search-by-constant; dispatcher slicing stays in `native-vm-recovery.md` |
| The logic you need is Python bytecode — a `.pyc`/PyInstaller/Pyarmor payload rather than Java, Dart or native | `python-bytecode-recovery.md` — key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing and the extra-section TLV; static and offline, then call the recovered module | | The logic you need is Python bytecode — a `.pyc`/PyInstaller/Pyarmor payload rather than Java, Dart or native | `python-bytecode-recovery.md` — key schedule, AES-CTR nonce rules, the 12-byte VM, version-gated `pyc` parsing and the extra-section TLV; static and offline, then call the recovered module |
| A Lua decompiler rejects every script with **`non-standard lua format: <n>`** | `unity-lua-and-assetbundles.md` §2 — a changed Lua 5.1 header byte, not encryption |
| A re-signed Unity/Mono build exits cleanly with code 4 about two seconds in, with no Java exception | `unity-lua-and-assetbundles.md` §5 — a publisher shell owns the process |
_70 row(s) below the header._ _70 row(s) below the header._
@@ -155,6 +157,7 @@ _70 row(s) below the header._
| `references/on-device-tooling.md` | Working **from the phone itself**: MT Manager edit/repack/sign and its built-in APK MCP, LSPosed Manager, Termux+frida, and on-device data inspection | | `references/on-device-tooling.md` | Working **from the phone itself**: MT Manager edit/repack/sign and its built-in APK MCP, LSPosed Manager, Termux+frida, and on-device data inspection |
| `references/split-apk.md` | The target is a **split APK / App Bundle set** (`base.apk` + `split_config.*.apk`), or `pm path <PKG>` returned several files: reading a set, merge versus unified re-signing, and the install refusal each mistake produces | | `references/split-apk.md` | The target is a **split APK / App Bundle set** (`base.apk` + `split_config.*.apk`), or `pm path <PKG>` returned several files: reading a set, merge versus unified re-signing, and the install refusal each mistake produces |
| `references/unity-runtime.md` | The package is **Unity**: telling Mono from IL2CPP, dumping `libil2cpp.so` + `global-metadata.dat` with Il2CppDumper and importing it into IDA in the order that works, a run-time lookup over frida-il2cpp-bridge, the dnSpy-Unity-mono patch for a Mono player, and the audit probes when the deliverable is a report | | `references/unity-runtime.md` | The package is **Unity**: telling Mono from IL2CPP, dumping `libil2cpp.so` + `global-metadata.dat` with Il2CppDumper and importing it into IDA in the order that works, a run-time lookup over frida-il2cpp-bridge, the dnSpy-Unity-mono patch for a Mono player, and the audit probes when the deliverable is a report |
| `references/unity-lua-and-assetbundles.md` | A Unity game keeps its logic in **Lua** (xLua/tolua/SLua), or the edit is in an AssetBundle: finding and decrypting the scripts, the Lua 5.1 header tamper, bundle CRC in the manifest the game actually reads, partial-encryption windows, UnityFS rebuild traps (layout loss, stripped dependencies, compressed==raw), added/replaced TextAsset read-back, and half-encrypted Mono assemblies behind a publisher shell |
| `references/il2cpp-protected-metadata.md` | A Unity IL2CPP pair is **not readable**: `global-metadata.dat` is absent, 0 bytes, encrypted, embedded, or its version lies. Consumer-side dump, version-independent header sizing, the XOR/VM/XXTEA container shapes, the live-image dump, and the ELF repair that makes a dump usable | | `references/il2cpp-protected-metadata.md` | A Unity IL2CPP pair is **not readable**: `global-metadata.dat` is absent, 0 bytes, encrypted, embedded, or its version lies. Consumer-side dump, version-independent header sizing, the XOR/VM/XXTEA container shapes, the live-image dump, and the ELF repair that makes a dump usable |
| `references/python-bytecode-recovery.md` | The logic is **Python bytecode** behind Pyarmor or PyInstaller: key derivation, AES-CTR nonce rules, the 12-byte VM, a version-gated `pyc` parser, the extra-section TLV, and per-code-object / per-string decryption | | `references/python-bytecode-recovery.md` | The logic is **Python bytecode** behind Pyarmor or PyInstaller: key derivation, AES-CTR nonce rules, the 12-byte VM, a version-gated `pyc` parser, the extra-section TLV, and per-code-object / per-string decryption |
| `references/linker-and-soinfo-repair.md` | A protected `.so` must be loaded or dumped **by hand**: the `dlopen` pipeline as a loader spec, load_bias and segment arithmetic, `DT_*` parsing, relocation rules and the two biases, the minimal `soinfo` repair set, anti-dump header XOR, and where a dump is valid | | `references/linker-and-soinfo-repair.md` | A protected `.so` must be loaded or dumped **by hand**: the `dlopen` pipeline as a loader spec, load_bias and segment arithmetic, `DT_*` parsing, relocation rules and the two biases, the minimal `soinfo` repair set, anti-dump header XOR, and where a dump is valid |
@@ -141,6 +141,39 @@ it also fails, the problem is environmental (`references/tls-and-cert.md`,
- **Certificate pinning to the app's own signature** is a different problem: it is verified, - **Certificate pinning to the app's own signature** is a different problem: it is verified,
not used as a key. See `references/tls-and-cert.md`. not used as a key. See `references/tls-and-cert.md`.
## Variant: the value is an input to the digest, not the key
A different failure with the same source. A signer is reconstructed from static analysis and produces
a signature the server refuses, while every ingredient visible in the request looks right. The formula
turns out to be `sig = prefix + H(input || salt || key)`, and `salt` never appears in the request — it
is generated at init from the certificate and cached in a global. (The certificate origin is
`unverified` here; it is the same mechanism as the key case above, which is documented and likewise
unmeasured.)
**Why it defeats black-box search: the search space is missing an argument.** Trying MD5/HMAC/SHA
combinations over the visible parameters cannot find a value that is concatenated inside the digest and
never transmitted. The symptom is *uniform* failure, not near-misses — that is the tell, and it is
also why this is misread as "the algorithm is not fully recovered". (`observed`, host, synthetic: a
36-combination search over three algorithms and four field orders returns zero hits against a digest
with a hidden 16-byte salt, and returns the target the moment the salt is included — see the
EXTENSION record.)
How to get it:
- **Find the buffer.** It is written once (during `JNI_OnLoad` or the first signature call), it is a
fixed-size array, and no exported function returns it. A memory read after init is enough.
- **Or hook the digest update** and dump its argument on one request; the salt is the constant run
inside an otherwise changing buffer.
- **Verify with three captured triples** that vary one field each. A formula that matches all three is
the formula; one that matches one is a coincidence. (`inferred`.)
Consequence for the deliverable: the salt is per build and per certificate. A local signer carries the
captured constant plus a build fingerprint (the same discipline as an extracted VM program,
`native-vm-recovery.md` §11), and the report says which build it came from. On update the value
changes and the signer must be re-derived — do not present the constant as an algorithm.
(`inferred` from the certificate binding, not measured.)
## Cost of getting this wrong ## Cost of getting this wrong
Without this step the task stalls in the worst possible way: the artifact is correct, the Without this step the task stalls in the worst possible way: the artifact is correct, the
@@ -221,6 +221,28 @@ the attribute chunks around it, which is what `apktool` is for — and note that
`apktool b` rebuild rewrites the whole archive `apktool b` rebuild rewrites the whole archive
(`references/repack-and-sign.md` §Repacking an unpacked (de-shelled) app). (`references/repack-and-sign.md` §Repacking an unpacked (de-shelled) app).
### A narrow manual merge through apktool (when bundletool is unavailable)
The rule above is the safe one: do not fold resource tables by hand. There is one exception narrow
enough to name — a set whose resource splits are **additive** (density or language variants that do not
redefine an existing name with a different id). The source's native case did this and installed the
result as a single APK:
1. Install the base as an apktool framework: `apktool if base.apk -p <dir> -t <tag>`.
2. Decode each split with the same `-p/-t` so its resources keep their **original ids** instead of
being renumbered by the decoder.
3. Copy the split's `res/` files into the base and add their ids to the base's `public.xml`. Skip a
name that already exists with the same id; replace `APKTOOL_DUMMY_0x...` names by looking the real
name up in the base's id table.
4. Copy `lib/<abi>/` into the base. In the manifest, remove `requiredSplitTypes`, `splitTypes`,
`vending.splits` and `stamp.*`, and set `extractNativeLibs="true"`.
5. Verify every resource reference resolves and the app renders the split-only content. If two members
define the same resource name with different ids, **stop** — that is the folding problem the first
rule warns about, and bundletool is the route.
This is a per-set workaround, not a resource merger. Say in the delivery which splits were folded and
which resource families they carried.
## 6. Install refusals, and what each one means ## 6. Install refusals, and what each one means
| Message | What it actually says | Attribution | | Message | What it actually says | Attribution |
@@ -0,0 +1,221 @@
# Unity + Lua, AssetBundles, and half-encrypted Mono assemblies
Load this when a Unity APK keeps its game logic in Lua (xLua / tolua / SLua), when the thing you need to
edit is an AssetBundle rather than an assembly, or when a rebuilt Unity package fails in a way that
looks like the patch: a decompiler rejects every script, a bundle loads as null, a repacked bundle
crashes only on device, or a re-signed Mono build exits cleanly a second or two after the splash. It
is the script-and-asset half of Unity; `unity-runtime.md` owns Mono/IL2CPP identification and the
managed-code route, and `il2cpp-protected-metadata.md` owns protected IL2CPP metadata.
**Claim strength.** Absorbed from a public game-preservation skill's anonymised case reports: one
Unity + Lua target (1,443 encrypted TextAssets, a Lua bundle, CRC in an AssetBundle manifest) and one
Unity Mono + SLua target (8,420 Lua 5.1 TextAssets, a publisher shell that decrypts the first 4 KB of
each assembly, a 1.2 GB micro-client). The source reports these as work performed on real devices;
**this repository has run none of it** — no Unity package was decrypted, no bundle rebuilt, and no
Mono assembly reconstructed here. Every mechanism below is therefore `unverified`, and the counts
and offsets are the source's, not this repository's measurements. What generalises is the failure
shape, not the constants.
## 1. Recognise the shape before choosing a tool
| What is in the package | Where the logic is | Route |
|---|---|---|
| `libunity.so` + `libmono*.so` + `assets/bin/Data/Managed/Assembly-CSharp.dll` | C# IL | `unity-runtime.md` §Mono |
| `libunity.so` + `libil2cpp.so` + `global-metadata.dat` | native + metadata | `unity-runtime.md` §IL2CPP |
| `libunity.so` + a `luascript` bundle or thousands of Lua `TextAsset` entries | Lua source or Lua 5.1 bytecode | this file §2 |
| `assets/AssetBundles/<platform>/` with per-bundle `.manifest` files | assets, prefabs, textures, sometimes scripts | this file §3–§4 |
| `Application` is a vendor shell class + `libtprt.so` / `__tpinfo.tsa` | shell decrypts managed assemblies at run time | this file §5 |
The first question is not "how do I decrypt Lua" but **which layer owns the behaviour**. A Lua game
can have almost no interesting C#: the C# boots the engine, loads a bundle and calls into Lua. In that
shape, editing IL is the wrong layer even when the IL is readable.
## 2. Getting Lua out of a Unity package
### 2.1 Find the container and the key
Scripts usually live in one of three places: a dedicated bundle such as `luascript`, individual
`TextAsset` entries inside many bundles, or a loose file list such as `all_lua_files.lua` (which is
often the one plaintext index that names the rest). Locate the loader first: a C# method with names
like `LuaScriptKey`, `ScriptKey`, `Key()` or `LuaRuntimeConfig` is where the key is chosen.
The source's case A: 1,443 `TextAsset` entries, DES-CBC, and **`key == IV ==` an 8-byte constant**
taken from `LuaRuntimeConfig.LuaScriptKey()`. Do not assume every script is encrypted: in that case
`all_lua_files.lua` was plaintext. Decrypt a sample, then prove the output is a script (it parses,
and its first line is plausible Lua) before batch-processing 1,443 files.
Patterns worth recognising without reversing the decryptor:
- **Header-only tamper.** A Lua 5.1 chunk starts with signature `1B 4C 75 61` and version `51`;
the next byte (offset 5) is the format byte, normally `00`. A build that changes it to `01` makes
`unluac` say *"non-standard lua format: 1"* while the rest of the file is untouched. Compare the
first 12 bytes with the standard header before concluding "encrypted".
- **A single-byte XOR tail** with a strongly encrypted head (see §5 for the assembly version). The
tell is the plaintext zero: deep in the file, the same byte repeats in long runs. One byte of XOR
turns every plaintext zero into that byte.
- **A "decrypt" that is only a wrapper.** Before implementing a cipher, check whether the transform
cancels (a repeating XOR with a fixed key, or a stream cipher applied twice). `protocol-reverse.md`
§7 has the differential probe for classifying a primitive; use it when the shape is not obvious.
### 2.2 Repair the header, then decide what the loader accepts
For the byte-5 tamper, copy the standard 5.1 header over the first 12 bytes, then decompile one file.
If the opcodes were not shuffled, the output is clean source; if the decompiler produces nonsense,
the build may also have shuffled opcodes, which is a different problem.
The other half is the loader: the C# call that loads a chunk often takes a mode/`bytecodeOnly` flag.
If the bundle path loads with `bytecodeOnly == false`, your patch can be **plaintext Lua** — no need
to find a matching 32-bit `luac`. If it is true, recompile the module to the exact Lua version and
ABI, or patch the loader to accept source. Read the call site, do not guess from the file extension.
Batch decompilation is CPU-bound per file (a JVM start per script in the source's toolchain); run it
in parallel and keep the output indexed by entry name, because the next step is a lookup, not a read.
### 2.3 Verify content against entry names
Lua 5.1 bytecode stores its source name immediately after the header (for example
`@UI/reputationshop/shop.lua`). After a batch decompile, compare **the entry name with the chunk
name** before analysing anything. In the source's case, 112 files decompiled to the same unrelated
file because their bundle writer had cloned a template object and `read()` kept returning the
template's bytes. The game itself was fine; only the analysis copy was wrong.
The same warning applies to a hot-update merge: if your bundle wrapper replaces `main.lua` but
`read()` still returns the packaged original, the build patches the **old** script, and the
hot-update version's constants silently disappear. Keep a sidecar map of every byte you write
(replacements and additions) and make your reader return it first; then compare the bytes read back
with the hot-update file before trusting a patch.
## 3. AssetBundle integrity: the CRC is not where you guess
Unity verifies a bundle's CRC when it loads it. The value can live in:
- `<bundle>.manifest` next to the bundle, and
- `assets/AssetBundles/<platform>/AssetDatabase.manifest` (the catalogue).
Guessing which one is live costs a full round. **Run the unmodified build once and read the log** —
Unity prints both values:
```text
E/Unity: CRC Mismatch. Provided d906612, calculated ab764880 from data.
Will not load AssetBundle 'luascript'
```
Change the manifest the game actually reads (the catalogue in the source's case, not the same-named
bundle manifest) to `0` (skip) or to the computed value. Then verify the bundle loads, not only that
the error disappeared.
**An 8-byte zero prefix is not corruption.** In the source's case A, 2,354 of 2,355 bundles began with
eight `0x00` bytes in the original package; the only exception was the catalogue. All of them loaded.
An earlier pass "repaired" 13 of them and carried the damage into the next baseline. Count the prefix
across the original package before treating it as a fault; skip it on read and preserve it on write.
### 3.1 A bundle whose first block will not decompress
The shape is: a valid `UnityFS` header, the first compressed block fails to decompress, later blocks
are fine. That is a **partial-encryption window**, not a corrupt download. To bound it:
1. Parse the UnityFS header and block table yourself; decompress each block independently and record
which blocks fail.
2. Entropy-scan the failing block's compressed stream. A sharp drop in entropy marks the end of the
encrypted window.
3. Run the block's compressor (often LZ4) directly over the ciphertext; the byte offset where it
crashes is the start of the window.
4. Compare the start/end across several bundles. The source found 1,691 bundles with the same
`[56:4096]` window, which proves a build-wide scheme rather than per-file damage.
5. XOR two ciphertexts from different bundles: if the transform is a fixed stream cipher, the
plaintext-derived difference is stable. That tells you the shape, not the key.
Only after this do you know what you are missing: the key or the algorithm. Do not rebuild the
bundles before the window is pinned.
## 4. Rebuilding a bundle without changing it
A bundle is a serialized container, not a zip. Two independent traps:
**The rewriter changes the header/layout.** UnityPy's `save_typetree` can produce a much smaller
serialized file than the original (the source saw 6,700 → 3,552 bytes) because it drops the original
header layout and alignment padding. Compare the object metadata and header of old and new files; if
they differ, pad/restore the original layout before writing the bundle back. For a texture, render the
new text with the game's own font and encode it back to the original format (ETC2 in that case); do
not assume a PNG round-trip is equivalent.
**A stripped resource is still in the dependency graph.** If you remove an AssetBundle but leave the
`AssetBundleManifest` listing it as a dependency of a retained bundle, Unity returns **null** for the
retained bundle. Remove the dependency edges when you remove the assets, not only the files.
**The compressed-size edge case.** A rebuilt bundle can crash where a block's compressed size equals
its raw size — the loader takes a branch that assumes compression. Do not debug this inside a full
build. Replace one hand-made bundle into an existing signed APK, re-align and re-sign, install and
cold-start; each experiment is about a minute. Write a minimal UnityFS reader that lets you change one
block size, one compression flag or one field at a time, and keep a control bundle that differs in
nothing. That is how the source found the exact equality that broke the load.
### 4.1 Adding or replacing a TextAsset
When a Lua script is added to an existing bundle, the writer has to create a new serialized object and
update the container index. Two checks make this safe:
- **Keep the bytes you wrote.** Do not rely on a library's `read()` after `set_raw`/`save_typetree`;
some versions return the template object or the original bytes. Store the written payload in a
sidecar map and serve it on read.
- **Verify entry name and chunk name agree**, for every added and every replaced script. Then verify
the bytes read back equal the source file you intended (especially after merging a hot-update
layer). A build that patches the old script is indistinguishable from a patch that did nothing.
## 5. Mono assemblies: half-encryption, a rebuilt PE header, and the publisher shell
This is a different shape from a packed dex. The assembly file is present and looks like a PE, but its
first `0x1000` bytes are strongly encrypted and the rest is XORed with one byte. The tell is the same
as §2: deep in the file, one value repeats in long runs, because plaintext zeros became that value.
Autocorrelation does not show a period; the repeated value does.
To read it without reversing the runtime's decryptor:
1. XOR the tail with the single byte.
2. Rebuild the PE header from structural landmarks rather than guessing offsets: the
`_CorDllMain`/`mscoree.dll` import, the `FF 25 00 20 40 00` entry trampoline, the `.reloc`
block that points at it, `VS_VERSION_INFO` in `.rsrc`, and the `BSJB` metadata root.
3. Watch for an extra `.sdata` section (static-field initial values): it appears as a hole between
`.text` and `.rsrc` and as a file offset `0x400` instead of `0x200` for `.text`. Missing it
makes ILSpy report *"Field data (rva=...) could not be found in any section"*.
4. Accept the boundary: methods whose bodies lived in the first 4 KB are lost (the source counted 87
small constructors and 123 getters across two assemblies). Static analysis of the rest still works.
**The publisher shell changes the plan.** If `AndroidManifest`'s `application` is a vendor class
(for example a `TPShellApplication`) and `lib/` contains its runtime, the shell checks the APK
(signature/CRC/package) and kills the process about two seconds after launch. The symptom is
`Process ... exited cleanly (4)` with **no Java exception** and no tombstone. Do not read that as a
normal crash. The same shell often decrypts the assembly heads, so removing it also removes the thing
that made the assemblies readable.
The source's route: switch the shell off through its own dex string constants (same-length value
change, then recompute the dex header's SHA-1 and adler32), and recover the plaintext assemblies from
the **original game's process memory** — root, read `/proc/<pid>/maps`, stream anonymous regions,
locate the known XORed body, and restore the DOS header the shell zeroed. That route is specific to
that shell; the general rule is: identify the shell's own kill signal and its own string gate before
patching, and do not ship a rebuild while the shell still owns the process. Shell identification and
the keep/drop decision are in `packers.md` and `code-virtualization-and-custom-linkers.md`;
`advanced-unpacking.md` owns the memory-dump boundary.
## 6. Verification
A Unity asset patch is done when:
- the bundle **loads** (the CRC error is gone, and no null bundle appears in the log);
- the script's **entry name, chunk name and decompiled content** agree;
- a replaced script's bytes read back byte-identical to the source you wrote;
- an added entry exists in the container index and is returned by the loader;
- the on-device screen shows the change, after a cold start, on the same build you installed;
- a control build with **no** patch shows the old behaviour on the same device.
A hash of the APK is not evidence that the bundle inside it changed — check the bundle entry, not the
APK size. Signing and alignment stay in `repack-and-sign.md`.
## 7. Boundary
- **IL2CPP metadata and native code** — `unity-runtime.md` and `il2cpp-protected-metadata.md`.
- **A packer or a self-terminating native check** — `packers.md`,
`code-virtualization-and-custom-linkers.md`, `native-tamper-and-suicide.md`.
- **Crypto classification** — `protocol-reverse.md` §7; do not implement a cipher from a guess.
- **The game's network layer** — `protocol-reverse.md` and `server-api.md`.
- **Splitting, signing and package rename** — `split-apk.md` and `repack-and-sign.md`.
@@ -140,6 +140,52 @@ the same rule as `pitfalls.md` P47.
actually loads — a split or stubbed `libil2cpp.so` inside the APK is not necessarily the one mapped actually loads — a split or stubbed `libil2cpp.so` inside the APK is not necessarily the one mapped
(`native-and-so.md`). (`native-and-so.md`).
### When the managed layer is itself the interpreter
IL2CPP is ahead-of-time compiled, which makes it tempting to read `libil2cpp.so` as the only code that
matters. A `.so` that looks like a thin wrapper over `Dictionary` and delegate calls is often sitting
on top of an interpreter written in C# — and a VM written in C# is recoverable from `dump.cs` without
ever reading an opcode handler in assembly. The shape in `dump.cs`:
```text
class <obf> {
int[] aa1; // the guest program, built from a literal
int aa5; // the cursor, i.e. the PC / vEIP
Dictionary<int, Action> aa8; // opcode -> handler
}
```
A `while` loop that reads `array[cursor]` and calls `dict[op]` is the dispatcher; the array initialised
from a literal and the dictionary filled in the constructor are the program and the handler table. The
handler *indices* are assigned in the constructor by walking an enum or a `static_fields` block (one
sample enumerated 1..22 and used those values as dictionary keys), so the opcode→handler map is a
property of the constructor, not something to discover by tracing. Read the constructor first, rename
the fields positionally to `a1..aN`, delete the null and length guards, and the dispatch loop becomes
plain control flow. If the program array is built at run time, hook the constructor and take its
argument instead of tracing the loop.
The recovery method does not change once you have the instruction stream — `vmp-differential-analysis.md`
for the opcode map and `native-vm-recovery.md` §11 for the artefact set. What changes is the cost: a
managed VM is read statically, in a decompiler that still has names.
### Array literals are not in `.rodata`
A static array literal — a crypto key, an S-box, a constant table — has **no inline initialiser in
`libil2cpp.so`**. IL2CPP stores the field's default value in the metadata and materialises it at class
init by calling `RuntimeHelpers::InitializeArray` (the managed-side name; the implementation copies
from the field-default blob). Consequences for both reading and searching:
- `grep`-ing the `.so`, or `strings`-`ing` it, cannot find the table, and its absence is not evidence
that the table is derived at run time.
- Hook `InitializeArray` (or break on it) and the argument is the table; the same bytes are also
readable from the metadata field-default blob without a device.
- The table is per-field, so one hook gives you every literal the class initialisation touches, which
is usually the whole key schedule of a hand-rolled cipher.
This is the cheapest way to answer "where does this constant come from" in a Unity target, and it is
cheaper than reconstructing the cipher. `unverified`: the API name is stable across Unity versions, the
argument shape is not.
## 5. Driving IL2CPP at run time: frida-il2cpp-bridge ## 5. Driving IL2CPP at run time: frida-il2cpp-bridge
When the dump is encrypted or the question is behavioural, the bridge resolves classes by name at run When the dump is encrypted or the question is behavioural, the bridge resolves classes by name at run
@@ -183,6 +229,23 @@ directory; with no arguments it uses defaults that may not be writable on a hard
written before the metadata is decrypted is the encrypted file again — check the magic before written before the metadata is decrypted is the encrypted file again — check the magic before
importing it. importing it.
**Hook the framework primitive, not the app's wrapper.** Obfuscation renames the app's classes; it
does not rename `System.Security.Cryptography.*`, `javax.crypto.Cipher` or `java.security.*`. So when
the question is "what key does this use", trace the primitive instead of the wrapper the app built:
```ts
Il2Cpp.trace(true).classes(Il2Cpp.domain.assembly("System.Security.Cryptography")
.image.class("System.Security.Cryptography.AesCryptoServiceProvider")).and().attach();
```
One such trace reports every key/IV pair the process constructs, no matter which wrapper or
obfuscated call chain produced it, and it removes the need to reconstruct the derivation. On the Java
side the equivalent pair is a hook on `Cipher.getInstance` plus `SecretKeySpec` / `IvParameterSpec`.
The trade is provenance: the primitive tells you the value, not which call site asked for it — use the
app's own class (above) when you need the call site, and the primitive when the derivation is hostile
and you only need the material. `unverified` here: neither trace was run in this record.
The dependency is the boundary: a build that hides or strips the il2cpp exports breaks the bridge, and The dependency is the boundary: a build that hides or strips the il2cpp exports breaks the bridge, and
the failure presents as *class not found* — indistinguishable from a wrong class name. Confirm the the failure presents as *class not found* — indistinguishable from a wrong class name. Confirm the
exports exist before believing a negative lookup. exports exist before believing a negative lookup.
+93
View File
@@ -0,0 +1,93 @@
"""The 2026-10-27 host fixture must be able to fail.
`docs/tool-verification/fixtures/verify_ref_claims_10c.py` is the only thing standing behind three
`observed` labels, so its checks are as load-bearing as a gate. The first draft failed the rule this
repository applies to gates: the comparison check counted iterations inside the Python loop it was
measuring, so `n == k + 1` restated its own source and could never fail for a real reason. It now
compiles the two comparators and measures the compiler's output.
Each test here injects the wrong claim and requires the check to reject it, plus one test that the
process exit code follows the verdict. `observed` on a host with neither `openssl` nor a C compiler
is a skip, not a pass.
"""
from __future__ import annotations
import importlib.util
import shutil
import pytest
from conftest import REPO_ROOT
pytestmark = pytest.mark.unit
FIXTURE = REPO_ROOT / "docs" / "tool-verification" / "fixtures" / "verify_ref_claims_10c.py"
@pytest.fixture(scope="module")
def claims():
spec = importlib.util.spec_from_file_location("verify_ref_claims_10c", str(FIXTURE))
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def _need_openssl():
if not shutil.which("openssl"):
pytest.skip("no openssl on this host: the CTR check degrades to SKIP")
def _need_cc():
if not (shutil.which("gcc") or shutil.which("cc") or shutil.which("clang")):
pytest.skip("no C compiler on this host: the comparison check degrades to SKIP")
def test_checks_pass_on_the_claim(claims):
_need_openssl()
_need_cc()
assert claims.ctr_nonce_tail() is True
assert claims.comparison_oracle() is True
assert claims.header_walk() is True
def test_ctr_check_rejects_an_unchanged_nonce(claims):
_need_openssl()
base = bytes(range(12)) + b"\x00\x00\x00"
same = base + b"\x02"
assert claims.ctr_nonce_tail(nonce_a=same, nonce_b=same) is False
def test_comparison_check_rejects_a_full_pass_mislabelled_early(claims):
_need_cc()
assert claims.comparison_oracle(early_source=claims.C_FULL) is False
def test_comparison_check_rejects_an_early_exit_mislabelled_constant(claims):
_need_cc()
assert claims.comparison_oracle(full_source=claims.C_EARLY) is False
def test_header_check_rejects_an_off_grid_start(claims):
assert claims.header_walk(start=0x110) is False
def test_header_check_rejects_ground_truth_that_disagrees(claims):
# the tail-most pair no longer sits at the largest offset, so "declared" and the forward scan
# cannot both be the file length
pairs = [(0x1100, 0x08), (0x1300, 0x10), (0x10A0, 0x10)]
assert claims.header_walk(pairs=pairs) is False
def test_main_exit_code_follows_the_verdict(claims, monkeypatch):
# a check that returns False without printing must still fail the run
monkeypatch.setattr(claims, "ctr_nonce_tail", lambda: False)
monkeypatch.setattr(claims, "comparison_oracle", lambda: True)
monkeypatch.setattr(claims, "header_walk", lambda: True)
assert claims.main() == 1
def test_main_treats_a_skip_as_not_a_failure(claims, monkeypatch):
monkeypatch.setattr(claims, "ctr_nonce_tail", lambda: None)
monkeypatch.setattr(claims, "comparison_oracle", lambda: True)
monkeypatch.setattr(claims, "header_walk", lambda: True)
assert claims.main() == 0