feat: support behinder shell generate

This commit is contained in:
ReaJason
2024-12-22 00:05:01 +08:00
parent 6b81791ff5
commit 6c23a15034
142 changed files with 2661 additions and 289 deletions
@@ -0,0 +1,38 @@
package com.reajason.javaweb.util;
import lombok.SneakyThrows;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* @author ReaJason
* @since 2024/11/23
*/
public class ClassUtils {
@SneakyThrows
public static Class<?> defineClass(byte[] bytes) {
return ClassDefiner.defineClass(bytes);
}
@SneakyThrows
public static Object newInstance(byte[] bytes) {
Class<?> clazz = defineClass(bytes);
return clazz.newInstance();
}
@SneakyThrows
public static Object getFieldValue(Object object, String fieldName) {
Field field = object.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(object);
}
@SneakyThrows
public static Object invokeMethod(Object object, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
Method method = object.getClass().getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
return method.invoke(object, parameters);
}
}