Files
apk-reverse/skills/apk-reverse/references/rasc-and-droidsaw.md
T
inliver233 9b159253c6 Adopt rasc (the Rust ASC) as the indexer, with its measured blind spot written down
The Python `droidasc` indexer works and is one `pip install` away, but the same project has a Rust
re-implementation on its `rust` branch, and this pass answers whether it can be used instead of the
Python one. It can, with one documented caveat. Everything below was measured here; nothing is taken
from the upstream README's numbers.

**What was built.** `rasc` publishes no artifact -- no release asset, and `cargo install rasc`
fetches an unrelated maths parser -- so adopting it means building it. rustup (gnu host, rustc 1.98.1)
plus a 64-bit MinGW-w64 gcc 16.1.0 as the linker, `cargo build --release` in **117 s**, producing a
2.13 MB binary from `MG1937/ASC@e809c7b` (rust branch, sha256 `1becdb86…c0264b`). The build traps are
recorded because they cost time here: the host's existing MinGW is **32-bit** and fails with
`sorry, unimplemented: 64-bit mode not compiled in`, E:\vs2022 has no VC tools, and the registered WSL2
distribution cannot start (`HCS_E_SERVICE_NOT_AVAILABLE`) -- so neither the MSVC nor the Linux path
was available.

**What it answers.** Same CLI shape as the Python tool (`classes` / `manifest` / `getclass` /
`findrefs {string,type,method,field}`), and on this repository's archives the answers match:

  MASTG UnCrackable-Level3 (1.4 MB)   classes 5.6x   findrefs string 15.6x   findrefs type 16.2x
  a real 34.8 MB app (30,768 classes) classes 4.0x   -- class sets IDENTICAL, 0 differences either way

`scripts/rasc_build.py` wraps the whole path -- `--check`, `--build`, `--verify <apk>` -- so the
verification travels with the kit instead of living in a note: `--verify` compares the class-definition
set against `droidasc` and fails on any difference. It resolves the repository root by walking up
rather than assuming a layout, prepends a non-default `CARGO_HOME` to PATH, and reports a missing
toolchain as exit 3 with the install step.

**The blind spot, and why the rule is a rule.** The rasc project ships its own JADX-parity harness.
Run here on a fair sample (app-like classes; the harness refuses to judge a class JADX cannot
decompile), 17 of 20 were judged and 16 matched literal-for-literal with 0 reorderings. The one
difference is not cosmetic: `org.bouncycastle.crypto.PasswordConverter` is an enum whose constants
override a method, JADX emits the three anonymous subclasses with their `convert` / `getType` bodies,
and **rasc emits a bare constant list -- the bodies are gone and no warning is emitted**. Clean,
plausible, incomplete output is precisely the failure shape this repository catalogues, so:

  use rasc to locate, and to read ordinary classes; confirm an enum that shows no bodies with a
  second reader; keep droidasc and JADX as the cross-checks the skill already requires.

The automated verdict said "literals rasc lost: 1", which understates it -- counting literals cannot
see a dropped body. That is recorded in the evidence file rather than smoothed over.

**What changed in the kit.** `references/rasc-and-droidsaw.md` (the measurements, the failing class,
the build traps, provenance); `scripts/rasc_build.py`; `toolchain.md` Tier 1 now lists `rasc` first
with `droidasc` as the fallback and the cross-check; README structure and script tables; the evidence
record `docs/tool-verification/EXTENSION-rasc.md`.

**One inconsistency this exposed and fixed.** `check_repo.py` looked for a reference or script name in
`SKILL.md` + the README only, while this repository's reference inventory lives in
`references/routing.md` -- so a correctly registered file was reported as orphaned, and the script
half of that check was not actually running. The registration surface is now SKILL.md + README +
`references/routing.md`, nested reference directories are read too, and a planted unregistered script
was used to confirm the check still fires.

Gates: check_repo 0 problem, check_refs 0 dangling / 0 warning, check_routing coherent, check_budget
0 failure / 0 warning, check_commands 154 checked / 0 drift, pytest 625 passed / 163 skipped /
25 xfailed.
2026-09-22 19:38:50 +08:00

8.1 KiB
Raw Blame History

rasc and droidsaw — the Rust ASC, and what it changes about the indexer-first workflow

Load this when: you are about to reach for droidasc (ASC) to locate classes or references, or when the Python indexer is the bottleneck on a real archive. It states what the Rust re-implementation is, how it was measured here, and the one class shape where it silently loses code — which is the part that decides whether you use it alone or keep a second tool next to it.

When to prefer it, in one line: rasc is the same interface with the same answers, several times faster, and one measured blind spot; use it as the indexer, keep droidasc and JADX as the cross-checks the rest of this skill already requires.

What it is

MG1937/ASC has two implementations on different branches. main is the Python tool this skill already documents (pip install droidasc). The rust branch is rasc, a re-implementation that keeps the CLI shape and drops the Python runtime:

Python droidasc main rasc (rust branch)
Runtime CPython + androguard none — one static-ish binary, 2.13 MB
Decompiler behind getclass androguard's droidsaw-dex 2.0.0 (pure Rust; its project advertises byte-identical DEX re-emission on F-Droid)
Install pip install droidasc must be built — no release asset, no crate (cargo install rasc fetches an unrelated maths parser)
Commands listclass getmanifest getclass findrefs classes manifest getclass findrefs
Flags --prefix on listclass --filter on classes (case-insensitive substring, not a prefix)
Shared flags --threads/--thread, -o/--output, --debug same, plus --debug prints phase timings on stderr

scripts/rasc_build.py wraps the build and the verification, because a build only one machine has performed is a build nobody else can reproduce: --check reports what is present, --build clones and compiles, --verify <apk> compares the class-definition sets against droidasc and fails if they differ.

