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

Install

# from PyPI
pip install droidasc

# or from source
pip install .

After installation, the droidasc CLI command is available globally:

usage: droidasc [-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:
  droidasc app.apk --gui
  droidasc getclass app.apk Lcom/poc/Main; -o Main.java
  droidasc getclass app.apk com.poc.Main --threads 16
  droidasc getmanifest app.apk -o AndroidManifest.xml
  droidasc findrefs app.apk string token -o string_refs.txt
  droidasc findrefs app.apk type com.poc.Main
  droidasc findrefs app.apk method onCreate --class com.poc.Main
  droidasc findrefs app.apk method notify --class MainActivity --fuzzy-class -o method_refs.txt
  droidasc findrefs app.apk field apiKey -o field_refs.txt

You can also use python main.py as before — it delegates to the same entry point.

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.1.tar.gz (86.7 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.1-py3-none-any.whl (95.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: droidasc-0.1.1.tar.gz
  • Upload date:
  • Size: 86.7 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.1.tar.gz
Algorithm Hash digest
SHA256 b9db80915dee6dcbd06983e741cf8a28a70b1bfe9b2bfb21e85bc01913ca681f
MD5 bd9587bf4803aeb7193875273fe33416
BLAKE2b-256 d2aea173db43c662af8748945ef5481e1a819d6c73f79d780b3a061387d09ee6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: droidasc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 95.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c1efcfd6212f0c444ad40b301888729ee490ca9fa3fe44a3ad76012aadb603d
MD5 abfda903cc2621c5898465d8ecf9eb04
BLAKE2b-256 f2c89e7100d934bb15a83d4bce9eb8076133af79bd3b82d7dd221323ef79a764

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

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