天天看点

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"           

继续阅读