Files
reverse-engineering-anything/src/cliCommandNames.ts
T
fef6f73064 feat(adb): complete ADB device support for Android reverse engineering (#1552)
* feat(adb): acquire installed APK sets from connected Android devices

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.

* feat(adb): complete the adb surface with observation, transfer, and lifecycle 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.

* fix(adb): quote remote shell operands and protect captured output

* test(adb): cover bugreport destinations containing spaces

---------

Co-authored-by: REA Contributor <contributor@rea.tools>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-10 23:01:24 +08:00

199 lines
7.5 KiB
TypeScript

/** Canonical names used by every one-shot CLI command registration. */
export const CLI_COMMANDS = Object.freeze({
inspectEvmInterface: "inspect-evm-interface",
inspectWebNetworkCapture: "inspect-web-network-capture",
observeWebExecution: "observe-web-execution",
inspectWebEventListeners: "inspect-web-event-listeners",
traceWebSourceLocation: "trace-web-source-location",
traceWebModuleImports: "trace-web-module-imports",
analyze: "analyze",
inspect: "inspect",
decompile: "decompile",
setup: "setup",
doctor: "doctor",
uninstall: "uninstall",
update: "update",
xrefs: "xrefs",
trace: "trace",
traceNativeUiAction: "trace-native-ui-action",
inspectNativeDispatchMetadata: "inspect-native-dispatch-metadata",
capabilities: "capabilities",
providers: "providers",
function: "function",
annotateNativeFunction: "annotate-native-function",
inspectNativeApi: "inspect-native-api",
instructions: "instructions",
search: "search",
importReferenceSource: "import-reference-source",
inspectArtifact: "inspect-artifact",
extractArtifact: "extract-artifact",
decodeInterfaceBuilder: "decode-interface-builder",
inspectKeyedArchive: "inspect-keyed-archive",
traceDylibResolution: "trace-dylib-resolution",
inspectNativeDataType: "inspect-native-data-type",
inspectNativeLoadImage: "inspect-native-load-image",
readBytes: "read-bytes",
addressToFileOffset: "address-to-file-offset",
traceNativeValues: "trace-native-values",
inspectNativeInstruction: "inspect-native-instruction",
resolveNativeCallTargets: "resolve-native-call-targets",
inspectAssetCatalog: "inspect-asset-catalog",
inspectManagedArtifact: "inspect-managed-artifact",
inspectRecordedCrash: "inspect-recorded-crash",
inspectBinaryLayout: "inspect-binary-layout",
inspectAnalysisView: "inspect-analysis-view",
inspectFirmwareRegions: "inspect-firmware-regions",
extractFirmware: "extract-firmware",
inspectAndroidPackage: "inspect-android-package",
inspectAdbClient: "inspect-adb-client",
listAdbDevices: "list-adb-devices",
inspectAdbDevice: "inspect-adb-device",
listAdbPackages: "list-adb-packages",
pullAdbPackage: "pull-adb-package",
readAdbLogcat: "read-adb-logcat",
inspectAdbPackage: "inspect-adb-package",
pullAdbFile: "pull-adb-file",
pushAdbFile: "push-adb-file",
captureAdbScreen: "capture-adb-screen",
listAdbProcesses: "list-adb-processes",
listAdbDirectory: "list-adb-directory",
listAdbFeatures: "list-adb-features",
listAdbServices: "list-adb-services",
inspectAdbDisplay: "inspect-adb-display",
inspectAdbWindow: "inspect-adb-window",
readAdbSetting: "read-adb-setting",
collectAdbBugreport: "collect-adb-bugreport",
resolveAdbPackages: "resolve-adb-packages",
installAdbPackage: "install-adb-package",
uninstallAdbPackage: "uninstall-adb-package",
startAdbApp: "start-adb-app",
startAdbActivity: "start-adb-activity",
stopAdbApp: "stop-adb-app",
searchAndroidClasses: "search-android-classes",
inspectAndroidClass: "inspect-android-class",
inspectAndroidMethod: "inspect-android-method",
traceAndroidReferences: "trace-android-references",
inspectManagedMembers: "inspect-managed-members",
inspectManagedNativeBoundaries: "inspect-managed-native-boundaries",
compareManagedMembers: "compare-managed-members",
verifyManagedNativeBoundaries: "verify-managed-native-boundaries",
importManagedReconstruction: "import-managed-reconstruction",
projectManagedApplicationGraph: "project-managed-application-graph",
observeNativeUi: "observe-native-ui",
observeNativeCalls: "observe-native-calls",
captureNativeUiScenario: "capture-native-ui-scenario",
inspectMacho: "inspect-macho",
inspectSignature: "inspect-signature",
listArchitectures: "list-architectures",
inspectPlist: "inspect-plist",
demangleSwift: "demangle-swift",
evidenceImport: "evidence-import",
evidenceExport: "evidence-export",
compare: "compare",
captureProcess: "capture-process",
compareProcessCaptures: "compare-process-captures",
listBrowserTargets: "list-browser-targets",
inspectWebPage: "inspect-web-page",
analyzeWebBundle: "analyze-web-bundle",
exportWebScripts: "export-web-scripts",
recoverJavaScriptSources: "recover-javascript-sources",
observeWebSession: "observe-web-session",
discoverWebMcpTools: "discover-webmcp-tools",
compareWebCaptures: "compare-web-captures",
captureWebScreenshot: "capture-web-screenshot",
compareWebScreenshots: "compare-web-screenshots",
captureBrowserScenario: "capture-browser-scenario",
listElectronTargets: "list-electron-targets",
inspectElectronPage: "inspect-electron-page",
captureElectronScenario: "capture-electron-scenario",
listJavaScriptRuntimeTargets: "list-javascript-runtime-targets",
observeJavaScriptRuntime: "observe-javascript-runtime",
analyzeJavaScriptApplication: "analyze-javascript-application",
reconcileJavaScriptRuntime: "reconcile-javascript-runtime",
traceApplicationFeature: "trace-application-feature",
traceJavaScriptSemantics: "trace-javascript-semantics",
compareApplicationVersions: "compare-application-versions",
compareSourceToBundle: "compare-source-to-bundle",
compareJavaScriptExportShapes: "compare-javascript-export-shapes",
buildReconstructionObligationLedger: "build-reconstruction-obligation-ledger",
evaluateReconstructionCoverage: "evaluate-reconstruction-coverage",
projectAndroidApplicationGraph: "project-android-application-graph",
projectAppleApplicationGraph: "project-apple-application-graph",
});
/** Ordered primary CLI inventory; aliases are intentionally excluded. */
export const CLI_COMMAND_NAMES = Object.freeze(Object.values(CLI_COMMANDS));
/** Command aliases registered on top of the primary CLI command inventory. */
export const CLI_COMMAND_ALIASES = Object.freeze(["compare-bundles"]);
/** Canonical MCP operations reached by CLI commands with different names. */
export const CLI_COMMAND_TOOL_ALIASES = Object.freeze({
analyze: ["binary_overview"],
inspect: ["binary_overview"],
decompile: ["procedure_pseudo_code"],
function: ["analyze_function"],
instructions: ["read_function_instructions"],
trace: ["trace_feature"],
search: ["search_strings", "search_procedures"],
"capture-process": ["capture_process_scenario"],
"compare-bundles": ["compare_bundles"],
});
/** MCP operations without a dedicated CLI command or direct command alias. */
export const MCP_TOOLS_WITHOUT_DEDICATED_CLI = Object.freeze([
"address_name",
"comment",
"current_address",
"current_procedure",
"current_document",
"goto_address",
"inline_comment",
"list_bookmarks",
"list_documents",
"list_names",
"list_procedures",
"list_segments",
"list_strings",
"next_address",
"prev_address",
"procedure_address",
"procedure_assembly",
"procedure_callees",
"procedure_callers",
"procedure_info",
"procedure_references",
"resolve_containing_procedure",
"set_address_name",
"set_addresses_names",
"set_bookmark",
"set_comment",
"set_inline_comment",
"unset_bookmark",
"get_objc_classes",
"get_objc_protocols",
"batch_decompile",
"get_call_graph",
"analyze_swift_types",
"find_xrefs_to_name",
"trace_call_path",
"open_binary",
"close_binary",
"binary_session",
"export_evidence_bundle",
"import_evidence_bundle",
"compare_artifacts",
"compare_functions",
"find_changed_behavior",
"build_call_path",
"correlate_static_and_runtime",
"verify_reconstruction",
"list_unknowns",
"record_unknown",
"update_unknown",
"verify_unknown_resolution",
"get_evidence_bundle",
"get_navigation_context",
"inspect_address_context",
]);