toProcess = new LinkedList<>(firstTree.subClasses);
60 | while (!toProcess.isEmpty()) {
61 | String s = toProcess.poll();
62 | if (allChilds1.add(s)) {
63 | obf. assureLoaded(s);
64 | ClassTree tempTree = obf.getClassTree(s);
65 | toProcess.addAll(tempTree.subClasses);
66 | }
67 | }
68 | return allChilds1.contains(type2);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/vm/NativeHandler.java:
--------------------------------------------------------------------------------
1 | package vm;
2 |
3 | import java.io.File;
4 |
5 | public class NativeHandler {
6 |
7 | static {
8 | System.load(new File("native.dll").getAbsolutePath());
9 | }
10 |
11 | /**
12 | * Decrypts constant pool contents
13 | *
14 | * - Ints
15 | * - Longs
16 | *
17 | * @param klass The class whose constant pool is going to be decrypted
18 | */
19 | public static native void decryptConstantPool(Class> klass);
20 |
21 | /**
22 | * Replaces the bytecode
23 | *
24 | * @param klass The class which holds the method
25 | * @param method Method getting its bytecode replaced
26 | * @param bytecode New bytecode
27 | */
28 | public static native void transformMethod(Class> klass, String method, int[] bytecode);
29 |
30 | public static native int[] raw_bytes(Class> var0, String var1);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/com/cheatbreaker/obf/tests/DynamicInvokeTest.java:
--------------------------------------------------------------------------------
1 | package com.cheatbreaker.obf.tests;
2 |
3 | import com.cheatbreaker.obf.utils.samples.DynamicInvoke;
4 | import lombok.SneakyThrows;
5 | import org.junit.jupiter.api.Test;
6 |
7 | import java.lang.invoke.MethodHandle;
8 | import java.lang.invoke.MethodHandles;
9 | import java.lang.invoke.MethodType;
10 |
11 | public class DynamicInvokeTest {
12 |
13 | @SneakyThrows
14 | @Test
15 | void test() {
16 |
17 | MethodHandles.Lookup lookup = MethodHandles.publicLookup();
18 |
19 | DynamicInvoke.invoke(new Object[] { 10 },
20 | DynamicInvokeTest.class,
21 | lookup.findStatic(String.class, "valueOf", MethodType.methodType(String.class, Object.class)).bindTo("test2"),
22 | lookup.findStatic(String.class, "valueOf", MethodType.methodType(String.class, Object.class)).bindTo("(I)V"),
23 | lookup.findVirtual(MethodHandle.class, "invokeWithArguments", MethodType.methodType(Object.class, Object[].class)),
24 | lookup.findVirtual(MethodHandles.Lookup.class, "findStatic", MethodType.methodType(MethodHandle.class, Class.class, String.class, MethodType.class)));
25 | }
26 |
27 | public static void test2(int i) {
28 | System.out.println(i);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------