Skip to content

Commit

Permalink
2.2.1 HWID Auth & Fixed ConstObf
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanB312 committed Sep 20, 2024
1 parent dfbf932 commit b999424
Show file tree
Hide file tree
Showing 27 changed files with 1,108 additions and 75 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ recommended to only enable computeMaxs and disable controlflow obfuscation when
* [X] [5]TrashClass
* [X] [5]ClonedClass
* [X] [5]SyntheticBridge
* [X] [5]HWIDAuthentication
* [X] [5]PostProcess

### ControlFlow
Expand Down
7 changes: 7 additions & 0 deletions grunt-annotation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
java
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.spartanb312.grunt.annotation;

public interface DisableControlflow {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.spartanb312.grunt.annotation;

public interface DisableInvokeDynamic {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.spartanb312.grunt.annotation;

public interface DisableScramble {
}
7 changes: 7 additions & 0 deletions grunt-hwid/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
java
}

repositories {
mavenCentral()
}
63 changes: 63 additions & 0 deletions grunt-hwid/src/main/java/net/spartanb312/grunt/hwid/HWID.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.spartanb312.grunt.hwid;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class HWID {

private static final String KEY = "1186118611861186";

public static void main(String[] args) {
new Frame(KEY).setVisible(false);
}

public static class Frame extends JFrame {
public Frame(String key) {
setTitle("HWID Getter");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
String hardwareID = "Unknown HWID";
try {
String raw = System.getenv("PROCESS_IDENTIFIER")
+ System.getenv("PROCESSOR_LEVEL")
+ System.getenv("PROCESSOR_REVISION")
+ System.getenv("PROCESSOR_ARCHITECTURE")
+ System.getenv("PROCESSOR_ARCHITEW6432")
+ System.getenv("NUMBER_OF_PROCESSORS")
+ System.getenv("COMPUTERNAME");
String aes = "AES";
Cipher cipher = Cipher.getInstance(aes);
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), aes);
cipher.init(1, secretKeySpec);
byte[] result = cipher.doFinal(raw.getBytes(StandardCharsets.UTF_8));
hardwareID = new String(Base64.getEncoder().encode(result))
.replace("/", "s")
.replace("=", "e")
.replace("+", "p");
} catch (Exception ignored) {
}
copyToClipboard(hardwareID);
String message = "Your HWID: " + hardwareID + "\n(Copied to clipboard)";
JOptionPane.showMessageDialog(
this,
message,
"HWID Getter",
JOptionPane.PLAIN_MESSAGE,
UIManager.getIcon("OptionPane.informationIcon")
);
}

public static void copyToClipboard(String s) {
StringSelection selection = new StringSelection(s);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
}

}
2 changes: 2 additions & 0 deletions grunt-main/CountLines.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Java -jar Counter.jar .java .kt .kts .vsh .fsh .vert .frag .glsl
pause
Binary file added grunt-main/Counter.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions grunt-main/src/main/kotlin/net/spartanb312/grunt/Grunt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import kotlin.system.measureTimeMillis
* Gruntpocalypse
* A java bytecode obfuscator
*/
const val VERSION = "2.2.0"
const val SUBTITLE = "build 240916"
const val VERSION = "2.2.1"
const val SUBTITLE = "build 240920"
const val GITHUB = "https://github.com/SpartanB312/Grunt"