Measured here

Environment: Windows 11, rustup stable-x86_64-pc-windows-gnu (rustc 1.98.1), MinGW-w64 gcc 16.1.0 (UCRT, 64-bit) as the linker. Build from a clean checkout: 117 s, cargo build --release with FatLTO. Binary rasc 0.1.0, 2,236,416 bytes, sha256 1becdb86b444fe7910589f8ade5bccf13794de9f2b466a1c07748b5669c0264b, from MG1937/ASC@e809c7b4b454ebc8eb4467f56d44a82e6139472b (rust branch).

Two archives, fastest of N runs, same machine, PYTHONUTF8=1 for the Python side:

Archive Scenario rasc droidasc ratio answers
MASTG UnCrackable-Level3.apk (1.4 MB) classes 0.025 s 0.116 s 4.7× identical set (1396 / 1396)
findrefs string http 0.021 s 0.299 s 14.0× identical (3 / 3)
findrefs type String 0.021 s 0.307 s 14.7× rasc superset (390 vs 384)
getclass ×2 real classes 0.086 / 0.082 s 0.297 / 0.267 s 3.3–3.5× both emitted Java
a real 34.8 MB app (30,768 classes) classes 0.048 s 0.190 s 4.0× identical set, 0 differences both ways

The speedup is smaller than the upstream README's geometric mean of 8.0× because that figure was measured on a 343 MiB archive with 567k classes, where startup cost disappears; on a mid-size app the Python runtime's import time keeps the ratio near 4×. Both are real, and the small-archive numbers are the ones a normal task hits.

python skills/apk-reverse/scripts/rasc_build.py --verify <apk> reproduces the class-set comparison and is the check to run after any rebuild.

The blind spot: abstract enum constants lose their bodies

bench/jadx_parity.py from the rasc repository compares string literals between JADX and rasc per class, counting a literal JADX has and rasc does not as a lost-code signal. Run here on a fair sample — app-like classes, no obfuscated identifiers, since the harness itself refuses to judge a class JADX cannot decompile — 20 classes picked, 17 judged, 1 with a difference, 0 reorderings.

The one difference is not a formatting artefact. org.bouncycastle.crypto.PasswordConverter is an enum whose constants each override an abstract method:

// JADX
public enum PasswordConverter implements CharToByteConverter {
    ASCII { // from class: ...PasswordConverter.1
        @Override public byte[] convert(char[] cArr) { ... }
        @Override public String getType() { return "ASCII"; }
    },
    ...
// rasc
public enum PasswordConverter implements org.bouncycastle.crypto.CharToByteConverter {
    ASCII,
    UTF8,
    PKCS12;
    public PasswordConverter() { }
    public PasswordConverter(PasswordConverter$1 v3) { }
}

Both the per-constant method bodies and the string literals are gone, and rasc emits no warning that anything was dropped. The output is clean, plausible, and incomplete — the same failure shape pitfalls.md is a catalogue of. So the rule for this layer is a rule, not a preference:

  • Use rasc getclass for locating and reading ordinary classes. That is what it was measured on.
  • When the class is an enum with constant-specific bodies, confirm with a second reader (droidasc getclass, or JADX). A collapsed enum is visible on sight: the constants are printed as a bare list and no method bodies follow. Treat "enum with no bodies" as unverified output, not as "this enum has no logic".
  • Never treat a single decompiler's output as the definition of what exists. This is the same rule the VMP section states about opcode tables, applied to a class body.

Frequency matters for calibration: 1 of 17 judged classes here, and the other 16 agreed literal for literal. So the correct posture is adopt, with the cross-check kept, not "reject" and not "drop the Python tool from the kit".

What it does not change

  • The workflow. The indexer is the same stage it always was: rasc answers location questions, and reading a class you have already located is what a decompiler is for. It does not decompile a whole APK into a project, and neither does the Python tool.
  • The verification discipline. Every claim above is a measurement with a command behind it; where rasc and droidasc disagree in the tables, the disagreement is recorded rather than averaged away.
  • Packer behaviour. On this repository's hardened sample both tools correctly return 4 classes — the payload is encrypted inside the shell and is not in any DEX either tool can read. A small class count on a hardened target is the target, not the tool.

Building it yourself

python skills/apk-reverse/scripts/rasc_build.py --check          # what is present
python skills/apk-reverse/scripts/rasc_build.py --build          # clone + cargo build --release
python skills/apk-reverse/scripts/rasc_build.py --verify app.apk # compare against droidasc

Requirements and the traps measured here:

  • Rust 1.93+ (the crate is edition = "2024"; this build used 1.98.1) and git.
  • On Windows, the GNU host toolchain needs a 64-bit MinGW-w64 gcc. A 32-bit MinGW fails at link with sorry, unimplemented: 64-bit mode not compiled in — the fix is a 64-bit distribution (this build used winlibs gcc 16.1.0), not a flag.
  • The build fetches crates from crates.io; vendor/ in the repository only carries the two patched crates (axmldecoder, droidsaw-dex), so --offline fails with no matching package named anyhow.
  • cargo/rustc installed to a non-default CARGO_HOME are invisible to a non-interactive PATH; rasc_build.py prepends the known locations rather than reporting the toolchain as absent.

Provenance

https://github.com/MG1937/ASC (branch rust, commit e809c7b), retrieved 2026-09-22. https://github.com/droidsaw/droidsaw and https://crates.io/crates/droidsaw-dex (2.0.0), consulted 2026-09-22. The Python implementation is pip install droidasc (0.1.1.post1 seen here; 0.1.1.post2 published 2026-09-21). Nothing from either project is vendored into this repository — rasc_build.py clones it into the gitignored tools/_work/ and the measurements above name the commit they came from.