CalebFenton / simplify

Android virtual machine and deobfuscator
Other
4.41k stars 438 forks source link

dex Bad checksum #167

Open S4muii opened 1 year ago

S4muii commented 1 year ago

Provide specific APK, DEX, or file hash obfuscation.zip it contains the obfuscated apk and the deobuscated apk

Describe the bug after deobfuscating the sample apk . the output apk has an issue with the classs.dex . it doesn't work on jadx and neither does it work with baksmali The error produced by baksmali is

Exception in thread "main" java.lang.RuntimeException: "deobfuscated-app.apk" has no dex files
    at org.jf.baksmali.DexInputCommand.loadDexFile(DexInputCommand.java:167)
    at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:162)
    at org.jf.baksmali.Main.main(Main.java:102)

The error produced by jadx-gui is

ERROR: Failed to read zip entry: classes.dex
jadx.plugins.input.dex.DexException: Bad checksum: 0x1368762a, expected: 0x00000008
    at jadx.plugins.input.dex.utils.DexCheckSum.verify(DexCheckSum.java:22)
    at jadx.plugins.input.dex.DexFileLoader.loadDexReader(DexFileLoader.java:82)
    at jadx.plugins.input.dex.DexFileLoader.load(DexFileLoader.java:67)
    at jadx.plugins.input.dex.DexFileLoader.lambda$collectDexFromZip$2(DexFileLoader.java:92)
    at jadx.api.plugins.utils.ZipSecurity.lambda$readZipEntries$0(ZipSecurity.java:124)
    at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:103)
    at jadx.api.plugins.utils.ZipSecurity.readZipEntries(ZipSecurity.java:121)
    at jadx.plugins.input.dex.DexFileLoader.collectDexFromZip(DexFileLoader.java:90)
    at jadx.plugins.input.dex.DexFileLoader.load(DexFileLoader.java:73)
    at jadx.plugins.input.dex.DexFileLoader.loadDexFromFile(DexFileLoader.java:50)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at jadx.plugins.input.dex.DexFileLoader.collectDexFiles(DexFileLoader.java:45)
    at jadx.plugins.input.dex.DexInputPlugin.loadFiles(DexInputPlugin.java:37)
    at jadx.plugins.input.dex.DexInputPlugin.loadFiles(DexInputPlugin.java:33)
    at jadx.api.JadxDecompiler.loadInputFiles(JadxDecompiler.java:133)
    at jadx.api.JadxDecompiler.load(JadxDecompiler.java:117)
    at jadx.gui.JadxWrapper.open(JadxWrapper.java:65)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

To Reproduce

java -jar ~/Downloads/simplify-1.3.0.jar -it "org/cf/obfuscated" -et "MainActivity" obfuscated-app.apk -o deobfuscated-app.apk
baksmali d deobfuscated-app.apk -o deobfuscated-app.apk-baksmali

Attempted work-arounds I unzipped the deobfuscated apk then tried baskmali on the classes.dex alone . it worked . but the output smali code is identical to the one from the obfuscated apk smali code . nothing changed except the androidx directory has been removed. I used this to check if something is different and there was no output . meaning no files are different.

diff --recursive --brief ~/obfuscationStuff/obfuscated-app.apk-baksmali ~/obfuscationStuff/deobf_unzip/deobfuscated-app.apk-baksmali