天天看點

apk資源加密之後反編譯失敗解決方案

作者:3tang
I: Using Apktool 2.7.0 on lxcs.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\tim\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling assets/39285EFA.dex...
Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Not a valid dex magic value: cf 77 4c c7 9b 21 01 cd
        at org.jf.dexlib2.util.DexUtil.verifyDexHeader(DexUtil.java:93)
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.getVersion(DexBackedDexFile.java:157)
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:81)
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:184)
        at org.jf.dexlib2.dexbacked.ZipDexContainer$1.getDexFile(ZipDexContainer.java:181)
        at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:89)
        at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:37)
        at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:103)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:151)
        at brut.apktool.Main.cmdDecode(Main.java:175)
        at brut.apktool.Main.main(Main.java:79)           

以上錯誤是我運作反編譯指令

java -jar "D:\tools\apktool\\apktool.jar" d -f C:\Users\tim\Desktop\lxcs.apk -o F:\360Downloads\lianxi_ori            

原因是assets下有一個dex檔案,明顯這個屬于加密檔案,不讓解析

apk資源加密之後反編譯失敗解決方案

那麼怎麼可以正常反編譯呢,方法如下,在反編譯指令後面加上

--only-main-classes           

完整的指令

apktool d -f C:\Users\tim\Desktop\lxcs.apk -o F:\360Downloads\lianxi_ori  --only-main-classes           
java -jar "D:\tools\apktool\\apktool.jar" d -f C:\Users\tim\Desktop\lxcs.apk -o F:\360Downloads\lianxi_ori --only-main-classes
I: Using Apktool 2.7.0 on lxcs.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\tim\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Copying raw assets/39285EFA.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
           

看到裡面有個Copying raw assets/39285EFA.dex file.這個就是加密的資源檔案,這個是作者不想暴露的資訊

打包工具指令也調整為:

de_smali_order = 'java -jar ' + apktoolPath + ' d -f ' + fx['input_file'] + " -o " + game_file +" --only-main-classes"           

繼續閱讀