Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

vdexExtractor

> DevOps
Open source

Tool to decompile & extract Android Dex bytecode from Vdex files

1.1K stars0 likes0 views
WebsiteGitHub

About

Tool to decompile & extract Android Dex bytecode from Vdex files

Vdex Extractor

Command line tool to decompile and extract Android Dex bytecode from Vdex files that are generated along with Oat files when optimizing bytecode from dex2oat ART runtime compiler. Vdex file format has been introduced in the Oreo (API-26) build. More information is available [here][vdex-cr]. It should be noted that Oat files are no longer storing the matching Dex files inside their .rodata section. Instead they're always paired with a matching Vdex container file.

Compile

  • Clone this repository
  • Install Android NDK if you want to cross-compile for Android devices
  • Invoke make.sh bash script with desired build target
    • $ ./make.sh - if CC not defined from env use gcc by default
    • $ ./make.sh gcc - compile with gcc
    • $ ./make.sh clang - compile with clang
    • $ ./make.sh cross-android - cross-compile (armeabi-v7a, arm64-v8a, x86 & x86_64) for Android with NDK
  • Executables are copied under the bin directory
  • For debug builds use $ DEBUG=true ./make.sh

Dependencies

The following external libraries should be installed the in the host system:

  1. zlib
    • macOS with homebrew: brew install zlib-devel
    • macOS with macports: port install zlib
    • Linux with apt: apt install libz-dev
    • Other Linux/Unix systems: Check available package manager or compile from sources
    • Windows with cygwin: Install zlib-devel from cygwin installer

Usage

…

Bytecode Unquickening Decompiler

The Vdex file includes all quick_info data (old vtable) required to revert the dex-to-dex transformations applied during bytecode optimization. The idea here is to create a quick standalone tool capable to revert optimized bytecode, that does not require building the entire libart from AOSP.

The Vdex fully unquicken functionality has been also implemented as part of the AOSP oatdump libart tool. The upstream contribution is available [here][aosp-master]. If you want to use oatdump with Oreo release you can use the corresponding patch [here][oatdump-oreo] or fork and build (inside and AOSP_SRC_ROOT workspace) the oreo-release branch of the [oatdump++][oatdump-plus] tool. Google has released the contributed patches along with the Android Pie release of the ART runtime. However, the upstream oatdump is appending the entire de-duplicated shared data section at the end of each CompactDex file when exporting.

Verified Dependencies Iterator

When the Dex bytecode files are compiled (optimized) for the first time, dex2oat executes the verification dependencies collector as part of the MethodVerifier The verification dependencies collector class is used to record resolution outcomes and type assignability tests of classes/methods/fields defined in the classpath. The compilation driver initializes the class and registers all Dex files which are being compiled. Classes defined in Dex files outside of this set (or synthesized classes without associated Dex files) are considered being in the classpath. All recorded dependencies are stored in the generated Vdex file along with the corresponding Oat file from the OatWriter class.

vdexExtractor tool integrates a Vdex dependencies walker function that is capable to iterate all dependencies information and dump them in a human readable format. The following snippet demonstrates a dependencies dump example of a sample Vdex file.

…

Integrated Disassembler

To debug the decompiler and assist the Dex bytecode investigation tasks, a light disassembler has been implemented. The disassembler output is very similar to the one provided by the AOSP dexdump2 utility of the platform/art project. The disassembler can be used independently of the unquickening decompiler.

A sample output is illustrated in the following snippet. Lines prefixed with [new] illustrate the output of the decompiled instruction (previous line) located in that offset. Notice that all the quickened offsets and vtable references have been reverted back to original signatures and prototypes.

…

Compact Dex Converter

The Android 9 (Pie) release has introduced a new type of Dex file, the Compact Dex (Cdex). Cdex is an ART internal file format that is compacting various Dex data structs (e.g. method header) and deduplicates common data blobs (e.g. strings) in multi-dex files. The deduplicated data from the Dex files of an input application are stored in the shared section of the Vdex container.

Now since the Vdex containers are storing Cdex files instead of standard Dex, the vdexExtractor backends (starting from version 019) have been updated to support them too. However, since the tool does not implement a Dex IR it is not possible to convert a Cdex file back to standard Dex without using an external tool. For this purpose the "compact_dex_converter" tool has been written, which uses the libdexlayout (Dex IR) from the AOSP art repo. The source code of the tool is available here. Compiling the tool requires forking the necessary AOSP repos and building as an AOSP module.

