GraxCode / threadtear

Multifunctional java deobfuscation tool suite
GNU General Public License v3.0
899 stars 123 forks source link

ZKM reference obfuscation #13

Open skidunion opened 4 years ago

skidunion commented 4 years ago

Describe what's not working The jar is obfuscated by ZKM (unknown version) and has string encryption + reference obfuscation applied. Only the calls to the string decryption method are encrypted. The tool is unable to deobfuscate it.

Java archive v4_dumpfile.zip

Log / Screenshots https://hasteb.in/xipijatu.kotlin

Please complete the following information:

GraxCode commented 4 years ago

Try to use commit 18425c9a1890b78b3c785a86dbb0b7cd22ded667. There was a bug that blocked reflection where it shouldn't get blocked.

skidunion commented 4 years ago

Still don't get to deobfuscate it 2020-12-09-02-12.log

GraxCode commented 4 years ago

Seems like it is a variant of ZKM invokedynamic obfuscation that doesn't take (J), but instead takes (IJ). I can try to implement that.

GraxCode commented 4 years ago

I tried to implement this variant of invokedynamics but it seems like there are some classes missing in your file and therefore it cannot be decrypted :/

skidunion commented 4 years ago

Oh, that's unfortunate. Anyway, I've made a sample with reference obfuscation, that the tool is unable to deobfuscate, maybe you can take a look Test.zip Log: https://hasteb.in/jelumoxe.lua

GraxCode commented 4 years ago

Which obfuscator and version is it?

skidunion commented 4 years ago

ZKM 14

skidunion commented 4 years ago

Still doesn't work (just compiled the latest version, 2.5.0) Log: https://hasteb.in/enivotal.makefile

GraxCode commented 4 years ago

I will have to update the regex for ZKM_INVOKEDYNAMIC_REAL_BOOTSTRAP_DESC. Seems like ZKM implemented multiple decryption longs / ints. You can add a long as last parameter to ZKM_INVOKEDYNAMIC_REAL_BOOTSTRAP_DESC and your Test.jar will probably decrypt.

GraxCode commented 4 years ago

Please test if it works.

skidunion commented 4 years ago

Yep, it works, but some references aren't decrypted sucessfully Here is the deobfuscated result image

skidunion commented 4 years ago

Because of the failures in some cases, it still isn't perfect. Here is another sample with the same reference obfuscation. Only ~30% of the references are decrypted sucessfully

irc-1.0.jar.zip

GraxCode commented 4 years ago

Improved it to about 42%. Decryption class often throws NPEs -> i think the cause is that there are some class files / libraries missing.

DarkyCat commented 4 years ago

I am writing to you again asking for help in decrypting ZKM. Here is the link: https://workupload.com/file/ZhbjSnnnb5K

d4ft1337 commented 4 years ago

Improved it to about 42%. Decryption class often throws NPEs -> i think the cause is that there are some class files / libraries missing.

Hi, Does ZKM work for 14.0.5? I really need.

GraxCode commented 4 years ago

Fixed a bug that caused encrypted references with longs or ints as first arguments to fail decryption

skidunion commented 4 years ago

I am writing to you again asking for help in decrypting ZKM. Here is the link: https://workupload.com/file/ZhbjSnnnb5K

The following jar uses ZKM's method parameter change (aka hardening string encryption), so its not directly reference obfuscation. With the current build, no strings or references can be decrypted

Edit: String decryption logs: https://hasteb.in/koqanudi.pl Reference decryption logs: https://hastebin.com/nejumileni.cs

GraxCode commented 4 years ago

I am writing to you again asking for help in decrypting ZKM. Here is the link: https://workupload.com/file/ZhbjSnnnb5K

The following jar uses ZKM's method parameter change (aka hardening string encryption), so its not directly reference obfuscation. With the current build, no strings or references can be decrypted

Edit: String decryption logs: https://hasteb.in/koqanudi.pl Reference decryption logs: https://hastebin.com/nejumileni.cs

Seems like a known invalid array index crashes the ConstantTracker. Will fix.

skidunion commented 4 years ago

No strings have been decrypted https://hasteb.in/inudakop.sql

edit: same with references https://hastebin.com/ikekumuqab.cs

GraxCode commented 4 years ago

I only fixed the analyzer bugs, I didn't implement ZKM 13+ support yet