mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support behinder shell generate
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user