For convenience vdexExtractor is implementing a helper tool (see "tools/deodex" in the following section) that downloads a set of precompiled binaries and wraps around the required automation. In addition the "compact_dex_converter" binaries can be downloaded from the following links:

  • Linux x86-64
    • With shared libraries: https://1drv.ms/u/s!ArDC4mvMyPrRhEsiuPjOF_ssIfOe
    • With shared libraries debug: https://1drv.ms/u/s!ArDC4mvMyPrRhE3Z2jdBXJIhazjc
    • Statically compiled: https://1drv.ms/u/s!ArDC4mvMyPrRhEq96XX-LsCACF2s
    • Statically compiled debug: https://1drv.ms/u/s!ArDC4mvMyPrRhEwmwM8--zdhoCB2
  • Linux x86-64 old CPUs (no SSE4.2 & no POPCNT #29)
    • With shared libraries: https://1drv.ms/u/s!ArDC4mvMyPrRhFP46IyBqOtihS9s
    • With shared libraries debug: https://1drv.ms/u/s!ArDC4mvMyPrRhFXEGW9vrlMlTKDJ
    • Statically compiled: https://1drv.ms/u/s!ArDC4mvMyPrRhFIFZCF9TtEHVooc
    • Statically compiled debug: https://1drv.ms/u/s!ArDC4mvMyPrRhFSMELB_H3w5Cdfe
  • ARM64 (aarch64)
    • With shared libraries: https://1drv.ms/u/s!ArDC4mvMyPrRhEindMOf3aWCbQRr
    • With shared libraries debug: https://1drv.ms/u/s!ArDC4mvMyPrRhEnU9Ei_3MeQipGr
    • Statically compiled: NOT SUPPORTED
  • macOS
    • With shared libraries: https://1drv.ms/u/s!ArDC4mvMyPrRhE45gEUNolEiZ50u
    • With shared libraries debug: https://1drv.ms/u/s!ArDC4mvMyPrRhFG5WH_zNz0jNarZ
    • Statically compiled: NOT SUPPORTED

The 's' suffix in binary names stands for "statically compiled" and the 'd' for "debug" build. They can be also combined (e.g. 'ds' - statically compiled debug build).

Update 14 Sept. 2018

A functionally equivalent upstream patch to art's oatdump utility has been contributed. AOSP master has merged, so hopefully it will ship with the next major OS update.

Utility Scripts

  • scripts/extract-apps-from-device.sh

    Extract ART compiler output resources (oat, art, vdex) of installed packages (user and system) from a connected Android device. Also supports extracting APK archives of installed packages. Some system app data might fail to extract without root access due to applied DAC permissions.

…
  • scripts/update-vdex-location-checksums.sh

    Update Vdex file location checksums with CRCs extracted from input Apk archive file. More information on how this feature was used to trick the ART runtime book keeping mechanism and bypass SafetyNet application integrity checks is available [here][census-snet].

    $ scripts/update-vdex-location-checksums.sh -h
      Usage: update-vdex-location-checksums.sh [options]
        options:
          -i|--input  : Input Vdex file to repair location checksum(s) within
          -a|--app    : Input Apk file to extract location checksum(s) from
          -o|--output  : Directory to save updated Vdex file (default is '.')
          -h|--help         : This help message
  • tools/deodex/run.sh

    Helper tool to decompile (deodex) Vdex resources back to standard Dex files in a bulk manner. The tool is automatically handling the case of CompactDex files (as introduced in Android Pie) and uses the compact_dex_converter tool (more info here) to convert back to StandardDex. Since the converter is compiled as part of the AOSP sources, a set of binaries for Linux & maacOS is maintained from the developer for convenience.

    $ tools/deodex/run.sh -h
      Usage: run.sh [options]
        options:
          -i|--input  : Directory with Vdex files or single file
          -o|--output  : Directory to save deodex'ed resources (default is '.')
          -k|--keep         : Keep intermediate files (default 'false')
          -h|--help         : This help message
    
    $ tools/deodex/run.sh -i /tmp/vdex_samples -o /tmp/deodexed_samples
    [INFO]: Processing 140 input Vdex files
    [INFO]: 140 binaries have been successfully deodexed

Changelog

  • 0.6.0 - 30 December 2019
    • Vdex 021 support for Android Q (appreciate IgorEisberg contribution)
    • Fix an issue in the method iterator of the Vdex 006 & 010 backends
    • Fix GCC 9 compilation issue
  • 0.5.2 - 22 September 2018
    • Fix an issue when decompiling framework bytecode the APIs of which have been hidden
  • 0.5.1 - 3 September 2018
    • Improve handling of deduplicated shared data section when exporting CompactDex files after decompilation
    • Fixes an OOB read issue in Vdex 010 decompiler
    • Fix Dex output header formatting glitch due to different magic size of CompactDex & StandardDex
    • Option (--get-api) to query Android API level of a Vdex file (mostly useful when scripting around the tool)
    • deodex helper tool and URLs for compact_dex_converter binaries for Linux & macOS
  • 0.5.0 - 30 August 2018
    • Vdex 019 support for Android Pie (verifier dependencies, decompiler & disassembler)
    • Extended Dex file parsing library to support CompactDex files
    • Extended disassembler engine to support CompactDex files as processed from the Android Pie Vdex containers
    • Improved input files sanity checks to avoid malformed Vdex crashing the tool
    • Various bug fixes and disassembler output improvements
  • 0.4.1 - 4 March 2018
    • Fix Vdex 006 NOP decompilation issue
    • Support multi-depth directory recursion for input path
    • Argument to ignore CRC errors required for out-of-order optimized classes (see [issue #3][issue3])
  • 0.4.0 - 11 December 2017
    • Add Vdex 010 (API-27) support by defining different parser & decompiler backend engines that are version specific
    • Fix a bug in verified dependencies iterator that presented results out of order
    • Simplified command line arguments
    • Deprecate class name recover information gather feature due to increased complexity in Vdex parser engine
    • Updated Dex API to support new opcodes & instruction formats
  • 0.3.1 - 17 November 2017
    • Add option to update checksum location of Vdex file (-n, --new-crc). Feature mostly targets use-cases were a backwards compatibility fix of the Vdex file is required without having to dex2oat recompile.
    • Implement class name recover information gather feature (-r, --class-recover)
    • Add timer utility functions to measure time spend to unquicken each input Vdex file
    • Use external log file only for disassembler & verified dependencies information output
    • Disassembler output performance improvements
    • Improve performance when decompiling and disassembling at the same run
    • Logging facility improvements
    • Improve code quality by removing duplicate code
  • 0.3.0 - 28 October 2017
    • Implement Vdex verified dependencies information iterator (-D, --dump-deps)
    • Enable Dex disassembler without requiring to unqu

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Candroidart-runtimebytecodebytecode-unquickening

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理