anestisb / vdexExtractor

Tool to decompile & extract Android Dex bytecode from Vdex files
Apache License 2.0
1k stars 214 forks source link

Bug when processing Vdex 019 containers with multi-cdex #22

Closed anestisb closed 6 years ago

anestisb commented 6 years ago

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))
IgorEisberg commented 6 years ago

This bug might not be relevant anymore. Tested a boot-framework.vdex and 3 CDEX files were extracted perfectly!

anestisb commented 6 years ago

Indeed this also fixed.