Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve StringEncryptTransformer #27

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d3df639
Improve StringEncryptTransformer
jonesdevelopment Dec 20, 2024
ba2b1be
Remove bytecode generator comment
jonesdevelopment Dec 20, 2024
bafd1ae
Merge remote-tracking branch 'origin/main' into feat/recode-string-en…
jonesdevelopment Dec 21, 2024
a797a46
Support interfaces in StringEncryptTransformer
jonesdevelopment Dec 21, 2024
e1c5392
Use better encryption/decryption method
jonesdevelopment Dec 21, 2024
a73db37
Remove debug message
jonesdevelopment Dec 21, 2024
f8e49d2
Make the en/decryption method heavier
jonesdevelopment Dec 21, 2024
a9e7e42
Merge remote-tracking branch 'origin/main' into feat/recode-string-en…
jonesdevelopment Dec 23, 2024
93545c7
Bump version from 2.4.2 to 2.4.3
jonesdevelopment Dec 23, 2024
612cb37
Merge remote-tracking branch 'origin/main' into feat/recode-string-en…
jonesdevelopment Dec 23, 2024
2ecf61c
Merge remote-tracking branch 'origin/main' into feat/recode-string-en…
jonesdevelopment Dec 25, 2024
21a7d27
[wip] Start working on InvokeDynamic string encryption
jonesdevelopment Dec 27, 2024
fd92221
[wip] Try pre-saving strings in localVars
jonesdevelopment Dec 28, 2024
1103d03
Fix StringEncryptTransformer causing VerifyError
jonesdevelopment Dec 28, 2024
c7b7815
[wip] InvokeDynamicInsnNode encryption
jonesdevelopment Dec 28, 2024
8c1f07f
Small micro-optimizations
jonesdevelopment Dec 28, 2024
588dd74
Recode StringEncryptTransformer
jonesdevelopment Dec 28, 2024
da6b037
Don't store decrypt method desc twice
jonesdevelopment Dec 28, 2024
dbc150d
[wip] StringBuilder appending for InDy
jonesdevelopment Dec 29, 2024
5d3fbfa
Implement Indy cst pool replacements
jonesdevelopment Dec 29, 2024
0baa5d4
Fix support for obfuscating a single method
jonesdevelopment Dec 29, 2024
2a9b068
Fix sleep deprivation
jonesdevelopment Dec 29, 2024
c69ba1b
Add more method/string shuffling
jonesdevelopment Dec 29, 2024
a35d975
Add interface support to indy boostrap
jonesdevelopment Dec 29, 2024
2b7518d
Optimize indy boostrap method generation
jonesdevelopment Dec 29, 2024
fe96b89
Optimize encryption method
jonesdevelopment Dec 29, 2024
0b33080
Don't limit encryption key "n"
jonesdevelopment Dec 29, 2024
51af9cc
Add the option to obfuscate the pool index
jonesdevelopment Dec 29, 2024
6104f50
Revert "Add the option to obfuscate the pool index"
jonesdevelopment Dec 29, 2024
2a57076
Harden encryption/decryption method
jonesdevelopment Dec 29, 2024
e915672
Fix interface support for StringEncryption
jonesdevelopment Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import org.objectweb.asm.tree.MethodNode
*/
@BuilderDSL
fun InsnListBuilder.INVOKESTATIC(owner: String, name: String, desc: String, isInterface: Boolean = false) {
require(!isInterface) {
"INVOKESTATIC isInterface should always be false"
}
+MethodInsnNode(Opcodes.INVOKESTATIC, owner, name, desc, false)
+MethodInsnNode(Opcodes.INVOKESTATIC, owner, name, desc, isInterface)
}

@BuilderDSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import net.spartanb312.grunt.process.transformers.encrypt.ConstPoolEncryptTransf
import net.spartanb312.grunt.process.transformers.encrypt.NumberEncryptTransformer
import net.spartanb312.grunt.process.transformers.encrypt.StringEncryptTransformer
import net.spartanb312.grunt.process.transformers.encrypt.number.NumberEncryptorClassic
import net.spartanb312.grunt.process.transformers.redirect.InvokeDynamicTransformer
import net.spartanb312.grunt.process.transformers.rename.ClassRenameTransformer
import net.spartanb312.grunt.utils.extensions.appendAnnotation
import net.spartanb312.grunt.utils.extensions.hasAnnotation
Expand Down Expand Up @@ -270,9 +271,9 @@ object RemoteLoaderTransformer : Transformer("RemoteLoader", Category.Miscellane
is ConstPoolEncryptTransformer.ConstRef.StringRef -> {
val key = Random.nextInt(0x8, 0x800)
val methodName = getRandomString(10)
val decryptMethod = StringEncryptTransformer.createDecryptMethod(methodName, key)
val decryptMethod = InvokeDynamicTransformer.createDecryptMethod(methodName, key)
remoteCompanion.methods.add(decryptMethod)
LDC(StringEncryptTransformer.encrypt(ref.value, key))
LDC(InvokeDynamicTransformer.encrypt(ref.value, key))
+MethodInsnNode(
Opcodes.INVOKESTATIC, remoteCompanion.name,
methodName, "(Ljava/lang/String;)Ljava/lang/String;",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import net.spartanb312.grunt.annotation.DISABLE_SCRAMBLE
import net.spartanb312.grunt.config.setting
import net.spartanb312.grunt.process.Transformer
import net.spartanb312.grunt.process.resource.ResourceCache
import net.spartanb312.grunt.process.transformers.encrypt.StringEncryptTransformer.createDecryptMethod
import net.spartanb312.grunt.process.transformers.encrypt.StringEncryptTransformer.encrypt
import net.spartanb312.grunt.process.transformers.encrypt.number.NumberEncryptorClassic
import net.spartanb312.grunt.process.transformers.misc.NativeCandidateTransformer
import net.spartanb312.grunt.process.transformers.redirect.InvokeDynamicTransformer
import net.spartanb312.grunt.process.transformers.rename.ReflectionSupportTransformer
import net.spartanb312.grunt.utils.count
import net.spartanb312.grunt.utils.extensions.appendAnnotation
Expand Down Expand Up @@ -129,9 +128,9 @@ object ConstPoolEncryptTransformer : Transformer("ConstPollEncrypt", Category.En
is ConstRef.StringRef -> {
val key = Random.nextInt(0x8, 0x800)
val methodName = getRandomString(10)
val decryptMethod = createDecryptMethod(methodName, key)
val decryptMethod = InvokeDynamicTransformer.createDecryptMethod(methodName, key)
clazz.methods.add(decryptMethod)
LDC(encrypt(it.value, key))
LDC(InvokeDynamicTransformer.encrypt(it.value, key))
INVOKESTATIC(clazz.name, methodName, "(Ljava/lang/String;)Ljava/lang/String;")
PUTSTATIC(clazz.name, it.field.name, it.field.desc)
}
Expand Down
Loading