fun main(args: Array<String>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package net.spartanb312.grunt.annotation

val DONT_SCRAMBLE = "Lnet/spartanb312/grunt/annotation/DontScramble;"
val DISABLE_SCRAMBLE = "Lnet/spartanb312/grunt/annotation/DisableScramble;"
val DISABLE_CONTROLFLOW = "Lnet/spartanb312/grunt/annotation/DisableControlflow;"
val DISABLE_INVOKEDYNAMIC = "Lnet/spartanb312/grunt/annotation/DisableInvokeDynamic;"

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import net.spartanb312.grunt.process.transformers.rename.*
/**
* Execution order
* 000 Optimization
* 010 Trash classes
* 010 Miscellaneous 1
* 020 Controlflow 1
* 030 Encryption 1
* 040 Controlflow 2
* 050 Encryption 2
* 060 Redirect
* 070 Miscellaneous 1
* 070 Miscellaneous 2
* 080 Renaming
* 090 Minecraft
* 100 InvokeDynamic & Miscellaneous 2
* 100 InvokeDynamic & Miscellaneous 3
* MAX PostProcess
*/
object Transformers : Collection<Transformer> by mutableListOf(
Expand All @@ -32,6 +32,7 @@ object Transformers : Collection<Transformer> by mutableListOf(
DeadCodeRemoveTransformer order 4,
ClonedClassTransformer order 10,
TrashClassTransformer order 11,
HWIDAuthenticatorTransformer order 12,
//ControlflowTransformer order 20,
StringEncryptTransformer order 30,
NumberEncryptTransformer order 31,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package net.spartanb312.grunt.process.transformers
import com.google.gson.Gson
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import net.spartanb312.grunt.annotation.DONT_SCRAMBLE
import net.spartanb312.grunt.annotation.DISABLE_CONTROLFLOW
import net.spartanb312.grunt.annotation.DISABLE_INVOKEDYNAMIC
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.utils.builder.insnList
import net.spartanb312.grunt.utils.dot
import net.spartanb312.grunt.utils.extensions.removeAnnotation
import net.spartanb312.grunt.utils.logging.Logger
Expand Down Expand Up @@ -37,7 +38,11 @@ object PostProcessTransformer : Transformer("PostProcess", Category.Miscellaneou

fun ResourceCache.finalize() {
// Remove annotation
val annotationRemoval = arrayOf(DONT_SCRAMBLE)
val annotationRemoval = arrayOf(
DISABLE_CONTROLFLOW,
DISABLE_INVOKEDYNAMIC,
DISABLE_SCRAMBLE
)
nonExcluded.forEach { clazz ->
clazz.methods.forEach { method ->
annotationRemoval.forEach { method.removeAnnotation(it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package net.spartanb312.grunt.process.transformers.encrypt

import net.spartanb312.grunt.annotation.DONT_SCRAMBLE
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.redirect.FieldScrambleTransformer
import net.spartanb312.grunt.utils.builder.*
import net.spartanb312.grunt.utils.extensions.appendAnnotation
import net.spartanb312.grunt.utils.extensions.isAbstract
Expand Down Expand Up @@ -50,7 +49,7 @@ object ConstPoolEncryptTransformer : Transformer("ConstPollEncrypt", Category.En
"java/lang/Object",
null
)
if (dontScramble) appendAnnotation(DONT_SCRAMBLE)
if (dontScramble) appendAnnotation(DISABLE_SCRAMBLE)
}
] = mutableListOf()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object StringEncryptTransformer : Transformer("StringEncrypt", Category.Encrypti
method.instructions.insert(
insnNode,
MethodInsnNode(
Opcodes.INVOKESTATIC, method.name,
Opcodes.INVOKESTATIC,
owner.name,
decryptMethodName, "(Ljava/lang/String;)Ljava/lang/String;",
false
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.spartanb312.grunt.process.transformers.flow

import net.spartanb312.grunt.annotation.DISABLE_CONTROLFLOW
import net.spartanb312.grunt.config.setting
import net.spartanb312.grunt.process.MethodProcessor
import net.spartanb312.grunt.process.Transformer
Expand All @@ -11,6 +12,7 @@ import net.spartanb312.grunt.process.transformers.flow.process.ReplaceGoto
import net.spartanb312.grunt.process.transformers.flow.process.ReplaceIf
import net.spartanb312.grunt.utils.builder.insnList
import net.spartanb312.grunt.utils.count
import net.spartanb312.grunt.utils.extensions.hasAnnotation
import net.spartanb312.grunt.utils.logging.Logger
import net.spartanb312.grunt.utils.notInList
import org.objectweb.asm.Opcodes
Expand Down Expand Up @@ -49,10 +51,15 @@ object ControlflowTransformer : Transformer("Controlflow", Category.Controlflow)
hierarchy.build(true)
val count = count {
nonExcluded.asSequence()
.filter { it.name.notInList(exclusion) && !it.missingReference(hierarchy) }
.forEach { classNode ->
.filter {
it.name.notInList(exclusion)
&& !it.missingReference(hierarchy)
&& !it.hasAnnotation(DISABLE_CONTROLFLOW)
}.forEach { classNode ->
classNode.methods.forEach { methodNode ->
add(processMethodNode(methodNode))
if (!methodNode.hasAnnotation(DISABLE_CONTROLFLOW)) {
add(processMethodNode(methodNode))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package net.spartanb312.grunt.process.transformers.misc
import net.spartanb312.grunt.config.setting
import net.spartanb312.grunt.process.Transformer
import net.spartanb312.grunt.process.resource.ResourceCache
import net.spartanb312.grunt.utils.count
import net.spartanb312.grunt.utils.logging.Logger
import net.spartanb312.grunt.utils.massiveBlankString
import net.spartanb312.grunt.utils.massiveString
import net.spartanb312.grunt.utils.notInList
Expand All @@ -22,17 +24,22 @@ object CrasherTransformer : Transformer("Crasher", Category.Miscellaneous) {
} else this

override fun ResourceCache.transform() {
nonExcluded.asSequence()
.filter { it.name.notInList(exclusion) }
.forEach { classNode ->
classNode.methods.forEach { methodNode ->
methodNode.signature = methodNode.signature.bigBrainSignature
Logger.info(" - Adding crashers on classes...")
val count = count {
nonExcluded.asSequence()
.filter { it.name.notInList(exclusion) }
.forEach { classNode ->
classNode.methods.forEach { methodNode ->
methodNode.signature = methodNode.signature.bigBrainSignature
}
classNode.fields.forEach { fieldNode ->
fieldNode.signature = fieldNode.signature.bigBrainSignature
}
classNode.signature = classNode.signature.bigBrainSignature
add()
}
classNode.fields.forEach { fieldNode ->
fieldNode.signature = fieldNode.signature.bigBrainSignature
}
classNode.signature = classNode.signature.bigBrainSignature
}
}.get()
Logger.info(" Added $count crashers")
}

}
Loading

0 comments on commit b999424

Please sign in to comment.