Skip to content

Improve StringEncryptTransformer#27

Merged
xiguajerry merged 31 commits intomainfrom
feat/recode-string-encryption
Jan 23, 2025
Merged

Improve StringEncryptTransformer#27
xiguajerry merged 31 commits intomainfrom
feat/recode-string-encryption

Conversation

@jonesdevelopment
Copy link
Collaborator

@jonesdevelopment jonesdevelopment commented Dec 20, 2024

  • Improves the encryption and decryption method
    • Optional: Instead of passing the encrypted string to the decryption method, pass a character array

TODO:

  • Pool strings in an array (initialized in a generated method called in <clinit>)
  • Encrypt InvokeDynamicInsnNode bsm strings

@jonesdevelopment jonesdevelopment self-assigned this Dec 20, 2024
@jonesdevelopment jonesdevelopment marked this pull request as draft December 20, 2024 20:54
@jonesdevelopment
Copy link
Collaborator Author

In order to keep the changes only to the string encryption, I've copied the old encryption function and method generator to InvokeDynamicTransformer.

I have tested this with my Minecraft plugin, and it worked fine. More extensive testing is recommended.

@jonesdevelopment
Copy link
Collaborator Author

@SpartanB312 I need some help with replacing invoke dynamic bsm arguments (strings) with a local variable representation (or something else). This way, we can obfuscate invoke dynamic bsms as well as ldcs.

@SpartanB312
Copy link
Owner

Bsm args are actually const pool index, which can't be replaced by localvar or field.

@SpartanB312
Copy link
Owner

You can refer to GOTO obfuscator's string encrypt transformer. It has a method for handling invoice dynamics

@SpartanB312
Copy link
Owner

or replace makeConcatWithConstants with StringBuilder (This is what the compiler did before Java8)

@jonesdevelopment
Copy link
Collaborator Author

You can refer to GOTO obfuscator's string encrypt transformer. It has a method for handling invoice dynamics

I've implemented parts of their system into Grunt's code and it seems to be working. I'm still going to do some more testing.

@jonesdevelopment jonesdevelopment marked this pull request as ready for review December 29, 2024 18:59
@jonesdevelopment
Copy link
Collaborator Author

jonesdevelopment commented Dec 29, 2024

@SpartanB312 Let me know if this is production ready. I've tested it several times and it works fine.

I'm going to recode the number obfuscation later and make it use a pool too.

@jonesdevelopment
Copy link
Collaborator Author

@SpartanB312 Can you make sure this also works in your environment? I'd like to merge this PR.

@SpartanB312
Copy link
Owner

Let me test more samples later

@jonesdevelopment
Copy link
Collaborator Author

Let me test more samples later

Hi, any updates?

@SpartanB312
Copy link
Owner

SpartanB312 commented Jan 21, 2025

Let me test more samples later

Hi, any updates?

Yeah, but I am recently working on my final exam. Your updates will be merged into 2.5.0 major update

@xiguajerry
Copy link
Collaborator

I'd like to test it. If there's no problem it will be merged today.

@xiguajerry xiguajerry self-requested a review January 23, 2025 07:52
@xiguajerry xiguajerry merged commit 559d0bd into main Jan 23, 2025
@xiguajerry xiguajerry deleted the feat/recode-string-encryption branch January 23, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants