Vdex Extractor
一款命令行工具,用于從Vdex文件反編譯和提取Android Dex字節(jié)碼的工具。
編譯
克隆此存儲庫
如果要為Android設(shè)備進(jìn)行交叉編譯,請安裝Android NDK
make.sh使用所需的構(gòu)建目標(biāo)調(diào)用bash腳本$ ./make.sh- 如果CC未從env定義,則默認(rèn)使用gcc$ ./make.sh gcc – 用gcc編譯$ ./make.sh clang – 用clang編譯$ ./make.sh cross-android – 使用NDK交叉編譯(armeabi-v7a,arm64-v8a,x86和x86_64)可執(zhí)行文件復(fù)制到bin目錄下,對于調(diào)試版本使用$ DEBUG=true ./make.sh
依賴關(guān)系
主機(jī)系統(tǒng)中應(yīng)安裝以下外部庫:
zlib
macos:brew install zlib-devel帶macports的macOS: port install zlibLinux: apt install libz-dev其他Linux / Unix系統(tǒng):檢查可用的包管理器或從源代碼編譯使用cygwin的Windows:zlib-devel從cygwin安裝程序安裝
用法
$ bin/vdexExtractor -h
vdexExtractor ver. 0.5.2
Anestis Bechtsoudis
Copyright 2017 - 2018 by CENSUS S.A. All Rights Reserved.
-i, --input= : 輸入目錄(遞歸搜索)或單個(gè)文件
-o, --output= : 輸出路徑(默認(rèn)與輸入相同)
-f, --file-override : 如果文件已經(jīng)存在允許覆蓋(默認(rèn):false)
--no-unquicken : 禁用unquicken字節(jié)碼反編譯器 (don't de-odex)
--deps : 轉(zhuǎn)儲經(jīng)過驗(yàn)證的依賴信息
--dis : 啟用字節(jié)碼反匯編器
--ignore-crc-error : 反編譯Dex 忽略CRC錯誤
--new-crc= : 提取Apk或Dex文件位置校驗(yàn)和文本文件
--get-api : 基于Vdex版本獲取Android API級別
-v, --debug=LEVEL : 日志級別 默認(rèn): '3' (INFO)
-l, --log-file=: 保存反匯編器或驗(yàn)證依賴項(xiàng)輸出到日志文件
-h, --help : 幫助信息
字節(jié)碼Unquickening解碼器
Vdex文件包含所有quick_info數(shù)據(jù)(舊vtable),用于恢復(fù)字節(jié)碼優(yōu)化過程中應(yīng)用的dexto -dex轉(zhuǎn)換。這里是創(chuàng)建一個(gè)能夠快速恢復(fù)優(yōu)化字節(jié)碼的獨(dú)立工具,不需要從AOSP構(gòu)建整個(gè)libart。Vdex完全unquicken功能也作為AOSP oatdump libart工具的一部分實(shí)現(xiàn)。可在此處獲得。如果你想在Oreo版本中使用oatdump,你可以在這里使用相應(yīng)的補(bǔ)丁,或者在oatdump ++工具的fork和build(內(nèi)部和AOSP_SRC_ROOT工作空間)中使用oreo-release分支。谷歌已經(jīng)發(fā)布了提供的補(bǔ)丁以及ART運(yùn)行時(shí)的Android Pie版本。
驗(yàn)證迭代器的依賴關(guān)系
當(dāng)?shù)谝淮尉幾g(優(yōu)化)Dex字節(jié)碼文件時(shí),dex2oat將執(zhí)行驗(yàn)證依賴項(xiàng)收集器,作為方法學(xué)驗(yàn)證者的一部分。驗(yàn)證依賴項(xiàng)收集器類用于記錄解析結(jié)果和類路徑中定義的類/方法/字段的類型可賦值測試。編譯驅(qū)動程序初始化類并注冊正在編譯的所有Dex文件。在這個(gè)集合之外的Dex文件中定義的類(或者沒有關(guān)聯(lián)的Dex文件的合成類)被認(rèn)為在類路徑中。所有記錄的依賴關(guān)系都存儲在生成的Vdex文件中,以及來自O(shè)atWriter類的相應(yīng)Oat文件。vdexExtractor工具集成了一個(gè)Vdex依賴項(xiàng)walker函數(shù),該函數(shù)能夠迭代所有依賴項(xiàng)信息并以人類可讀的格式轉(zhuǎn)儲它們。以下代碼段演示了示例Vdex文件的依賴項(xiàng)轉(zhuǎn)儲示例。
$ 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'
|