Closed Col-E closed 2 years ago
This patch seems to fix the issue! I did encounter though the same error after using a transformer, during writing.
Transformer: com.javadeobfuscator.deobfuscator.transformers.zelix.StringEncryptionTransformer
Could this be related?
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Loading classpath
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Loading input
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Computing callers
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Transforming
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Running com.javadeobfuscator.deobfuscator.transformers.zelix.StringEncryptionTransformer
[Zelix] [StringEncryptionTransformer] Starting
[Zelix] [StringEncryptionTransformer] Decrypted strings from 465 encrypted classes
[Zelix] [StringEncryptionTransformer] Decrypted 6092 strings
[Zelix] [StringEncryptionTransformer] Done
[main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Writing
Deobfuscation failed. Please open a ticket on GitHub and provide the following error:
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.objectweb.asm.AnnotationWriter.computeParameterAnnotationsSize(AnnotationWriter.java:498)
at org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2143)
at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:489)
at com.javadeobfuscator.deobfuscator.Deobfuscator.toByteArray(Deobfuscator.java:657)
at com.javadeobfuscator.deobfuscator.Deobfuscator.lambda$start$9(Deobfuscator.java:461)
at java.base/java.util.HashMap$Values.forEach(HashMap.java:1065)
at com.javadeobfuscator.deobfuscator.Deobfuscator.start(Deobfuscator.java:459)
at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.run(DeobfuscatorMain.java:106)
at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.run(DeobfuscatorMain.java:99)
at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.main(DeobfuscatorMain.java:36)
I was able to run the transformer on the small zip attached in #876 - Does the new error you're describing here happen on the same file, or something else? I'm pretty sure this case should be covered but if a new sample is breaking it I'd like to have it to test against.
This is the jar I'm experimenting with and the one having the issue: testsubject.zip
I don't know which specific part is breaking so here is the whole jar. I'm only using one transformer: StringEncryptionTransformer
It looks like CAFED00D is able to patch it just fine but somehow the transformer re-introduces code that cannot be successfully written back. With no transformer applied I can read and write back 3A.
See comment below, figured out what was happening.
loadInput
in Deobfuscator
only uses Cafedude when the reading fails but doesn't check for the writing. Making it always use cafedude resolves the problem. I'll update the PR in a sec.
Your sample no longer crashes on write 👍
I can also confirm that the error doesn't come up anymore. Thanks for taking the time to fix this!
Something else I've noticed, When trying to excecute the deobfuscated version of the jar, I get the following exception:
During deobfuscation I see this line:
[main] INFO me.coley.cafedude.transform.IllegalStrippingTransformer - Attribute 'Code' on CODE-ATTRIBUTE will be removed since a sub-attribute is not legal!
Is that 'Code' Attribute wrongly getting stripped out by the IllegalStrippingTransformer?
This is the class file that contains the 'Code' attribute: gsonCodeAttribute.zip
I'll take a look at that later today. Probably passed a wrong parameter on my end if thats happening.
I added some additional logging and realized two things:
Another quick fix, will bump to 1.9.1
With the latest commit e82b3c5 I got a NullPointerException from the zelix.StringEncryptionTransformer
:
I narrowed it down to this class: nullpointer.zip
It is thrown at this point.
Could this be related to the fix?
Ah, unearthed a bug in where I missed a case where: inner_name_index
can be 0
Normally 0 is reserved so it thought it was bad and removed it. 1.9.2
bump incoming...
Using the latest commit, after trying to launch the deobfuscated jar I get thrown this exception:
Exception in thread "main" java.lang.annotation.IncompleteAnnotationException: picocli.CommandLine$Command missing element modelTransformer
at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:86)
at jdk.proxy2/jdk.proxy2.$Proxy4.modelTransformer(Unknown Source)
at picocli.CommandLine$Model$CommandSpec.updateCommandAttributes(CommandLine.java)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java)
at picocli.CommandLine.<init>(CommandLine.java)
The class that seem to contain the incomplete annotation is this one: IncompleteAnnotationException.zip
The only transformer used was the zelix.StringEncryptionTransformer
Ah, I was assuming the class_info_index pointed to a CP_CLASS based on its name, but it instead points to a CP_UTF8. So that was making the illegal-patcher angry.
Will update PR once jitpack publishes the artifact.
Using the latest commit, after trying to run the deobfuscated jar I get a java.lang.VerifyError
on this file VerifyError.zip
The only transformer used was the zelix.StringEncryptionTransformer
I might be wrong but it looks like there is an issue with casting?
net/miginfocom/swing/MigLayout.getPackable(Ljava/awt/Component;)Ljava/awt/Container; @38: areturn
In the zip you sent there is no getPackable
defined in either class 🤔
Its referenced in the constant pool, but there's no defined method by that name.
Hmm.. I sent only the class file that seemed relevant but I probably messed up. In this zip I have included the relevant classes (class and inner classes) along with a .java file that was produced using the cfr decompiler. MigLayout.zip
Oh the verify error is totally unrelated. I can push that to this branch as well.
I'd vote for patchAsm to be true by default
None of the other options were, so I thought it'd be odd to do so. The message you get when things fail is also quite clear:
[main] ERROR com.javadeobfuscator.deobfuscator.Deobfuscator - Could not parse sample9.class (Try adding "patchAsm: true" to the config?)
java.lang.ArrayIndexOutOfBoundsException: 10106
at org.objectweb.asm.ClassReader.readUnsignedShort(ClassReader.java:3573)
at org.objectweb.asm.ClassReader.readStringish(ClassReader.java:3703)
at org.objectweb.asm.ClassReader.readClass(ClassReader.java:3718)
As nothing happens in this repo, I updated my repo with this PR and my PR 888 and some general cleanup: https://github.com/Janmm14/deobfuscator
Resolves #876
Can add ASM patching as a flag in your config: