Skip to content

feat(adb): complete ADB device support for Android reverse engineering - #1552

Merged
morluto merged 5 commits into
morluto:mainfrom
3QL:feat/adb-device-acquisition
Oct 10, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
3QL:feat/adb-device-acquisition

Conversation

@3QL

@3QL 3QL commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

feat(adb): complete ADB device support for Android reverse engineering

Summary

Add an ADB family of 24 operations over the caller's adb binary, exposed through the same shared CLI/MCP workflows as every other analysis family. Every operation composes a fixed adb argument vector — caller values occupy positional arguments only and never reach a shell. REA never installs platform tools, never starts or manages emulators, and every result embeds the producing adb client identity (binary, selection source, version) so Evidence keeps producer provenance.

Device identity and state (read-only): inspect_adb_client · list_adb_devices (inferred emulator/physical kind with basis) · inspect_adb_device (getprop whitelist + ro.kernel.qemu) · inspect_adb_display · list_adb_features (hex GL versions) · list_adb_services (AIDL /-suffixed names) · list_adb_processes · inspect_adb_window (focus declarations) · read_adb_setting (device-side nulls reported as such) · read_adb_logcat (bounded dump, count/buffer/pid).

Find and acquire (read-only): resolve_adb_packages (substring search, e.g. whatsapp → com.whatsapp) · list_adb_packages · inspect_adb_package (dumpsys projection) · pull_adb_package (complete split APK set from pm path, each file SHA-256 digested, partial pulls keep per-file failure reasons) · pull_adb_file · push_adb_file (e.g. tools into /data/local/tmp; refuses existing targets without explicit overwrite; verifies via the device's own sha256sum) · capture_adb_screen (exec-out screencap -p, PNG dimensions) · collect_adb_bugreport (digested device archive).

Lifecycle for dynamic analysis (mutatesTarget declared): install_adb_package / uninstall_adb_package (preserving the device's Success/Failure [...] verdict verbatim) · start_adb_app (resolve-activity → am start -W) · start_adb_activity (action, URI, component, up to 16 typed extras as --es/--ez/--ei/--el/--ef) · stop_adb_app (am force-stop). The dynamic-analysis loop is now one surface: install → start → read_adb_logcat --pid → `stop → uninstall.

This implements the read-only-plus-lifecycle ADB stage of the Android roadmap #717. UI driving (tap/type/monkey) and device-driver installs remain deliberately out of scope; see the docs' follow-up-lanes note on pairing mobile-device-mcp / Frida (#1359) behind explicit mutation authority.

Honesty rules baked in

  • Inferences carry their basis: kind_basis (serial prefix / USB transport), role_basis: file_name for APK roles, device_reported_null for absent settings keys, device_digest_source when a device can't verify a push.
  • Device paths stay typed as device paths; only pulls/captures produce host-local paths, always with bytes + SHA-256.
  • Unparseable output is preserved (unparsed_lines + coverage: "partial"), never silently dropped; the first run against a real device caught three real format variants this way (AIDL / names, hex feature versions, adb version's colon-less Version line).
  • Transfer/lifecycle mutations are explicit and audited in TOOL_EFFECTS (mutatesTarget, non-idempotent); everything else is read-only with respect to the device.

Verification

  • 130+ module/adapter/boundary tests: parser goldens, provider behavior through #!/bin/sh adb stubs (fixed-argv audits via logged argv files, digest mismatch → artifact_changed, overwrite refusals, cancellation before spawn, mistyped extras rejected pre-device), service admission/Evidence composition, CLI schema advertisement (24 commands), MCP schema parity with Ajv-validated examples and rejected unknown input.
  • Real-device lane (npm run verify:adb): adb 34.0.5-debian on Linux vs. an Android 14 (API 34) x86_64 emulator — every operation green: 287 binder services, 92 features, 337-process listing, bounded logcat, directory listings, a real two-APK split set pulled with byte-exact on-digest agreement, a push/pull roundtrip verified by the device's own sha256sum, a 1.3 MB screen capture with dimensions, dumpsys package projection, and the full lifecycle (unique resolve → launcher start via resolve-activity + am start -W → visible in ps → force-stop → uninstall → zero matches). System packages with non-base.apk names verify honest unknown-role reporting (73.9 MB com.android.settings).
  • check:fast, docs:generate, docs:check, and 3,400+ tests across the domain/services/adapters/composition projects pass. Two pre-existing environment failures in the firmware lane reproduce on a clean tree and are unrelated.

Docs

  • docs/adb-device-analysis.md: supply tools, 24-operation table with read/mutates classification, result semantics, budgets, follow-up lanes.
  • docs/testing.md: full verification record. README analysis table gains the "Android devices" row in English and all 17 translations.

Towards #717. No engine, SDK, or emulator installation; no new runtime dependencies.

REA Contributor added 2 commits October 10, 2026 13:28
Add a read-only ADB device-acquisition family over the caller's adb binary:
inspect_adb_client, list_adb_devices, inspect_adb_device, list_adb_packages,
and pull_adb_package, exposed through the CLI and MCP with shared admission,
Evidence provenance (binary, version, serial, transport), and fixed argv
vectors that never reach a shell.

pull_adb_package acquires the complete split set reported by pm path into a
package-named directory that must not exist, digesting every file with
SHA-256 and keeping per-file failure reasons and partial coverage. Device
kind is reported as an inference with its basis; getprop whitelisting keeps
build identity bounded. REA installs nothing and never manages devices or
emulators; the first device query may start the caller's local adb server,
recorded when observed.

Verified against adb 34.0.5 on Linux with an Android 14 (API 34) x86_64
emulator: full 224-package inventory, a real two-APK split set pulled with
byte-exact digests, and a 73.9 MB system-package pull. npm run verify:adb
records the lane; parser goldens come from the same device. READMEs carry
the new row in every supported language.
…ifecycle tools

Extend the ADB family from five to twenty-four operations, all through
fixed adb argument vectors with no shell exposure:

Observation: read_adb_logcat (bounded dump, count/buffer/pid), inspect_adb_package
(dumpsys package projection), list_adb_processes (ps -A), list_adb_directory
(ls -la with kinds and symlink targets), list_adb_features (hex GL versions),
list_adb_services (AIDL slash-suffixed names), inspect_adb_display (wm size and
density), inspect_adb_window (focus declarations), read_adb_setting (device-side
nulls reported as such), capture_adb_screen (exec-out screencap with PNG
dimensions), collect_adb_bugreport (digested device archive).

Transfer and search: pull_adb_file and push_adb_file (device-side sha256sum
verification, explicit overwrite authority), resolve_adb_packages (substring
package search with exact-match flag — the find step of an easy get).

Lifecycle for dynamic analysis, each declaring mutatesTarget:
install_adb_package and uninstall_adb_package preserving the device's
Success/Failure verdict, start_adb_app (resolve-activity then am start -W),
start_adb_activity (typed extras as --es/--ez/--ei/--el/--ef), and stop_adb_app
(am force-stop).

Verified end-to-end against adb 34.0.5 on Linux with an Android 14 (API 34)
x86_64 emulator: 287 services, 92 features, split-set pulls with byte-exact
digests, verified push/pull roundtrip, sized screen capture, and the full
install → resolve → start → observe-in-ps → force-stop → uninstall lifecycle.
Fixed a v-mode regex incompatibility in the settings key pattern and added
argument descriptions required by the CLI catalog audit.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

# Conflicts:
#	README_ar.md
#	README_de.md
#	README_es.md
#	README_fa.md
#	README_fr.md
#	README_ja.md
#	README_ko.md
#	README_pl.md
#	README_pt-BR.md
#	README_ru.md
#	README_th.md
#	README_tr.md
#	README_uk.md
#	README_vi.md
#	README_zh-TW.md
#	README_zh.md
@morluto

morluto commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thanks @3QL for expanding ADB device inspection and acquisition support! This is merged, including the review fixes for remote shell quoting, cancellation, bugreport output, and screenshot file preservation. I appreciate the work across the Android tooling PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants