mirror of
https://codeberg.org/dabao1955/apk-reverse.git
synced 2026-11-28 03:50:22 +08:00
Four-state labels, and the negatives that used to look alike
Every claim carried one of three labels, and the third was doing two jobs. `unverified` meant
both "someone asserted it and nobody here paid for the counters" and "no evidence was gathered
at all" -- different statements with different next actions. This adds `unknown` for the second.
The distinction that pays for itself lives inside a *negative* result, because an empty probe has
three causes and only one of them is a finding:
absent -- coverage reached the question, nothing is there
present but unreadable -- the thing is there and this route cannot read it
unknown -- nothing covered the question
The middle one is the dangerous one: it produces byte-identical output to the first, and it is the
normal case on the input this skill is aimed at. A packed APK returning four classes is not an APK
with four classes, and "the string was not in the dex" is a statement about a probe. The rule now
says to name the probe's coverage and run a control that must hit before writing "not present", and
to record `unknown` about the probe rather than `absent` about the target.
Also in this pass:
* P47 -- two tools disagree about the same artifact, and the disagreement is your parser. One
extraction rule reused across outputs that do not share a format: an unescaped `$` dropped every
descriptor containing one, and dotted names were compared against DEX descriptors so one side
parsed to nothing. The comfortable failure is the one that confirms what you already expected,
which is why it survived the sanity check it should not have.
* dexsql: a cache is second-hand evidence and it ages silently. A stale cache answers for the old
artifact with no error, and `--trusted-input` skips revalidating the recorded source inputs --
so a cached run supports "true of the artifact the cache was built from", not "true of the
artifact in front of me".
* ete-diff-tracing: a divergence is a location, not a cause. The differential method produces a
positional claim, and three readings it does not authorise are written down beside the step that
produces it.
* CONTRIBUTING.md -- the gates, what a green run does and does not establish, the sync rules a
change has to keep (a new reference must be named in the inventory; renaming a heading breaks
every section reference that pointed at it), and the two failure modes to watch when editing the
gates: a limit that cannot fail, and a gate whose answer varies with the runner. README links it
from both language editions.
This commit is contained in:
1 parent
b8aa0a529b
commit
6ab905b2c8
12 files changed
+274
-6
No files matched your search
@@ -8,7 +8,7 @@ metadata:
|
||||
capability_registry: skills/apk-reverse/scripts/capabilities.py
|
||||
evidence_summary: skills/apk-reverse/references/evidence-summary.md
|
||||
last_reconstruction_pass: "2026-09-22"
|
||||
strength_labels: "observed | inferred | unverified"
|
||||
strength_labels: "observed | inferred | unverified | unknown"
|
||||
---
|
||||
|
||||
# APK Reverse Engineering & Patching
|
||||
@@ -102,13 +102,31 @@ that almost fits is more dangerous than no method at all, because it arrives wit
|
||||
vocabulary and a set of reassuring numbers.
|
||||
|
||||
**How strong these claims are — this is load-bearing, not cosmetic.** Every claim in this skill carries
|
||||
one of three labels, and you must label your own results the same way:
|
||||
one of four labels, and you must label your own results the same way:
|
||||
|
||||
| Label | Means | May it justify a decision? |
|
||||
|---|---|---|
|
||||
| `observed` | a command was run and its output exists | yes |
|
||||
| `inferred` | follows from an observation, but the step is reasoned | provisionally |
|
||||
| `unverified` | assumed, or reported elsewhere and never reproduced here | only as something to test |
|
||||
| `unknown` | nothing here covers it: no probe ran, or the probe's coverage did not reach it | no — and never as absence |
|
||||
|
||||
**A negative result has three shapes, and folding them together is the failure this section exists
|
||||
for.** `unverified` means somebody asserted something and nobody here paid for the counters; `unknown`
|
||||
means no evidence was gathered at all. But a probe that *did* run and came back empty means one of two
|
||||
different things, and only one of them is a finding:
|
||||
|
||||
- **absent** — the probe's coverage reached the question and the thing genuinely is not there;
|
||||
- **present but unreadable** — the thing is there and *this route* cannot read it: an encrypted payload
|
||||
inside a shell, a library the running ABI never loads, a check that fires before your hooks exist, a
|
||||
field that exists under a type your parser rejects.
|
||||
|
||||
The second is the dangerous one, because it produces byte-identical output to the first and it is the
|
||||
**normal** case on the hardened targets this skill is aimed at. A packed APK returning four classes is
|
||||
not an APK with four classes. So before "not present" goes into the record, name the probe that covered
|
||||
the question and run a control that must hit. If the control is silent too, the honest statement is
|
||||
`unknown` about **your probe**, not `absent` about the target — and the next move is a different probe,
|
||||
not a stronger conclusion.
|
||||
|
||||
**The inventory that replaces a guess:** the per-route list of what is covered and what is not — by
|
||||
verified mechanism versus by documented-but-mostly-inferred route — is in
|
||||
@@ -390,7 +408,7 @@ These are moments where continuing to push forward is the wrong move. Each has c
|
||||
| **Neutralise a native terminate path by returning, never by making it not return** | a spin stub freezes the caller **holding its lock**; unrelated threads wedge and the symptom (hang, external kill, restart loop) looks nothing like the cause, with no crash record | return a benign value, prefer success (`0`) over failure (`-1`), never touch `pthread_exit`/`exit`/`abort`/`snprintf`/`closedir`. `native-tamper-and-suicide.md` |
|
||||
| **Look before you conclude, and look while you wait** | a screen that is actually looked at answers in one step what coordinate-guessing cannot answer in five | capture **and inspect**; byte-identical samples mean nothing will change. `scripts/snap.py`, `environment.md` §look at the screen |
|
||||
| **Bound every command, and calibrate the bound from a measurement** | an unbounded call turns a stall into "still working", which is indistinguishable from progress | time the operation once, record it, derive the deadline from it. `long-task-discipline.md` §Bound every wait |
|
||||
| **Every claim carries a label — `observed`, `inferred` or `unverified`** | "probably", "should be" and "in theory" are not findings, and an unlabelled guess propagates as a fact | `observed` requires a command **and its output**; nothing else may be written as established |
|
||||
| **Every claim carries a label — `observed`, `inferred`, `unverified` or `unknown`** | "probably", "should be" and "in theory" are not findings, and an unlabelled guess propagates as a fact | `observed` requires a command **and its output**; nothing else may be written as established. A probe that did not reach the question is `unknown`, never `absent` |
|
||||
| **"Done" means the user-visible outcome** | a blocking dialog still on screen means the task is not done, however clean the log is | §What "done" means, all six items; absence of a log line is never evidence of success |
|
||||
| **Never discard a route on compound evidence** | if a failure followed two simultaneous changes, the attribution is a hypothesis — mis-attributed failures have removed viable routes for hours | re-run the abandonment single-variable before writing it down |
|
||||
| **Prove the device changed before measuring anything** | install success describes the *request*, not the app on disk | hash the on-device artifact against your build; otherwise every later observation describes the previous build |
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"strength_labels": {
|
||||
"observed": "A command was run and its output exists behind the claim.",
|
||||
"inferred": "Follows from a documented mechanism or a neighbouring measurement; the step itself was not executed.",
|
||||
"unverified": "Assumed, or reported by someone else, and not reproduced in this record."
|
||||
"unverified": "Assumed, or reported by someone else, and not reproduced in this record.",
|
||||
"unknown": "Nothing here covers it: not probed, or probed without the coverage to answer. Missing evidence, never a negative result -- do not read an `unknown` row as 'absent' or 'safe'."
|
||||
},
|
||||
"evidence_rules": [
|
||||
"Every path in `evidence` is relative to the installed skill root and resolves in an installed copy.",
|
||||
|
||||
@@ -15,6 +15,8 @@ take. Silence in this list is not support for a route; it means nobody here paid
|
||||
- **inferred** — follows from a documented mechanism or a neighbouring measurement; the step itself
|
||||
was not executed.
|
||||
- **unverified** — assumed, or reported by someone else, and not reproduced in this record.
|
||||
- **unknown** — nothing here covers it: not probed, or probed without the coverage to answer. Missing
|
||||
evidence, not a negative result.
|
||||
|
||||
A row whose strength is `unverified` is a statement about *this skill's evidence*, not about the
|
||||
mechanism's truth. It means nobody has yet put a command and its output behind it here.
|
||||
|
||||
@@ -18,11 +18,25 @@ what was and was not exercised. Load it when a claim's strength decides whether
|
||||
- **inferred** — follows from documented mechanism or from a neighbouring measurement; the step
|
||||
itself was not executed.
|
||||
- **unverified** — assumed, or reported by someone else, and not reproduced in this repository.
|
||||
- **unknown** — nothing here covers it: the question was never probed, or the probe's coverage did
|
||||
not reach it. This is missing coverage, not a negative result.
|
||||
|
||||
Reserve `observed` strictly (`references/long-task-discipline.md` does). "I reasoned it out" is
|
||||
`inferred`. The distinction is load-bearing, not cosmetic: an `inferred` route may still be right,
|
||||
but nobody here has paid for the counters yet.
|
||||
|
||||
**Read a negative result as `unknown` unless the probe's coverage is established, and check for the
|
||||
third state first.** An empty result has three possible causes and only one of them is a finding:
|
||||
**absent** (coverage reached the question, nothing is there), **present but unreadable** (the thing is
|
||||
there, and this route cannot read it), or **`unknown`** (nothing covered it). The second is the one
|
||||
that costs hours, because it is indistinguishable from the first and it is the *normal* case on
|
||||
hardened input: "the string was not in the dex", "the hook never fired", "no request reached the
|
||||
endpoint" each have a failure mode that produces the same empty output as a true negative — a query
|
||||
whose argument never arrived intact, a hook installed after the check that matters, a request refused
|
||||
before it was built. A small class count on a packed target is the payload being unreadable, not
|
||||
absent. Name the probe's coverage, run a control that must hit, and write `unknown` about the probe
|
||||
rather than `absent` about the target.
|
||||
|
||||
## Covered, by verified mechanisms — the evidence
|
||||
|
||||
- **Client-side ads, promos and splash/popup/tab configuration**, including the server-issued UI
|
||||
|
||||
@@ -32,6 +32,8 @@ what is *exempt*, in code, that can be read and argued with.
|
||||
- **inferred** — follows from an observed fact or from documented mechanism; the step itself
|
||||
was not executed.
|
||||
- **unverified** — assumed, or reported elsewhere, and not reproduced in this repository.
|
||||
- **unknown** — nothing here covers it: not probed, or probed without the coverage to answer. Missing
|
||||
evidence, not a negative result.
|
||||
|
||||
Claim strength in this file means *how well the statement about desensitization was measured*,
|
||||
not how confident the writing sounds.
|
||||
|
||||
@@ -127,6 +127,22 @@ parse-and-build path is already 0.12 s on this archive. Treat the cache as a way
|
||||
across many queries in a long session, not as a speed switch; on small archives it is a net loss
|
||||
(cache read 0.071 s against a 0.042 s direct query on the 38.7 MB sample).
|
||||
|
||||
**A cache is second-hand evidence, and it ages silently.** The cache keys on the artifact it recorded,
|
||||
and a stale cache answers for the **old** file with no error: query a rebuilt APK through yesterday's
|
||||
`cache.dxc2` and every count, string and caller list describes the previous build. Two consequences
|
||||
worth acting on:
|
||||
|
||||
- **The cache file is a separate object from the source.** "I queried this APK" is a claim you have to
|
||||
keep true yourself, the same way `repack-and-sign.md` requires the on-device hash before any later
|
||||
measurement means anything. Record the source path **and its hash** next to the cache, and rebuild
|
||||
after the artifact changes.
|
||||
- **`--trusted-input` skips revalidating the cache's recorded source inputs.** It exists for a
|
||||
controlled build pipeline, and reaching for it to make a suspicious artifact load converts a stale
|
||||
answer into an apparently fresh one. Do not use it on a target you are still investigating.
|
||||
|
||||
Scope the claim accordingly: a cached run supports "this was true of the artifact the cache was built
|
||||
from", not "this is true of the artifact in front of me".
|
||||
|
||||
**Read-only is enforced, and the error surface is uniform.** Missing class → `Error: not_found:
|
||||
selected file, method, or class not found`, exit 1. Missing input, a non-dex input, an unknown column,
|
||||
an unknown relation and a `DELETE` all exit 1 with a named cause; the write is refused.
|
||||
|
||||
@@ -122,6 +122,24 @@ pair was built to ask:
|
||||
same window, one-bit difference. A diff across two builds is noise with a confident
|
||||
rendering.
|
||||
|
||||
**A divergence is a location, not a cause.** Everything §4 produces is a positional claim: *these
|
||||
blocks execute only when input A is present*. That is already valuable, and it is routinely read as
|
||||
more than it is. Three upgrades it does **not** authorise on its own:
|
||||
|
||||
- **"this block validates the credential"** — it may be a downstream consequence of a decision taken
|
||||
earlier; the first divergence is the honest candidate for the decision, and even that is a
|
||||
candidate.
|
||||
- **"patching this block flips the outcome"** — untested until the patch exists and both inputs have
|
||||
been run through it (R2, single variable, with the unpatched run as control).
|
||||
- **"the blocks that matched are irrelevant"** — untested until a control run shows they stay matched
|
||||
when the outcome changes.
|
||||
|
||||
What promotes a candidate to a cause: step 5's swapped-input repeat, or a patch that moves the
|
||||
outcome and a control that does not. Until one of those has run, the finding to write down is "the
|
||||
first divergence is at X" — a place, with the evidence that it is input-dependent — and not "X is
|
||||
what decides this". The distinction is the same one `verification.md` draws between *the mechanism
|
||||
is proven* and *the behaviour changed*.
|
||||
|
||||
## 5. What the obfuscator actually built — read from two open implementations
|
||||
|
||||
The differential reads better when you know what the two families actually emit. The facts
|
||||
|
||||
@@ -1405,3 +1405,35 @@ data is still plaintext** — a JNI boundary beats a TLS interior every time. Ea
|
||||
the next layer: TLS-blind says "own crypto", dex-empty says "JS/native bundle", and the
|
||||
RegisterNative inventory turns "somewhere in libfoo" into a function address. *(Absorbed from a
|
||||
public write-up, 2026-09.)*
|
||||
|
||||
## P47. Two tools disagree about the same artifact, and the disagreement is your parser
|
||||
|
||||
**Symptom**
|
||||
Two indexers report different class counts for one APK: one says 647, the other says 38. Both exit
|
||||
cleanly, both print plausible output, and the smaller number has an innocent explanation ready to
|
||||
hand — a hardened target really does expose few classes — so the discrepancy is filed as "the tools
|
||||
disagree on packed input" and the investigation moves on with a wrong number in the record.
|
||||
|
||||
**Root cause**
|
||||
One extraction rule was reused across outputs that do not share a format. Two defects in one pass:
|
||||
an unescaped metacharacter in the pattern (`$` inside a class descriptor is an end-of-line anchor, so
|
||||
every name containing `$` or a non-ASCII character was dropped), and two different representations
|
||||
compared as if they were one (a tool printing dotted Java names against a tool printing DEX
|
||||
descriptors, so one side parsed to nothing). Neither is a property of the tools. The measurement was
|
||||
reporting the parser's blind spot and attributing it to the artifact.
|
||||
|
||||
**Why it is hard to see**
|
||||
Cross-checking tools is what this skill tells you to do, and the comfortable failure is the one that
|
||||
*confirms* something you already expect: a packed APK returning few classes is true, so the wrong
|
||||
number passes the one sanity check you were most likely to run. Both sides also produced output of
|
||||
the right *shape*, which reads as agreement.
|
||||
|
||||
**The rule**
|
||||
**A count disagreement between two tools is a claim about your parser until you have proved
|
||||
otherwise.** Parse each tool's own output with a parser written for that format, normalise both to
|
||||
one representation, and only then compare — and let the comparison carry its own control: a query
|
||||
whose answer you already know, pushed through the same path, before any "the tools disagree" verdict
|
||||
is recorded. Two traps recur: regex metacharacters that are legal characters in the data (`$` in
|
||||
descriptors, `[` in array types, `.` in package names), and representation mismatches that hide
|
||||
behind a matching line count. The encoding cousins of this failure are in `framework-runtimes.md`
|
||||
and the line-ending trap in `patch-audit.md`.
|
||||
@@ -18,9 +18,10 @@ are nothing of the kind:
|
||||
`scripts/repack.py` handles both routes and **refuses to guess**: it inventories the set, decides
|
||||
which route is legal from what the members actually carry, prints the reason, and only then acts.
|
||||
|
||||
**Strength labels** (same three this repository uses everywhere): **observed** = reproduced with an
|
||||
**Strength labels** (the same set this repository uses everywhere): **observed** = reproduced with an
|
||||
exact command and output; **inferred** = follows from observed facts, step not executed;
|
||||
**unverified** = reported or assumed, not independently confirmed. The measurements behind this
|
||||
**unverified** = reported or assumed, not independently confirmed; **unknown** = not covered here at
|
||||
all, which is missing evidence rather than a negative result. The measurements behind this
|
||||
file are recorded in `references/evidence-summary.md` §The capability matrix.
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user