GithubHelp home page GithubHelp logo

anestisb / vdexextractor Goto Github PK

View Code? Open in Web Editor NEW
976.0 42.0 211.0 571 KB

Tool to decompile & extract Android Dex bytecode from Vdex files

License: Apache License 2.0

Makefile 0.99% Shell 5.87% C 93.14%
android vdex bytecode dex art-runtime decompiler libart bytecode-unquickening disassembler compactdex

vdexextractor's Introduction

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. 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

$ bin/vdexExtractor -h
              vdexExtractor ver. 0.5.2
    Anestis Bechtsoudis <[email protected]>
  Copyright 2017 - 2018 by CENSUS S.A. All Rights Reserved.

 -i, --input=<path>   : input dir (search recursively) or single file
 -o, --output=<path>  : output path (default is same as input)
 -f, --file-override  : allow output file override if already exists (default: false)
 --no-unquicken       : disable unquicken bytecode decompiler (don't de-odex)
 --deps               : dump verified dependencies information
 --dis                : enable bytecode disassembler
 --ignore-crc-error   : decompiled Dex CRC errors are ignored (see issue #3)
 --new-crc=<path>     : text file with extracted Apk or Dex file location checksum(s)
 --get-api             : get Android API level based on Vdex version (expects single Vdex file)
 -v, --debug=LEVEL    : log level (0 - FATAL ... 4 - DEBUG), default: '3' (INFO)
 -l, --log-file=<path>: save disassembler and/or verified dependencies output to log file (default is STDOUT)
 -h, --help           : this help

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. If you want to use oatdump with Oreo release you can use the corresponding patch here or fork and build (inside and AOSP_SRC_ROOT workspace) the oreo-release branch of the oatdump++ 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.

$ bin/vdexExtractor -i /tmp/BasicDreams.vdex -o /tmp --deps -f
[INFO] Processing 1 file(s) from /tmp/BasicDreams.vdex
------- Vdex Deps Info -------
dex file #0
 extra strings: number_of_strings=2
  0000: 'Ljava/lang/Thread;'
  0001: 'Ljava/lang/Throwable;'
 assignable type sets: number_of_sets=8
  0000: 'Landroid/service/dreams/DreamService;' must be assignable to 'Landroid/content/Context;'
  0001: 'Landroid/view/TextureView;' must be assignable to 'Landroid/view/View;'
  0002: 'Ljava/nio/FloatBuffer;' must be assignable to 'Ljava/nio/Buffer;'
...
 unassignable type sets: number_of_sets=0
 class dependencies: number_of_classes=34
  0000: 'Landroid/graphics/Color;' 'must' be resolved with access flags '1'
  0001: 'Landroid/graphics/SurfaceTexture;' 'must' be resolved with access flags '1'
...
  0024: 'Ljavax/microedition/khronos/egl/EGL10;' 'must' be resolved with access flags '513'
...
 field dependencies: number_of_fields=4
  0000: 'Ljavax/microedition/khronos/egl/EGL10;'->'EGL_DEFAULT_DISPLAY':'Ljava/lang/Object;' is expected to be in class 'Ljavax/microedition/khronos/egl/EGL10;' and have the access flags '9'
  0001: 'Ljavax/microedition/khronos/egl/EGL10;'->'EGL_NO_CONTEXT':'Ljavax/microedition/khronos/egl/EGLContext;' is expected to be in class 'Ljavax/microedition/khronos/egl/EGL10;' and have the access flags '9'
  0002: 'Ljavax/microedition/khronos/egl/EGL10;'->'EGL_NO_DISPLAY':'Ljavax/microedition/khronos/egl/EGLDisplay;' is expected to be in class 'Ljavax/microedition/khronos/egl/EGL10;' and have the access flags '9'
  0003: 'Ljavax/microedition/khronos/egl/EGL10;'->'EGL_NO_SURFACE':'Ljavax/microedition/khronos/egl/EGLSurface;' is expected to be in class 'Ljavax/microedition/khronos/egl/EGL10;' and have the access flags '9'
 method dependencies: number_of_methods=84
  0000: 'Landroid/graphics/Color;'->'HSVToColor':'([F)I' is expected to be in class 'Landroid/graphics/Color;', have the access flags '9
  0001: 'Landroid/opengl/GLES20;'->'glAttachShader':'(II)V' is expected to be in class 'Landroid/opengl/GLES20;', have the access flags '9
  0002: 'Landroid/opengl/GLES20;'->'glClear':'(I)V' is expected to be in class 'Landroid/opengl/GLES20;', have the access flags '9
...
 unverified classes: number_of_classes=0
----- EOF Vdex Deps Info -----
[INFO] 1 out of 1 Vdex files have been processed
[INFO] 1 Dex files have been extracted in total
[INFO] Extracted Dex files are available in '/tmp'

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.

$ bin/vdexExtractor -i /tmp/Videos.vdex -o /tmp -f --dis -l /tmp/dis.log
[INFO] Processing 1 file(s) from /tmp/Videos.vdex
[INFO] 1 out of 1 Vdex files have been processed
[INFO] 2 Dex files have been extracted in total
[INFO] Extracted Dex files are available in '/tmp'
$ head -90 /tmp/dis.log
------ Dex Header Info ------
magic        : dex-035
checksum     : e14de163 (3779977571)
signature    : 9a91f8e5f2afe2c6b5c2b4853832d3c5ed01aef8
fileSize     : 8ca638 (9217592)
headerSize   : 70 (112)
endianTag    : 12345678 (305419896)
linkSize     : 0 (0)
linkOff      : 0 (0)
mapOff       : 8ca568 (9217384)
stringIdsSize: ef06 (61190)
stringIdsOff : 70 (112)
typeIdsSize  : 29f4 (10740)
typeIdsOff   : 3bc88 (244872)
protoIdsSize : 3df9 (15865)
protoIdsOff  : 46458 (287832)
fieldIdsSize : a79d (42909)
fieldIdsOff  : 74c04 (478212)
methodIdsSize: fed7 (65239)
methodIdsOff : c88ec (821484)
classDefsSize: 2288 (8840)
classDefsOff : 147fa4 (1343396)
dataSize     : 73d594 (7591316)
dataOff      : 18d0a4 (1626276)
-----------------------------
file #0: classDefsSize=8840
  class #0: a.a ('La$a;')
   access=0601 (PUBLIC INTERFACE ABSTRACT)
   source_file=SourceFile, class_data_off=851907 (8722695)
   static_fields=0, instance_fields=0, direct_methods=0, virtual_methods=2
   virtual_method #0: onMenuItemSelected (La;Landroid/view/MenuItem;)Z
    access=0401 (PUBLIC ABSTRACT)
    codeOff=0 (0)
   virtual_method #1: invokeItem (Landroid/support/v7/view/menu/MenuItemImpl;)Z
    access=0401 (PUBLIC ABSTRACT)
    codeOff=0 (0)
  class #1: a.b ('La$b;')
   access=0601 (PUBLIC INTERFACE ABSTRACT)
   source_file=SourceFile, class_data_off=851913 (8722707)
   static_fields=0, instance_fields=0, direct_methods=0, virtual_methods=1
   virtual_method #0: invokeItem (Landroid/support/v7/view/menu/MenuItemImpl;)Z
    access=0401 (PUBLIC ABSTRACT)
    codeOff=0 (0)
  class #2: SupportMenu ('Landroid/support/v4/internal/view/SupportMenu;')
   access=0601 (PUBLIC INTERFACE ABSTRACT)
   source_file=SourceFile, class_data_off=0 (0)
  class #3: a ('La;')
   access=0001 (PUBLIC)
   source_file=SourceFile, class_data_off=85191b (8722715)
   static_fields=1, instance_fields=25, direct_methods=12, virtual_methods=74
   direct_method #0: <clinit> ()V
    access=10008 (STATIC CONSTRUCTOR)
    codeOff=1abb50 (1751888)
    quickening_size=4 (4)
      1abb60: 1260                                   |0000: const/4 v0, #int 6 // #6
      1abb62: 2300 e426                              |0001: new-array v0, v0, [I // type@26e4
      1abb66: 2600 0700 0000                         |0003: fill-array-data v0, 0000000a // +00000000
      1abb6c: 6900 1900                              |0006: sput-object v0, La;.sCategoryToOrder:[I // field@0019
      1abb70: 7300                                   |0008: return-void-no-barrier
[new] 1abb70: 0e00                                   |0008: return-void
      1abb72: 0000                                   |0009: nop // spacer
      1abb74: 0003 0400 0600 0000 0100 0000 0400 ... |000a: array-data (16 units)
   direct_method #1: invokeItem (Landroid/support/v7/view/menu/MenuItemImpl;)Z
    access=10001 (PUBLIC CONSTRUCTOR)
    codeOff=1abb94 (1751956)
    quickening_size=22 (34)
      1abba4: 1211                                   |0000: const/4 v1, #int 1 // #1
      1abba6: 1200                                   |0001: const/4 v0, #int 0 // #0
      1abba8: 7010 dbf9 0200                         |0002: invoke-direct {v2}, Ljava/lang/Object;.<init>:()V // method@f9db
      1abbae: e620 4000                              |0005: iput-quick v0, v2, [obj+0040]
[new] 1abbae: 5920 0400                              |0005: iput v0, v2, La;.mDefaultShowAsAction:I // field@0004
      1abbb2: eb20 4a00                              |0007: iput-boolean-quick v0, v2, [obj+004a]
[new] 1abbb2: 5c20 1200                              |0007: iput-boolean v0, v2, La;.mPreventDispatchingItemsChanged:Z // field@0012
      1abbb6: eb20 4700                              |0009: iput-boolean-quick v0, v2, [obj+0047]
[new] 1abbb6: 5c20 0d00                              |0009: iput-boolean v0, v2, La;.mItemsChangedWhileDispatchPrevented:Z // field@000d
      1abbba: eb20 4d00                              |000b: iput-boolean-quick v0, v2, [obj+004d]
[new] 1abbba: 5c20 1600                              |000b: iput-boolean v0, v2, La;.mStructureChangedWhileDispatchPrevented:Z // field@0016
      1abbbe: eb20 4800                              |000d: iput-boolean-quick v0, v2, [obj+0048]
[new] 1abbbe: 5c20 0f00                              |000d: iput-boolean v0, v2, La;.mOptionalIconsVisible:Z // field@000f
      1abbc2: eb20 4500                              |000f: iput-boolean-quick v0, v2, [obj+0045]
[new] 1abbc2: 5c20 0a00                              |000f: iput-boolean v0, v2, La;.mIsClosing:Z // field@000a
      1abbc6: 2200 fe25                              |0011: new-instance v0, Ljava/util/ArrayList; // type@25fe
      1abbca: 7010 6bfb 0000                         |0013: invoke-direct {v0}, Ljava/util/ArrayList;.<init>:()V // method@fb6b
      1abbd0: e820 3800                              |0016: iput-object-quick v0, v2, [obj+0038]
[new] 1abbd0: 5b20 1700                              |0016: iput-object v0, v2, La;.mTempShortcutItemList:Ljava/util/ArrayList; // field@0017
      1abbd4: 2200 2c26                              |0018: new-instance v0, Ljava/util/concurrent/CopyOnWriteArrayList; // type@262c
      1abbd8: 7010 cdfc 0000                         |001a: invoke-direct {v0}, Ljava/util/concurrent/CopyOnWriteArrayList;.<init>:()V // method@fccd
      1abbde: e820 3000                              |001d: iput-object-quick v0, v2, [obj+0030]
[new] 1abbde: 5b20 1100                              |001d: iput-object v0, v2, La;.mPresenters:Ljava/util/concurrent/CopyOnWriteArrayList; // field@0011
      1abbe2: e823 1000                              |001f: iput-object-quick v3, v2, [obj+0010]

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:

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/extract-apps-from-device.sh -h
      Usage: extract-apps-from-device.sh [options]
        options:
          -o|--output <dir>  : Output directory to save extracted data (default is '.')
          -d|--device <devID>: Device serial to use instead of default interactive selection
          --system-apps      : Extract system apps too (default is user apps only)
          --apks             : Extract apks (default is optimized files only)
          -h|--help          : This help message
    $ scripts/extract-apps-from-device.sh --system-apps -o /tmp/art_data --apks
    [INFO]: Enumerating connected Android devices
    [INFO]: Trying to extract data from '163' packages
    [INFO]: Extracted data stored under '/tmp/art_data'
    
  • 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.

    $ scripts/update-vdex-location-checksums.sh -h
      Usage: update-vdex-location-checksums.sh [options]
        options:
          -i|--input <file> : Input Vdex file to repair location checksum(s) within
          -a|--app <file>   : Input Apk file to extract location checksum(s) from
          -o|--output <dir> : 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 <path> : Directory with Vdex files or single file
          -o|--output <dir> : 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)
  • 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 unquicken bytecode
    • Improve Dex disassembler output by resolving class & method definitions
    • Improve Dex disassembler output by annotating classes & methods access flags
    • Fixed a bug when printing number of class fields and method from Dex disassembler
    • Utility script to automate extraction of ART compiler output resources from a device
    • Dex file API improvements
  • 0.2.3 - 16 October 2017
    • Improve disassembler output when decompiling NOP instructions (effectively ignore spacers)
  • 0.2.2 - 16 October 2017
    • Fix UAF bug when processing multiple files
  • 0.2.1 - 16 October 2017
    • Option to save output to log file instead of (default) STDOUT (-l, --log-file)
    • Dump Vdex header information with verbose debug option
    • Fix minor memory leaks & memory corruptions in disassembler engine
  • 0.2.0 - 16 October 2017
    • Unquicken decompiler stable release (-u, --unquicken)
    • Implement Dex bytecode disassembler (-d, --disassemble)
  • 0.1.1 - 13 October 2017
    • Unquicken decompiler beta release (-u, --unquicken)
    • Allow override of output Dex files (-f, --file-override)
  • 0.1.0 - 8 October 2017
    • Initial release

ToDo

  • Disassembler performance & usability improvements

License

   Anestis Bechtsoudis <[email protected]>
   Copyright 2017 - 2020 by CENSUS S.A. All Rights Reserved.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

vdexextractor's People

Contributors

anestisb avatar angea avatar chenxiaolong avatar gesangtome avatar jiajunpei avatar rulliam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vdexextractor's Issues

Cant extract from Android P vdex

C:\BatchApkTool\_system\framework\arm>vdexExtractor.exe -i boot.vdex -v 4
[INFO] Processing 1 file(s) from boot.vdex
[DEBUG] [7492] 2018/04/11 15:46:46 (vdexExtractor.c:212 main) Processing 'boot.vdex'
[DEBUG] [7492] 2018/04/11 15:46:46 (vdexExtractor.c:231 main) Invalid Vdex header - skipping 'boot.vdex'
[INFO] 0 out of 0 Vdex files have been processed
[INFO] 0 Dex files have been extracted in total
[INFO] Extracted Dex files are available in '.'

This file from official Android P Developer Preview firmware
boot.vdex.zip

(Question) Can it be a conversion problem from .cdex to .dex?

I was able to complete a deodex with Android 9, but I had a strange problem, which I'm trying to understand, basically to get the device up and running the following files:

framework/arm
framework/arm64
framework/oat
framework/*.vdex

I can not figure out if this problem is due to the conversion from .cdex to .dex or maybe it's the new .rel files?

As a premise the script I use works perfectly on android 8.x so I exclude a script problem

Segfault when extracting vdex

(french here)

[INFO] Processing 1 file(s) from framework/oat/arm64/services.vdex
[DEBUG] [18604] 2018/08/26 20:55:47 (vdexExtractor.c:194 main) Processing 'framework/oat/arm64/services.vdex'
[DEBUG] [18604] 2018/08/26 20:55:47 (vdex_api.c:46 vdexApi_initEnv) Initializing environment for Vdex version '019'
------ Vdex Header Info -------
magic header : vdex
verifier dependencies version : 019
dex section version : 002
number of dex files : 1 (1)
verifier dependencies size : 16ff4 (94196)
verifier dependencies offset : 9168a8 (9529512)
quickening info size : 58ec (22764)
quickening info offset : 92d89c (9623708)
dex section header offset : 18 (24)
dex size : 14cc84 (1363076)
dex shared data size : 7c9c00 (8166400)
dex files info :
[0] location checksum : 6ef52d8d (1861561741)
---- EOF Vdex Header Info ----
[DEBUG] [18604] 2018/08/26 20:55:47 (vdex/vdex_019.c:195 vdex_019_GetNextDexFileData) Processing first Dex file at offset:0x28
[DEBUG] [18604] 2018/08/26 20:55:47 (dex.c:375 dex_isValidCDex) CompactDex version '001' detected
Erreur de segmentation

how can i get a vdexExtractor.exe

when i use “ ./make.sh gcc - compile with gcc ” in ubuntu,it return some error like -unrecognized
command line option std=c11 make*** [dex.o] Error.
so,how can i get a vdexExtractor.exe ? i cant comile your source

after deodex is lags

device : xiaomi redmi note 5 (pro )
after deodexed is lags
android 8.1
please fix it , thanks

Malformed Vdex file

Hello. I'm have a problem with decompile com.sonymobile.settings.shakecontrol.vdex file on latest version of vdexextractor.

[ERROR] Verifier dependencies section points past the end of file (234 + c > 23d)
[ERROR] Malformed Vdex file
[ERROR] Failed to process Dex files - skipping 'framework/oat/arm64/com.sonymobile.settings.shakecontrol.vdex'

If i'm using version 0.4.1 all works, i can decompile this file and it work. I can deodex classes.dex from this file via baksmali.
Why latest version of vdexextractor show me that error?

some opcode can't be recovery to dex bytecode

system: MIUI 10 based Android 8.1
jar: core-oj.jar
class: java.lang.invoke.Transformers$CollectArguments
method: public void transform(dalvik.system.EmulatedStackFrame stackFrame)

screenshot_2018-08-18-10-37-34-787_bin mt plus

Bootloop devices with framework/*.jar files android 9.x

Hello @anestisb , with the new vdexextractor 0.51 for android 9.x I found a bootloop of the device, I would like to understand if this problem can be caused by a problem of conversion from cdex.

Partial error:-->https://pastebin.com/rDXuzSZ7

Logcat complete-->https://drive.google.com/open?id=14aYKhuW2pJrxGI0v6TO-a2rrqAgJzRWY

Files framework-->https://drive.google.com/open?id=102DLsG1OLd4Dz2cVicaD_MsJ5neoBqYY

Is it possible to check if it is a conversion problem?

Thanks for help

the latest source don't support android 9.0 vdex parse ???

@anestisb,when i download your latest code and compile a vdexExtractor tool , i parse android P vdex ,get result as below . Doesn't your code support Android 9.0 ???

root@book-virtual-machine:/work/vdexExtractor-master/bin# ./vdexExtractor -i tmp/boot-framework.vdex -o tmp --deps -f
[INFO] Processing 1 file(s) from tmp/boot-framework.vdex
[ERROR] Unsupported Vdex version
[WARNING] Invalid Vdex header - skipping 'tmp/boot-framework.vdex'
[INFO] 0 out of 0 Vdex files have been processed
[INFO] 0 Dex files have been extracted in total
[INFO] Extracted Dex files are available in 'tmp'

Problem MiLauncherGlobal.vdex

vdexExtractor update from last commit

File vdex

Error:

./vdexExtractor -i MiLauncherGlobal.vdex [INFO] Processing 1 file(s) from MiLauncherGlobal.vdex [FATAL] ((idx)) < ((dex_getMethodIdsSize(dexFileBuf))

back to .vdex

Thank you very much for your tools.
I want to know how to restore the modified class.dex file to.Vdex file. After merging, the system will not be smooth.

Only question deodex android P.

Thank you for today's update for android P, but I wanted to ask you for information, launching the command "./vdexExtractor -i Apk.vdex" I have output Apk_classes.cdex, is it possible to have Apk_classes.dex as android 8.x?

If Possible - Prebuilt Binaries?

Hello,

I know a lot of people in Android want to Deodex and patch their ROMs for Signature Spoofing to do microG on, and just running the cmds to accomplish this as it relates to getting you there with vdexExtractor are simple.

The hard part for these newbies is compiling in Windows who have no clue.

So I understand all the differences on systems, libs, dependencies etc., I compile in Linux all the time.

If possible for you and you have the time, I know the Newbie Community out there would appreciate some Windows Binaries...

Thank for your consideration...

Compile errors

First, thank you for this wonderful tool. Your contributions are greatly appreciated :)

Starting with commit 5d460e1 I am unable to compile vdexExtractor on 64-bit Ubuntu Linux 16.04. I used the generic ./make.sh command to compile. The error follows:

gcc -c -std=c11 -D_GNU_SOURCE -Wall -Wextra -Werror -g -ggdb -c dex.c -o dex.o
dex.c:39:42: error: initializer element is not constant
 static const u2 kFlagPreHeaderCombined = kFlagPreHeaderRegisterSize | kFlagPreHeaderInsSize |
                                          ^
Makefile:53: recipe for target 'dex.o' failed
make: *** [dex.o] Error 1

Thank you for your time :)

Script request to use deodex command line

Meanwhile, I thank the developer of this excellent tool that allows the deodex of Android or very quickly.

I wanted to ask if you could create a script to run the deodex from a specific folder, for example:

I have the folder "system" on my pc launch the command ./deodex.sh and he reads the directories and makes the deodex of that folder.

I know I'm asking a lot, but obviously the trouble will be compensated.

Thank you for your attention

fail to make with gcc

ubuntu32 16lts
make: Entering directory '/home/phoenix/Downloads/vdexExtractor-master/src'
rm -f *.o
rm -f /.o
rm -f vdexExtractor
make: Leaving directory '/home/phoenix/Downloads/vdexExtractor-master/src'
make: Entering directory '/home/phoenix/Downloads/vdexExtractor-master/src'
gcc -c -std=c11 -D_GNU_SOURCE -Wall -Wextra -Werror -c out_writer.c -o out_writer.o
gcc -c -std=c11 -D_GNU_SOURCE -Wall -Wextra -Werror -c log.c -o log.o
gcc -c -std=c11 -D_GNU_SOURCE -Wall -Wextra -Werror -c vdexExtractor.c -o vdexExtractor.o
In file included from vdexExtractor.c:30:0:
vdex.h:26:18: fatal error: zlib.h: No such file or directory
compilation terminated.
Makefile:42: recipe for target 'vdexExtractor.o' failed
make: *** [vdexExtractor.o] Error 1
make: Leaving directory '/home/phoenix/Downloads/vdexExtractor-master/src'
[-] build failed

Linux: compact_dex_converter fails with "Illegal instruction (core dumped)"

Hello,

When trying to convert cdex to dex, compact_dex_converter fails:

$ bin/compact_dex_converterd services_classes.cdex 
Opened 'services_classes.cdex', DEX version '001'
Illegal instruction (core dumped)

You asked if I would use valgrind to run it, and to my surprise it works when run through valgrind:

$ valgrind bin/compact_dex_converterd services_classes.cdex 
==6242== Memcheck, a memory error detector
==6242== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==6242== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==6242== Command: bin/compact_dex_converterd services_classes.cdex
==6242== 
--6242-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x13
--6242-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x13
Opened 'services_classes.cdex', DEX version '001'
compact_dex_converterd I 09-07 08:17:15  6242  6242 compact_dex_converter_main.cc:172] StandardDex file successfully extracted to services_classes.cdex.new
==6242== 
==6242== HEAP SUMMARY:
==6242==     in use at exit: 264 bytes in 7 blocks
==6242==   total heap usage: 1,377,216 allocs, 1,377,209 frees, 115,375,932 bytes allocated
==6242== 
==6242== LEAK SUMMARY:
==6242==    definitely lost: 0 bytes in 0 blocks
==6242==    indirectly lost: 0 bytes in 0 blocks
==6242==      possibly lost: 0 bytes in 0 blocks
==6242==    still reachable: 264 bytes in 7 blocks
==6242==         suppressed: 0 bytes in 0 blocks
==6242== Rerun with --leak-check=full to see details of leaked memory
==6242== 
==6242== For counts of detected and suppressed errors, rerun with: -v
==6242== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Now I am really confused

compact_dex_converter crashing when verifying some framework converted files

$ gdb /tmp/vdexExtractor/tools/deodex/hostTools/Linux/api-API_28/bin/compact_dex_converter
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/vdexExtractor/tools/deodex/hostTools/Linux/api-API_28/bin/compact_dex_converter...done.
(gdb) run -v -w . old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex
Starting program: /tmp/vdexExtractor/tools/deodex/hostTools/Linux/api-API_28/bin/compact_dex_converter -v -w . old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Opened 'old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex', DEX version '001'
compact_dex_converter W 09-08 12:27:03 19161 19161 dex_file_verifier.cc:377] Ignoring bad checksum (c6c4c142, expected be17fbb4)
compact_dex_converter F 09-08 12:27:03 19161 19161 dexlayout.cc:1950] Check failed: output_dex_file != nullptr Failed to re-open output file:Failure to verify dex file 'memory mapped file for old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex': Method may have only one of public/protected/private, Ljava/lang/Object;.identityHashCode: f

Program received signal SIGSEGV, Segmentation fault.
art::Mutex::ExclusiveLock (this=0x0, self=0x0) at art/runtime/base/mutex.cc:435
435	art/runtime/base/mutex.cc: No such file or directory.
(gdb) bt
#0  art::Mutex::ExclusiveLock (this=0x0, self=0x0) at art/runtime/base/mutex.cc:435
#1  0x00007ffff7bf98ef in art::MutexLock::MutexLock (self=0x0, mu=..., this=<optimized out>) at art/runtime/base/mutex.h:513
#2  art::Runtime::Abort (
    msg=0x55555555d9e0 "Check failed: output_dex_file != nullptr Failed to re-open output file:Failure to verify dex file 'memory mapped file for old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex"...) at art/runtime/runtime.cc:545
#3  0x00007ffff7fee720 in std::__1::function<void (char const*)>::operator()(char const*) const (this=<optimized out>,
    __arg=0x55555555d9e0 "Check failed: output_dex_file != nullptr Failed to re-open output file:Failure to verify dex file 'memory mapped file for old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex"...) at external/libcxx/include/functional:1916
#4  android::base::LogMessage::~LogMessage (this=0x7fffffffd810) at system/core/base/logging.cpp:458
#5  0x00007ffff7fb6a58 in art::DexLayout::ProcessDexFile (this=0x7fffffffda80, file_name=0x7ffff5005010 "dex\n039", dex_file=0x55555555d810,
    dex_file_index=<optimized out>, dex_container=<optimized out>, error_msg=<optimized out>) at art/dexlayout/dexlayout.cc:1950
#6  0x0000555555556f54 in art::ProcessFile (file_name=0x7fffffffdfa4 "old/vdexExtractor_decompiled/boot-core-oj/decompiled/boot-core-oj_classes.cdex",
    out_file=<optimized out>, output_dex_directory=<optimized out>, verify_output_file=<optimized out>) at art/dexlayout/compact_dex_converter_main.cc:111
#7  art::DexlayoutDriver (argc=5, argv=<optimized out>) at art/dexlayout/compact_dex_converter_main.cc:235
#8  0x0000555555557ead in main (argc=5, argv=0x7fffffffdc98) at art/dexlayout/compact_dex_converter_main.cc:252

Need to explain Android 9 deodex

It's very confusing, not obvious what is the way to deodex Android 9.

Can you please send me a draft of the list of the commands to run ?

I will elaborate on this and create a pull request to have a clear doc with pleasure, or better a bash script. It's my job !

I try to deodex vdex files to enable signature spoofing to install MicroG via NanoDroid for LineageOS 16.0 alpha (Android 9.0 Pie SM-A520F device)

I follow instructions from here

I wonder how to use vdexextractor/tools/deodex/run.sh

What I have tried so far :

adb shell
$ find / -name '*.vdex' 2>/dev/null > /sdcard/list.vdex

# from Linux
$ adb pull /sdcard/list.vdex ~
$ while read a; do
    mkdir -p ./${a%/*}
    adb pull "$a" ./$a
done < ~/list.vdex
$ find system
system/system/framework/boot-android.test.base.vdex
system/system/framework/arm64/boot-android.test.base.vdex
system/system/framework/arm64/boot-ext.vdex
system/system/framework/arm64/boot-telephony-common.vdex
system/system/framework/arm64/boot-conscrypt.vdex
system/system/framework/arm64/boot-android.hidl.base-V1.0-java.vdex
system/system/framework/arm64/boot-framework-oahl-backward-compatibility.vdex
system/system/framework/arm64/boot-okhttp.vdex
system/system/framework/arm64/boot-bouncycastle.vdex
system/system/framework/arm64/boot-android.hidl.manager-V1.0-java.vdex
system/system/framework/arm64/boot-ims-common.vdex
system/system/framework/arm64/boot-voip-common.vdex
system/system/framework/arm64/boot.vdex
system/system/framework/arm64/boot-core-libart.vdex
system/system/framework/arm64/boot-apache-xml.vdex
system/system/framework/arm64/boot-framework.vdex
system/system/framework/boot-ext.vdex
system/system/framework/boot-telephony-common.vdex
system/system/framework/boot-conscrypt.vdex
system/system/framework/boot-android.hidl.base-V1.0-java.vdex
system/system/framework/boot-framework-oahl-backward-compatibility.vdex
system/system/framework/boot-okhttp.vdex
system/system/framework/boot-bouncycastle.vdex
system/system/framework/oat/arm64/wifi-service.vdex
system/system/framework/oat/arm64/com.android.location.provider.vdex
system/system/framework/oat/arm64/org.lineageos.hardware.vdex
system/system/framework/oat/arm64/org.lineageos.platform.vdex
system/system/framework/oat/arm64/ethernet-service.vdex
system/system/framework/oat/arm64/services.vdex
system/system/framework/boot-android.hidl.manager-V1.0-java.vdex
system/system/framework/boot-ims-common.vdex
system/system/framework/boot-voip-common.vdex
system/system/framework/boot.vdex
system/system/framework/boot-core-libart.vdex
system/system/framework/arm/boot-android.test.base.vdex
system/system/framework/arm/boot-ext.vdex
system/system/framework/arm/boot-telephony-common.vdex
system/system/framework/arm/boot-conscrypt.vdex
system/system/framework/arm/boot-android.hidl.base-V1.0-java.vdex
system/system/framework/arm/boot-framework-oahl-backward-compatibility.vdex
system/system/framework/arm/boot-okhttp.vdex
system/system/framework/arm/boot-bouncycastle.vdex
system/system/framework/arm/boot-android.hidl.manager-V1.0-java.vdex
system/system/framework/arm/boot-ims-common.vdex
system/system/framework/arm/boot-voip-common.vdex
system/system/framework/arm/boot.vdex
system/system/framework/arm/boot-core-libart.vdex
system/system/framework/arm/boot-apache-xml.vdex
system/system/framework/arm/boot-framework.vdex
system/system/framework/boot-apache-xml.vdex
system/system/framework/boot-framework.vdex

$ cd /path/to/vdexExtractor
$ find ../system -name '*.vdex' | while read a; do
     dir=${a%/*]
    tools/deodex/run.sh -i "$a" -o ../system_new
 done

But now, I have only as *.dex :

system_new/framework/arm64/vdexExtractor_deodexed/boot-framework/boot-framework_classes3.dex
system_new/framework/arm64/vdexExtractor_deodexed/boot-framework/boot-framework_classes2.dex
system_new/framework/arm64/vdexExtractor_deodexed/boot-framework/boot-framework_classes.dex
system_new/framework/vdexExtractor_deodexed/boot-framework/boot-framework_classes3.dex
system_new/framework/vdexExtractor_deodexed/boot-framework/boot-framework_classes2.dex
system_new/framework/vdexExtractor_deodexed/boot-framework/boot-framework_classes.dex
system_new/framework/oat/arm64/vdexExtractor_deodexed/services/services_classes.dex
system_new/framework/arm/vdexExtractor_deodexed/boot-framework/boot-framework_classes3.dex
system_new/framework/arm/vdexExtractor_deodexed/boot-framework/boot-framework_classes2.dex
system_new/framework/arm/vdexExtractor_deodexed/boot-framework/boot-framework_classes.dex

I think I miss something.

  • I think I don't have one dex file per .vdex
  • the path is messy with vdexExtractor_deodexe extra dir
  • does I need to use instead bin/vdexExtractor binary ? The doc said to use 'compact_dex_extractor', but don't know how if not ran with tools/deodex/run.sh

I think I miss-use the tool. What is the full list of commands to be able to patch Pie aka Android 9 ?

小米8se的8.9.13开发版刷机包中framework中的services.vdex转换失败

unverified classes: number_of_classes=14 0000: 'Landroid/hardware/vibrator/V1_0/Constants$Effect;' is expected to be verified at runtime 0001: 'Landroid/hardware/vibrator/V1_0/Constants$EffectStrength;' is expected to be verified at runtime 0002: 'Landroid/hardware/vibrator/V1_0/Constants;' is expected to be verified at runtime 0003: 'Landroid/hidl/base/V1_0/DebugInfo$Architecture;' is expected to be verified at runtime 0004: 'Landroid/hidl/base/V1_0/DebugInfo;' is expected to be verified at runtime 0005: 'Landroid/hidl/base/V1_0/IBase$Proxy;' is expected to be verified at runtime 0006: 'Landroid/hidl/base/V1_0/IBase$Stub;' is expected to be verified at runtime 0007: 'Landroid/hidl/base/V1_0/IBase;' is expected to be verified at runtime 0008: 'Landroid/net/INetd$Stub$Proxy;' is expected to be verified at runtime 0009: 'Landroid/net/INetd$Stub;' is expected to be verified at runtime 0010: 'Landroid/net/INetd;' is expected to be verified at runtime 0011: 'Landroid/os/IInstalld$Stub$Proxy;' is expected to be verified at runtime 0012: 'Landroid/os/IInstalld$Stub;' is expected to be verified at runtime 0013: 'Landroid/os/IInstalld;' is expected to be verified at runtime ----- EOF Vdex Deps Info ----- [ERROR] Unexpected checksum (38206974 vs b4756bdf) - failed to unquicken Dex file [ERROR] Failed to process Dex files - skipping '/tmp/services.vdex' [INFO] 0 out of 1 Vdex files have been processed [INFO] 0 Dex files have been extracted in total [INFO] Extracted Dex files are available in '/tmp'
附下载地址:https://pan.baidu.com/s/1XlRsImJacd6vlx3Ra6sn-Q

taimen android 8.1 deodexing issues

Tested taimen-opm1.171019.011-factory-2df1c1cb deodexing and got two errors during framework deodexing:

[DEBUG] [11132] 2017/12/20 20:22:23 (vdexExtractor.c:206 main) Processing 'services.vdex'
[DEBUG] [11132] 2017/12/20 20:22:23 (vdex.c:64 vdex_isVersionValid) Vdex version '010' detected
------ Vdex Header Info ------
magic header & version      : vdex-010
number of dex files         : 1 (1)
dex size (overall)          : 85b388 (8762248)
verifier dependencies size  : 120f8 (73976)
verifier dependencies offset: 85b3a4 (8762276)
quickening info size        : a72 (2674)
quickening info offset      : 86d49c (8836252)
dex files info              :
  [0] location checksum : 7c35823a (2083881530)
---- EOF Vdex Header Info ----
[DEBUG] [11132] 2017/12/20 20:22:23 (vdex.c:110 vdex_GetNextDexFileData) Processing first Dex file at offset:0x1c
[DEBUG] [11132] 2017/12/20 20:22:23 (dex.c:327 dex_isValidDexMagic) Dex version '037' detected
[ERROR] [11132] 2017/12/20 20:22:23 (vdex_backend_v10.c:451 vdex_process_v10) Unexpected checksum (89f9fc35 vs fa7bb981) - failed to unquicken Dex file
[DEBUG] [11132] 2017/12/20 20:22:23 (vdex.c:217 vdex_process) Took 78 ms to process Vdex file
[ERROR] [11132] 2017/12/20 20:22:23 (vdexExtractor.c:262 main) Failed to process Dex files - skipping 'services.vdex'
[INFO] 0 out of 1 Vdex files have been processed
[INFO] 0 Dex files have been extracted in total
[INFO] Extracted Dex files are available in '.'

and

[INFO] Processing 1 file(s) from wifi-service.vdex
[DEBUG] [2284] 2017/12/20 20:28:09 (vdexExtractor.c:206 main) Processing 'wifi-service.vdex'
[DEBUG] [2284] 2017/12/20 20:28:09 (vdex.c:64 vdex_isVersionValid) Vdex version '010' detected
------ Vdex Header Info ------
magic header & version      : vdex-010
number of dex files         : 1 (1)
dex size (overall)          : 1cffac (1900460)
verifier dependencies size  : 34f0 (13552)
verifier dependencies offset: 1cffc8 (1900488)
quickening info size        : 74 (116)
quickening info offset      : 1d34b8 (1914040)
dex files info              :
  [0] location checksum : a8dc636b (2833015659)
---- EOF Vdex Header Info ----
[DEBUG] [2284] 2017/12/20 20:28:09 (vdex.c:110 vdex_GetNextDexFileData) Processing first Dex file at offset:0x1c
[DEBUG] [2284] 2017/12/20 20:28:09 (dex.c:327 dex_isValidDexMagic) Dex version '037' detected
[ERROR] [2284] 2017/12/20 20:28:09 (vdex_backend_v10.c:451 vdex_process_v10) Unexpected checksum (c684b9f3 vs f02f3db5) - failed to unquicken Dex file
[DEBUG] [2284] 2017/12/20 20:28:09 (vdex.c:217 vdex_process) Took 31 ms to process Vdex file
[ERROR] [2284] 2017/12/20 20:28:09 (vdexExtractor.c:262 main) Failed to process Dex files - skipping 'wifi-service.vdex'
[INFO] 0 out of 1 Vdex files have been processed
[INFO] 0 Dex files have been extracted in total
[INFO] Extracted Dex files are available in '.'

files.zip

Can't decompile deodexed files on U11

I tried to decompile several files, framework.jar, telephony-common.jar, services.jar.

All fail with several errors that always look like:

java -jar baksmali.jar d services.jar

Error occurred while disassembling class classname - skipping class
org.jf.util.ExceptionWithContext: The last instruction in method methodname is truncated

When I deodex with baksmali, it works fine.

Other files I tried, like SystemUI.apk work fine.

services.zip

about debug info in the dex file

Is there any option not to include the '.line/.params/..' when deodex.
now,it is below after use apktool:

.method public constructor (Landroid/content/Context;)V
.locals 5

.param p1, "context"    # Landroid/content/Context;

.line 72

invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V

Compact Dex on Windows

@anestisb
Hi Dev,

As you now compiling AOSP in windows is not available so we can not compile the compact dex converter for android Pie for windows.

could you add support to compiling it on windows or create a project on Github like vdexExtractor so we can compile it on Cygwin too as i do with vdexExtractor ?

Bug when processing Vdex 019 containers with multi-cdex

Seems that the QuickenInfoOffsetTable offsets are not properly calculated when processing a Vdex 019 container with multi-cdex files.

[DEBUG] [33974] 2018/08/26 17:30:04 (vdexExtractor.c:194 main) Processing '/Users/anestisb/Desktop/vdex_019/Drive.vdex'
[DEBUG] [33974] 2018/08/26 17:30:04 (vdex_api.c:46 vdexApi_initEnv) Initializing environment for Vdex version '019'
------ Vdex Header Info -------
magic header                  : vdex
verifier dependencies version : 019
dex section version           : 002
number of dex files           : 2 (2)
verifier dependencies size    : 128cc (75980)
verifier dependencies offset  : 983478 (9974904)
quickening info size          : c5930 (809264)
quickening info offset        : 995d44 (10050884)
dex section header offset     : 1c (28)
dex size                      : 1bcc60 (1821792)
dex shared data size          : 7c67f0 (8153072)
dex files info                :
  [0] location checksum : ac4b12de (2890601182)
  [1] location checksum : 106d5b3b (275602235)
---- EOF Vdex Header Info ----
[DEBUG] [33974] 2018/08/26 17:30:04 (vdex/vdex_019.c:195 vdex_019_GetNextDexFileData) Processing first Dex file at offset:0x2c
------ Dex Header Info ------
magic        : cdex-001
checksum     : 7cc0dfd3 (2093014995)
signature    : 914a4a1cb33defdda796aef57936fc1c262ebd72
fileSize     : 19aff8 (1683448)
headerSize   : 88 (136)
endianTag    : 12345678 (305419896)
linkSize     : 0 (0)
linkOff      : 0 (0)
mapOff       : 7388fc (7571708)
stringIdsSize: a27b (41595)
stringIdsOff : 88 (136)
typeIdsSize  : 3d1e (15646)
typeIdsOff   : 28a74 (166516)
protoIdsSize : 2feb (12267)
protoIdsOff  : 37eec (229100)
fieldIdsSize : b167 (45415)
fieldIdsOff  : 5bdf0 (376304)
methodIdsSize: fec6 (65222)
methodIdsOff : b4928 (739624)
classDefsSize: 3385 (13189)
classDefsOff : 133f58 (1261400)
dataSize     : 75d620 (7722528)
dataOff      : 1bcc5c (1821788)
featureFlags                : 0 (0)
debuginfoOffsetsPos         : 7389cc (7571916)
debugInfoOffsetsTableOffset : 20ca0 (134304)
debugInfoBase               : 46cd36 (4640054)
ownedDataBegin              : 8 (8)
ownedDataEnd                : 75d620 (7722528)
-----------------------------
[DEBUG] [33974] 2018/08/26 17:30:04 (dex.c:375 dex_isValidCDex) CompactDex version '001' detected
file #0: classDefsSize=13189
  class #0: a ('La;')
   access=0011 (PUBLIC FINAL)
   source_file=PG, class_data_off=5d8440 (6128704)
   static_fields=1, instance_fields=3, direct_methods=3, virtual_methods=1
   direct_method #0: <init> (Landroid/content/Context;)V
    access=10002 (PRIVATE CONSTRUCTOR)
    codeOff=8 (8)
    quickening_size=0 (0)
      00000c: 7010 dfc2 0200                         |0000: invoke-direct {v2}, Ljava/lang/Object;.<init>:()V // method@c2df
      000012: e910 3100 0300                         |0003: invoke-virtual-quick {v3}, [0031] // vtable #0031
[FATAL] [33974] 2018/08/26 17:30:04 (vdex/vdex_decompiler_019.c:202 vdex_decompiler_019_decompile) ((quicken_info_number_of_indices)) > ((0))

SEGFAULT with some .vdex

Crash with some .vdex files, built with gcc, tested on MSYS2, Gentoo, Arch

Program received signal SIGSEGV, Segmentation fault.
0x00005555555702f1 in QuickeningInfoItGetCurrentPtr () at vdex/vdex_backend_010.c:54
54	  return quickening_info_ptr + current_code_item_ptr[1] + sizeof(u4);
(gdb) bt
#0  0x00005555555702f1 in QuickeningInfoItGetCurrentPtr () at vdex/vdex_backend_010.c:54
#1  0x0000555555571937 in vdex_backend_010_process (VdexFileName=0x7fffffffded2 "system/app/FidoClient/oat/arm64/FidoClient.vdex", cursor=0x7ffff7297000 "vdex010", pRunArgs=0x7fffffffd7f0) at vdex/vdex_backend_010.c:395
#2  0x000055555557263a in vdex_010_process (VdexFileName=0x7fffffffded2 "system/app/FidoClient/oat/arm64/FidoClient.vdex", cursor=0x7ffff7297000 "vdex010", pRunArgs=0x7fffffffd7f0) at vdex/vdex_010.c:183
#3  0x00005555555641a3 in main (argc=5, argv=0x7fffffffdac8) at vdexExtractor.c:229

.vdex files causing segfault

Segmentation fault

Got segmentation fault on SecFactoryPhoneTest.vdex(vdex 0.10 from Samsung galaxy note 9, android 8.1 rom)

[INFO] Processing 1 file(s) from SecFactoryPhoneTest.vdex
[DEBUG] [2836] 2018/08/30 19:44:12 (vdexExtractor.c:194 main) Processing 'SecFactoryPhoneTest.vdex'
[DEBUG] [2836] 2018/08/30 19:44:12 (vdex_api.c:41 vdexApi_initEnv) Initializing environment for Vdex version '010'
------ Vdex Header Info ------
magic header & version      : vdex-010
number of dex files         : 1 (1)
dex size (overall)          : 9d28 (40232)
verifier dependencies size  : 2b8 (696)
verifier dependencies offset: 9d44 (40260)
quickening info size        : 4 (4)
quickening info offset      : 9ffc (40956)
dex files info              :
  [0] location checksum : 1d2ba12a (489398570)
---- EOF Vdex Header Info ----
[DEBUG] [2836] 2018/08/30 19:44:12 (vdex/vdex_010.c:75 vdex_010_GetNextDexFileData) Processing first Dex file at offset:0x1c
[DEBUG] [2836] 2018/08/30 19:44:12 (dex.c:351 dex_isValidDex) Dex version '037' detected
Segmentation fault (core dumped)

SecFactoryPhoneTest.zip

Strategy to convert CompactDex back to StandardDex

When the Vdex 019 unquicken decompiler is completed (some minor bugs left to be fixed), need to figure out a way to convert CompactDex back to StandardDex. This is required since most tools (e.g. JEB2) and AOSP build infra (see android-prepare-vendor requirements) does not support CompactDex. And most likely they never will since CompactDex is considered an ART internal file.

Some possible approaches are:

  • Use libdexlayout from ART
  • Try to manually convert CompactDex without implementing a layout IR
  • Fork the Dex layout IR from libart and wrap-around a conversion API

All 3 approaches require a significant deal of code reading and testing, with the optimal candidate being the first for the time being. So this might take some time.

Unexpected checksum (7d70f08b vs 4ff0a59e) - failed to unquicken Dex file

I have to specify --ignore-crc-error in order to generate dex file, but the result dex looks corrupted.

dex2oat output:
oat_writer.cc:3082] Failed to open dex file from oat file. File: app.apk Error: Failure to verify dex file 'app.apk': could not find declaring class for virtual method index 6634

[ERROR] Unsupported Vdex version - [WARNING] Invalid Vdex header

Hello Everybody!

I'm trying to get the cdex files from my boot-framework.vdex file but i run into thoses error:
I did look on other posts to try to figure out what was wrong by myself without luck:
tried on master and 0.5.2 with no luck: same error:

Vdex are from Android 9 Onplus 6 Rom

root@omv-labo:~/vdexExtractor# /root/vdexExtractor/bin/vdexExtractor -i "/root/boot-framework.vdex" -o "/root/extracted" --log-file=/root/log.txt [INFO] Processing 1 file(s) from /root/boot-framework.vdex [ERROR] Unsupported Vdex version [WARNING] Invalid Vdex header - skipping '/root/boot-framework.vdex' [INFO] 0 out of 0 Vdex files have been processed [INFO] 0 Dex files have been extracted in total [INFO] Extracted Dex files are available in '/root/extracted'

Log file is empty.

Am i doing something wrong?

Thanks for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.