style: code format

This commit is contained in:
ReaJason
2024-12-11 01:35:41 +08:00
parent 59b0aeaaca
commit 40c036ab92
66 changed files with 2104 additions and 1876 deletions
@@ -19,20 +19,6 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_17;
* @since 2024/12/7
*/
class ByPassJavaModuleInterceptorTest {
static class TestClass {
static {
System.out.println("TestClass");
}
public TestClass() {
}
public String hello() {
return "hello";
}
}
@Test
@SneakyThrows
@EnabledOnJre(JAVA_17)
@@ -62,4 +48,18 @@ class ByPassJavaModuleInterceptorTest {
}
}
static class TestClass {
static {
System.out.println("TestClass");
}
public TestClass() {
}
public String hello() {
return "hello";
}
}
}
@@ -77,6 +77,22 @@ class LogRemoveVisitorWrapperTest {
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String", "length", "()I", false);
}
@Test
void testIntegration() throws Exception {
// Use ByteBuddy to create a new class with log statements removed
DynamicType.Unloaded<TestClass> make = new ByteBuddy()
.redefine(TestClass.class)
.name("com.reajason.javaweb.buddy.TestClass1")
.visit(new AsmVisitorWrapper.ForDeclaredMethods()
.method(ElementMatchers.any(), LogRemoveMethodVisitor.INSTANCE))
.make();
byte[] bytes = make.getBytes();
Files.write(Paths.get("xx.class"), bytes);
Class<?> modifiedClass = make.load(getClass().getClassLoader()).getLoaded();
Object instance = modifiedClass.getDeclaredConstructor().newInstance();
modifiedClass.getMethod("methodWithLogs").invoke(instance);
}
public static class TestClass {
public TestClass() {
}
@@ -93,20 +109,4 @@ class LogRemoveVisitorWrapperTest {
}
}
}
@Test
void testIntegration() throws Exception {
// Use ByteBuddy to create a new class with log statements removed
DynamicType.Unloaded<TestClass> make = new ByteBuddy()
.redefine(TestClass.class)
.name("com.reajason.javaweb.buddy.TestClass1")
.visit(new AsmVisitorWrapper.ForDeclaredMethods()
.method(ElementMatchers.any(), LogRemoveMethodVisitor.INSTANCE))
.make();
byte[] bytes = make.getBytes();
Files.write(Paths.get("xx.class"), bytes);
Class<?> modifiedClass = make.load(getClass().getClassLoader()).getLoaded();
Object instance = modifiedClass.getDeclaredConstructor().newInstance();
modifiedClass.getMethod("methodWithLogs").invoke(instance);
}
}
@@ -66,7 +66,7 @@ class GodzillaManagerTest {
}
@Test
void testRestorePayload(){
void testRestorePayload() {
String payload = "k2qs7l3%2F4ZZaGyyrfpBQGg0dXGM%2BFVFxzmCWLnyFEgoPSpSjHre4o1HBHTCFnNDX";
String key = "d8ea7326e6ec5916";
Map<String, String> map = GodzillaManager.restorePayload(key, payload);
@@ -1,7 +1,7 @@
package com.reajason.javaweb.memsell.tomcat.godzilla;
import com.reajason.javaweb.config.ShellConfig;
import com.reajason.javaweb.config.GodzillaConfig;
import com.reajason.javaweb.config.ShellConfig;
import com.reajason.javaweb.memsell.GodzillaGenerator;
import com.reajason.javaweb.util.ClassUtils;
import com.reajason.javaweb.util.CommonUtil;