Skip to main content

Droid ASC: R8 Compiler Optimization as a DeCompiler Primitive

https://blackhat.com/europe/arsenal/schedule/index.html#droid-asc-r8-compiler-optimization-as-a-decompiler-primitive-54834

When decompiling massive Android APKs, the standard procedure is to wait. We wait for tools to eat gigabytes of RAM, fully inflate the artifacts, and spend tens of minutes building heavy global indexes and cross references... All of this is just to guarantee fast code searches later, but here is the contradiction. A compiled artifact is already highly structured, modern decompilers never utilize this, they waste massive amounts of time and memory reconstructing a bloated database of code relationships over already structured data. This engineering approach defies common sense. When I can directly extract any code relationship from the APK in milliseconds, does this preprocessing still hold any value?

Instead of forcing decompilers into heavy preprocessing, we choose to query the compiled artifact directly as a database. We built a stateless, zero-overhead engine that extracts and searches code on demand in milliseconds. In this briefing, we will explore the underlying engineering required to bypass traditional bottlenecks. We will demonstrate how to abandon full inflate by probing directly within the Deflate bitstream, building dense Huffman lookup tables to extract core metadata without touching irrelevant data blocks. Furthermore, we will explain optimization details of the R8 compiler, especially how deterministic constant relocation and instruction deduplication leave behind highly concentrated physical layouts, we weaponize this compiler behavior to execute lightning-fast cross DEX code searches. To map these raw bytecode offsets back to methods, we engineered an O(1) instruction locating primitive, achieving constant-time method resolution without building heavy mapping tables. Finally, upon hitting a target, Droid ASC extracts only the specific bytecodes and its dependencies, dynamically reconstructing a minimal and self consistent DEX entirely in memory for instant decompilation.

We will demonstrate this architecture live against a 352MB commercial APK. Droid ASC executes global cross reference searches in 1.79 seconds and decompiles target classes in 177 milliseconds using only 141MB of RAM. By treating the artifact as a read only database and operating with zero preprocessing, we return the decompiler to its core essence. It is no longer a bloated indexing tool, but a lightning fast, on demand decompilation engine that fundamentally redefines how we analyze compiled code.

Benchmark

Benchmark

https://github.com/user-attachments/assets/4c4a6813-8561-490c-a573-ef113da861b6

How to use

usage: main.py [-h] {getclass,getmanifest,findrefs} ...

ASC tooling entry.

positional arguments:
  {getclass,getmanifest,findrefs}
    getclass            Locate the target class in APK, extract one DEX in memory, then decompile.
    getmanifest         Decode AndroidManifest.xml from APK and print it as XML.
    findrefs            Find code references for string/type/method/field across all DEX entries in APK.

options:
  -h, --help            show this help message and exit

examples:
  python main.py app.apk --gui
  python main.py getclass app.apk Lcom/poc/Main; -o Main.java
  python main.py getclass app.apk com.poc.Main --threads 16
  python main.py getmanifest app.apk -o AndroidManifest.xml
  python main.py findrefs app.apk string token -o string_refs.txt
  python main.py findrefs app.apk type com.poc.Main
  python main.py findrefs app.apk method onCreate --class com.poc.Main
  python main.py findrefs app.apk method notify --class MainActivity --fuzzy-class -o method_refs.txt
  python main.py findrefs app.apk field apiKey -o field_refs.txt

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

droidasc-0.1.0.tar.gz (85.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

droidasc-0.1.0-py3-none-any.whl (94.2 kB view details)

Uploaded Python 3

File details

Details for the file droidasc-0.1.0.tar.gz.

File metadata

  • Download URL: droidasc-0.1.0.tar.gz
  • Upload date:
  • Size: 85.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for droidasc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 590acd57b391c208cedef4b6708b4bac901953d748e9989d39bb49762be9201e
MD5 275d7ce8e9d374842f7d597e7efbae1f
BLAKE2b-256 d20ba5ea0f6e4ffe9eb91d30c7f76964d67eb95636c41d2aa208ffb103de216b

See more details on using hashes here.

File details

Details for the file droidasc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: droidasc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 94.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for droidasc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95df248800300eca77929cdb8f72bb51039125948f018e1eb4c9c9e13fbe3b91
MD5 11fc8c4c987a7925b73a74e2818268ef
BLAKE2b-256 4a34ed09039ec346fe5fa072e493568323c37acc0c296c44ad9c9931a5f82617

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page