This commit is contained in:
pen4uin
2024-06-01 12:20:17 +08:00
parent 1e4291e965
commit b6e34b31e2
99 changed files with 11806 additions and 128 deletions
+98
View File
@@ -0,0 +1,98 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>java-memshell-generator</artifactId>
<groupId>jmg</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jmg-gui</artifactId>
<dependencies>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-core</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.gv7.woodpecker</groupId>
<artifactId>jexpr-encoder-utils</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>forms_rt</artifactId>
<version>7.0.3</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-behinder</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-antsword</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-godzilla</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-suo5</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-neoregeorg</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jmg</groupId>
<artifactId>jmg-custom</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>jmg.gui.jMGApp</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,389 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="jmg.gui.form.jMGForm">
<grid id="27dc6" binding="jMGPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="863" height="665"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="3afd3" binding="TopPanel" layout-manager="GridLayoutManager" row-count="1" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c4be0" class="javax.swing.JLabel" binding="toolLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="tool.text"/>
</properties>
</component>
<component id="b6735" class="javax.swing.JLabel" binding="formatLabel">
<constraints>
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="format.text"/>
</properties>
</component>
<component id="55e33" class="javax.swing.JLabel" binding="serverLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="server.text"/>
</properties>
</component>
<component id="50832" class="javax.swing.JLabel" binding="shellLabel">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="shell.text"/>
</properties>
</component>
<component id="9f7e2" class="javax.swing.JComboBox" binding="toolBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="139" height="-1"/>
</grid>
</constraints>
<properties>
<model>
<item value="Behinder"/>
<item value="Godzilla"/>
<item value="AntSword"/>
<item value="Suo5"/>
<item value="NeoreGeorg"/>
<item value="Custom"/>
</model>
</properties>
</component>
<component id="4aed2" class="javax.swing.JComboBox" binding="serverBox">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="139" height="-1"/>
</grid>
</constraints>
<properties>
<model>
<item value="Tomcat"/>
<item value="SpringMVC"/>
<item value="Weblogic"/>
<item value="Websphere"/>
<item value="Resin"/>
<item value="Undertow"/>
<item value="Jetty"/>
<item value="SpringWebFlux"/>
</model>
</properties>
</component>
<component id="427be" class="javax.swing.JComboBox" binding="shellBox">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<model>
<item value="Listener"/>
<item value="Filter"/>
<item value="Interceptor"/>
<item value="WFHandlerMethod"/>
</model>
</properties>
</component>
<component id="5feb" class="javax.swing.JComboBox" binding="formatBox">
<constraints>
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<model>
<item value="BASE64"/>
<item value="BIGINTEGER"/>
<item value="BCEL"/>
<item value="CLASS"/>
<item value="JAR"/>
<item value="JS"/>
<item value="JSP"/>
</model>
</properties>
</component>
</children>
</grid>
<scrollpane id="df5d3" binding="textScrollPane">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="360"/>
<preferred-size width="36" height="207"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="2f007" class="javax.swing.JTextPane" binding="textPane">
<constraints/>
<properties>
<text value=""/>
</properties>
</component>
</children>
</scrollpane>
<grid id="3932" binding="MiddlePanel" layout-manager="GridLayoutManager" row-count="4" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d00d4" class="javax.swing.JLabel" binding="keyLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="key.text"/>
</properties>
</component>
<component id="686ad" class="javax.swing.JLabel" binding="passLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="34" height="16"/>
</grid>
</constraints>
<properties>
<text resource-bundle="messages" key="pass.text"/>
</properties>
</component>
<component id="f1c80" class="javax.swing.JLabel" binding="headerValueLabel">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="headerValue.text"/>
</properties>
</component>
<component id="ad3ef" class="javax.swing.JTextField" binding="uriText">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="/*"/>
<toolTipText value="可选,默认为 /*"/>
</properties>
</component>
<component id="feb40" class="javax.swing.JTextField" binding="headerValueText">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
<component id="56266" class="javax.swing.JTextField" binding="keyText">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
<component id="82af3" class="javax.swing.JLabel" binding="headerNameLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="headerName.text"/>
</properties>
</component>
<component id="5ae4e" class="javax.swing.JLabel" binding="uriLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="uri.text"/>
</properties>
</component>
<component id="e7770" class="javax.swing.JTextField" binding="headerNameText">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
<component id="e2d0f" class="javax.swing.JTextField" binding="passText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
<component id="e461d" class="javax.swing.JLabel" binding="shellClsNameLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="shellClsName.text"/>
</properties>
</component>
<component id="cfea8" class="javax.swing.JLabel" binding="injectorClsNameLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="injectorClsName.text"/>
</properties>
</component>
<component id="85281" class="javax.swing.JTextField" binding="injectorClsNameText">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
<component id="f7207" class="javax.swing.JTextField" binding="shellClsNameText">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<toolTipText value="可选,默认随机生成"/>
</properties>
</component>
</children>
</grid>
<component id="a889a" class="javax.swing.JSeparator" binding="TopSep">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="9582c" class="javax.swing.JSeparator" binding="MiddleSep">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<grid id="ff8e2" binding="BottomPanel" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="a29cd" class="javax.swing.JCheckBox" binding="enableGadget">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="gadget.text"/>
<toolTipText value="根据漏洞类型自动完成对类文件的封装,如继承类、实现接口、添加注解等"/>
</properties>
</component>
<component id="3c3cb" class="javax.swing.JComboBox" binding="gadgetTypeBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="JDK_AbstractTranslet"/>
<item value="SnakeYaml"/>
<item value="XALAN_AbstractTranslet"/>
<item value="FastjsonGroovy"/>
</model>
</properties>
</component>
<component id="dfe4d" class="javax.swing.JCheckBox" binding="enableExpr">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="expr.text"/>
<toolTipText value="根据语句类型自动生成相应内存马注入的表达式语句"/>
</properties>
</component>
<component id="aa87f" class="javax.swing.JComboBox" binding="exprBox">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="EL"/>
<item value="SpEL"/>
<item value="OGNL"/>
<item value="FreeMarker"/>
<item value="Velocity"/>
<item value="ScriptEngineManager(JS)"/>
</model>
</properties>
</component>
<component id="3a0da" class="javax.swing.JButton" binding="generateButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages" key="generate.text"/>
</properties>
</component>
</children>
</grid>
<grid id="61400" binding="TipPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="28a9f">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="da658" class="javax.swing.JLabel" binding="authorLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="请勿用于非法用途"/>
</properties>
</component>
<component id="c8061" class="javax.swing.JLabel" binding="noticeLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="by pen4uin"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
@@ -0,0 +1,616 @@
package jmg.gui.form;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import jmg.core.config.AbstractConfig;
import jmg.core.config.Constants;
import jmg.core.generator.InjectorGenerator;
import jmg.core.util.ClassNameUtil;
import jmg.core.util.CommonUtil;
import jmg.core.util.RandomHttpHeaderUtil;
import jmg.gui.util.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
public class jMGForm {
private static JFrame frame;
private JComboBox toolBox;
private JComboBox serverBox;
private JComboBox shellBox;
private JComboBox formatBox;
private JTextField uriText;
private JTextField headerValueText;
private JTextField keyText;
private JTextField headerNameText;
private JTextField passText;
private JTextField injectorClsNameText;
private JTextField shellClsNameText;
private JCheckBox enableGadget;
private JComboBox gadgetTypeBox;
private JCheckBox enableExpr;
private JComboBox exprBox;
private JButton generateButton;
private JPanel jMGPanel;
private JPanel TopPanel;
private JLabel toolLabel;
private JLabel formatLabel;
private JLabel serverLabel;
private JLabel shellLabel;
private JScrollPane textScrollPane;
private JPanel MiddlePanel;
private JLabel keyLabel;
private JLabel passLabel;
private JLabel headerValueLabel;
private JLabel headerNameLabel;
private JLabel uriLabel;
private JLabel shellClsNameLabel;
private JLabel injectorClsNameLabel;
private JSeparator TopSep;
private JSeparator MiddleSep;
private JLabel authorLabel;
private JLabel noticeLabel;
private JPanel BottomPanel;
private JPanel TipPanel;
private JTextPane textPane;
private AbstractConfig config;
public static void start() {
Locale.setDefault(Locale.CHINA);
frame = new JFrame(Constants.JMG_NAME + " " + Constants.JMG_VERSION);
// 将窗口居中显示,解决 windows 下靠左的问题
frame.setLocationRelativeTo(null);
frame.setResizable(true);
jMGForm jmgForm = new jMGForm();
JPanel contentPanel = jmgForm.jMGPanel;
contentPanel.setBorder(new EmptyBorder(8, 10, 8, 10));
frame.setContentPane(contentPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setJMenuBar(MenuUtil.createMenuBar(frame));
frame.pack();
frame.setVisible(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int centerX = screenSize.width / 2;
int centerY = screenSize.height / 2;
Dimension jfSize = frame.getSize();
int halfwidth = jfSize.width / 2;
int halfHeight = jfSize.height / 2;
frame.setLocation(centerX - halfwidth, centerY - halfHeight);
}
private String serverType = Constants.SERVER_TOMCAT;
private String shellType = Constants.SHELL_LISTENER;
private String gadgetType = Constants.GADGET_JDK_TRANSLET;
private String toolType = Constants.TOOL_BEHINDER;
private String formatType = Constants.FORMAT_BASE64;
public jMGForm() {
config = new AbstractConfig();
String[] servletApiShellBox = {Constants.SHELL_LISTENER, Constants.SHELL_FILTER};
String[] servletApiServerBox = {Constants.SERVER_TOMCAT, Constants.SERVER_RESIN, Constants.SERVER_WEBLOGIC, Constants.SERVER_WEBSPHERE, Constants.SERVER_JETTY, Constants.SERVER_UNDERTOW, Constants.SERVER_GLASSFISH, Constants.SERVER_JBOSS};
String[] interceptorServerBox = {Constants.SERVER_SPRING_MVC};
String[] interceptorShellBox = {Constants.SHELL_INTERCEPTOR};
String[] handlerMethodServerBox = {Constants.SERVER_SPRING_WEBFLUX};
String[] handlerMethodShellBox = {Constants.SHELL_WF_HANDLERMETHOD};
String[] behinderServerBox = CommonUtil.concatenateArrays(servletApiServerBox, interceptorServerBox);
String[] behinderShellBox = CommonUtil.concatenateArrays(servletApiShellBox, interceptorShellBox);
String[] godzillaServerBox = CommonUtil.concatenateArrays(behinderServerBox, handlerMethodServerBox);
String[] godzillaShellBox = CommonUtil.concatenateArrays(behinderShellBox, handlerMethodShellBox);
String[] formatBoxForOther = new String[]{Constants.FORMAT_BASE64, Constants.FORMAT_BIGINTEGER, Constants.FORMAT_BCEL, Constants.FORMAT_CLASS, Constants.FORMAT_JAR, Constants.FORMAT_JS, Constants.FORMAT_JSP};
String[] formatBoxForTomcat = new String[]{Constants.FORMAT_BASE64, Constants.FORMAT_BIGINTEGER, Constants.FORMAT_BCEL, Constants.FORMAT_CLASS, Constants.FORMAT_JAR, Constants.FORMAT_JAR_AGENT, Constants.FORMAT_JS, Constants.FORMAT_JSP};
String[] exprEncoderBoxItems = new String[]{Constants.EXPR_EL, Constants.EXPR_SPEL, Constants.EXPR_OGNL, Constants.EXPR_FREEMARKER, Constants.EXPR_VELOCITY, Constants.EXPR_JS};
String[] gadgetTypeBoxItems = new String[]{Constants.GADGET_JDK_TRANSLET, Constants.GADGET_SNAKEYAML, Constants.GADGET_FJ_GROOVY, Constants.GADGET_XALAN_TRANSLET};
formatBox.setModel(new DefaultComboBoxModel<>(formatBoxForTomcat));
serverBox.setModel(new DefaultComboBoxModel(behinderServerBox));
shellBox.setModel(new DefaultComboBoxModel(servletApiShellBox));
toolBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
toolType = (String) toolBox.getSelectedItem();
if (toolType.equals(Constants.TOOL_GODZILLA)) {
serverBox.setModel(new DefaultComboBoxModel(godzillaServerBox));
shellBox.setModel(new DefaultComboBoxModel(godzillaShellBox));
} else if (toolType.equals(Constants.TOOL_ANTSWORD)) {
shellBox.setModel(new DefaultComboBoxModel(servletApiShellBox));
serverBox.setModel(new DefaultComboBoxModel(servletApiServerBox));
} else if (toolType.equals(Constants.TOOL_CUSTOM)) {
JFileChooser fileChooser = new JFileChooser();
FileFilter classFileFilter = new FileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory() || file.getName().toLowerCase().endsWith(".class");
}
@Override
public String getDescription() {
return "Java Class Files (*.class)";
}
};
fileChooser.setFileFilter(classFileFilter);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showSaveDialog(jMGPanel);
if (result == JFileChooser.APPROVE_OPTION) {
String selectedPath = fileChooser.getSelectedFile().getPath();
config.setClassFilePath(selectedPath);
}
} else {
serverBox.setModel(new DefaultComboBoxModel(behinderServerBox));
shellBox.setModel(new DefaultComboBoxModel(behinderShellBox));
}
}
});
serverBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
serverType = (String) serverBox.getSelectedItem();
if (serverType.equals(Constants.SERVER_SPRING_MVC)) {
shellBox.setModel(new DefaultComboBoxModel<>(interceptorShellBox));
shellType = (String) shellBox.getSelectedItem();
} else if (serverType.equals(Constants.SERVER_SPRING_WEBFLUX)) {
shellBox.setModel(new DefaultComboBoxModel<>(handlerMethodShellBox));
shellType = (String) shellBox.getSelectedItem();
} else {
shellBox.setModel(new DefaultComboBoxModel<>(servletApiShellBox));
shellType = (String) shellBox.getSelectedItem();
}
if (!serverType.equals(Constants.SERVER_TOMCAT) && !serverType.equals(Constants.SERVER_SPRING_MVC)) {
formatBox.setModel(new DefaultComboBoxModel<>(formatBoxForOther));
} else {
formatBox.setModel(new DefaultComboBoxModel<>(formatBoxForTomcat));
}
}
});
shellBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
shellType = (String) shellBox.getSelectedItem();
}
});
formatBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
formatType = (String) formatBox.getSelectedItem();
assert formatType != null;
if (formatType.equalsIgnoreCase(Constants.FORMAT_CLASS) || formatType.equalsIgnoreCase(Constants.FORMAT_JSP) || formatType.equalsIgnoreCase(Constants.FORMAT_JAR) || formatType.equalsIgnoreCase(Constants.FORMAT_JAR_AGENT)) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = fileChooser.showSaveDialog(jMGPanel);
if (result == JFileChooser.APPROVE_OPTION) {
String selectedPath = fileChooser.getSelectedFile().getPath();
config.setSavePath(selectedPath);
}
}
}
});
// 可选参数设置
passText.getDocument().putProperty("owner", passText);
passText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(passText, config::setPass));
keyText.getDocument().putProperty("owner", keyText);
keyText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(keyText, config::setKey));
shellClsNameText.getDocument().putProperty("owner", shellClsNameText);
shellClsNameText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(shellClsNameText, config::setShellClassName));
injectorClsNameText.getDocument().putProperty("owner", injectorClsNameText);
injectorClsNameText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(injectorClsNameText, config::setInjectorClassName));
uriText.getDocument().putProperty("owner", uriText);
uriText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(uriText, config::setUrlPattern));
headerNameText.getDocument().putProperty("owner", headerNameText);
headerNameText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(headerNameText, config::setHeaderName));
headerValueText.getDocument().putProperty("owner", headerValueText);
headerValueText.getDocument().addDocumentListener(ComponentUtil.createDocumentListener(headerValueText, config::setHeaderValue));
exprBox.setEnabled(false);
enableExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (enableExpr.isSelected()) {
config.setExprEncoder(Constants.EXPR_EL);
exprBox.setEnabled(enableExpr.isSelected());
} else {
exprBox.setEnabled(enableExpr.isSelected());
config.setExprEncoder(null);
exprBox.setModel(new DefaultComboBoxModel(exprEncoderBoxItems));
}
}
});
exprBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED && exprBox.isEnabled()) {
config.setExprEncoder((String) exprBox.getSelectedItem());
} else {
config.setExprEncoder(null);
}
}
});
gadgetTypeBox.setEnabled(false);
enableGadget.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (enableGadget.isSelected()) {
config.setGadgetType(gadgetType);
gadgetTypeBox.setEnabled(enableGadget.isSelected());
} else {
gadgetTypeBox.setEnabled(enableGadget.isSelected());
config.setGadgetType(null);
gadgetTypeBox.setModel(new DefaultComboBoxModel(gadgetTypeBoxItems));
}
}
});
gadgetTypeBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED && gadgetTypeBox.isEnabled()) {
config.setGadgetType((String) gadgetTypeBox.getSelectedItem());
} else {
config.setGadgetType(null);
}
}
});
generateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TextPaneUtil.initTextPane(textPane);
TextPaneUtil.startPrintln(toolType + " " + serverType + " " + shellType + " " + formatType + "\n");
try {
initConfig(config);
new ShellGeneratorUtil().makeShell(config);
new InjectorGenerator().makeInjector(config);
ResultUtil.resultOutput(config);
ComponentUtil.restoreScrollPosition(textScrollPane);
resetConfig(config);
} catch (Throwable ex) {
resetConfig(config);
TextPaneUtil.errorPrintln(CommonUtil.getThrowableStackTrace(ex));
}
}
});
textPane.setComponentPopupMenu(MenuUtil.createPopupMenu(frame, textPane));
}
public void initConfig(AbstractConfig config) {
config.setToolType(toolType);
config.setServerType(serverType);
config.setShellType(shellType);
config.setOutputFormat(formatType);
ComponentUtil.setTextIfNotEmpty(passText, config::setPass);
ComponentUtil.setTextIfNotEmpty(keyText, config::setKey);
ComponentUtil.setTextIfNotEmpty(shellClsNameText, config::setShellClassName);
ComponentUtil.setTextIfNotEmpty(injectorClsNameText, config::setInjectorClassName);
ComponentUtil.setTextIfNotEmpty(uriText, config::setUrlPattern);
ComponentUtil.setTextIfNotEmpty(headerNameText, config::setHeaderName);
ComponentUtil.setTextIfNotEmpty(headerValueText, config::setHeaderValue);
if (config.getShellClassName() == null)
config.setShellClassName(ClassNameUtil.getRandomShellClassName(config.getShellType()));
if (config.getInjectorClassName() == null)
config.setInjectorClassName(ClassNameUtil.getRandomInjectorClassName());
Map.Entry<String, String> header = RandomHttpHeaderUtil.generateHeader();
if (config.getHeaderName() == null) config.setHeaderName(header.getKey());
if (config.getHeaderValue() == null) config.setHeaderValue(header.getValue());
if (config.getUrlPattern() == null || config.getUrlPattern().equals("/*") || config.getUrlPattern().equals("/")) {
if (config.getShellType().equals(Constants.SHELL_WF_HANDLERMETHOD)) {
config.setUrlPattern("/" + CommonUtil.getRandomString(6).toLowerCase());
} else {
config.setUrlPattern("/*");
}
}
if (config.getOutputFormat().contains(Constants.FORMAT_BCEL))
config.setLoaderClassName(ClassNameUtil.getRandomLoaderClassName());
config.setInjectorSimpleClassName(CommonUtil.getSimpleName(config.getInjectorClassName()));
}
public void resetConfig(AbstractConfig config) {
config.setPass(null);
config.setKey(null);
config.setShellClassName(null);
config.setInjectorClassName(null);
config.setHeaderName(null);
config.setHeaderValue(null);
config.setUrlPattern(null);
config.setInjectorSimpleClassName(null);
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
jMGPanel = new JPanel();
jMGPanel.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1));
TopPanel = new JPanel();
TopPanel.setLayout(new GridLayoutManager(1, 8, new Insets(0, 0, 0, 0), -1, -1));
jMGPanel.add(TopPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
toolLabel = new JLabel();
this.$$$loadLabelText$$$(toolLabel, this.$$$getMessageFromBundle$$$("messages", "tool.text"));
TopPanel.add(toolLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
formatLabel = new JLabel();
this.$$$loadLabelText$$$(formatLabel, this.$$$getMessageFromBundle$$$("messages", "format.text"));
TopPanel.add(formatLabel, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
serverLabel = new JLabel();
this.$$$loadLabelText$$$(serverLabel, this.$$$getMessageFromBundle$$$("messages", "server.text"));
TopPanel.add(serverLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
shellLabel = new JLabel();
this.$$$loadLabelText$$$(shellLabel, this.$$$getMessageFromBundle$$$("messages", "shell.text"));
TopPanel.add(shellLabel, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
toolBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
defaultComboBoxModel1.addElement("Behinder");
defaultComboBoxModel1.addElement("Godzilla");
defaultComboBoxModel1.addElement("AntSword");
defaultComboBoxModel1.addElement("Suo5");
defaultComboBoxModel1.addElement("NeoreGeorg");
defaultComboBoxModel1.addElement("Custom");
toolBox.setModel(defaultComboBoxModel1);
TopPanel.add(toolBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(139, -1), null, 0, false));
serverBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel();
defaultComboBoxModel2.addElement("Tomcat");
defaultComboBoxModel2.addElement("SpringMVC");
defaultComboBoxModel2.addElement("Weblogic");
defaultComboBoxModel2.addElement("Websphere");
defaultComboBoxModel2.addElement("Resin");
defaultComboBoxModel2.addElement("Undertow");
defaultComboBoxModel2.addElement("Jetty");
defaultComboBoxModel2.addElement("SpringWebFlux");
serverBox.setModel(defaultComboBoxModel2);
TopPanel.add(serverBox, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(139, -1), null, 0, false));
shellBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel3 = new DefaultComboBoxModel();
defaultComboBoxModel3.addElement("Listener");
defaultComboBoxModel3.addElement("Filter");
defaultComboBoxModel3.addElement("Interceptor");
defaultComboBoxModel3.addElement("WFHandlerMethod");
shellBox.setModel(defaultComboBoxModel3);
TopPanel.add(shellBox, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
formatBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel4 = new DefaultComboBoxModel();
defaultComboBoxModel4.addElement("BASE64");
defaultComboBoxModel4.addElement("BIGINTEGER");
defaultComboBoxModel4.addElement("BCEL");
defaultComboBoxModel4.addElement("CLASS");
defaultComboBoxModel4.addElement("JAR");
defaultComboBoxModel4.addElement("JS");
defaultComboBoxModel4.addElement("JSP");
formatBox.setModel(defaultComboBoxModel4);
TopPanel.add(formatBox, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
textScrollPane = new JScrollPane();
jMGPanel.add(textScrollPane, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(-1, 360), new Dimension(36, 207), null, 0, false));
textPane = new JTextPane();
textPane.setText("");
textScrollPane.setViewportView(textPane);
MiddlePanel = new JPanel();
MiddlePanel.setLayout(new GridLayoutManager(4, 4, new Insets(0, 0, 0, 0), -1, -1));
jMGPanel.add(MiddlePanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
keyLabel = new JLabel();
this.$$$loadLabelText$$$(keyLabel, this.$$$getMessageFromBundle$$$("messages", "key.text"));
MiddlePanel.add(keyLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
passLabel = new JLabel();
this.$$$loadLabelText$$$(passLabel, this.$$$getMessageFromBundle$$$("messages", "pass.text"));
MiddlePanel.add(passLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(34, 16), null, 0, false));
headerValueLabel = new JLabel();
this.$$$loadLabelText$$$(headerValueLabel, this.$$$getMessageFromBundle$$$("messages", "headerValue.text"));
MiddlePanel.add(headerValueLabel, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
uriText = new JTextField();
uriText.setText("/*");
uriText.setToolTipText("可选,默认为 /*");
MiddlePanel.add(uriText, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
headerValueText = new JTextField();
headerValueText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(headerValueText, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
keyText = new JTextField();
keyText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(keyText, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
headerNameLabel = new JLabel();
this.$$$loadLabelText$$$(headerNameLabel, this.$$$getMessageFromBundle$$$("messages", "headerName.text"));
MiddlePanel.add(headerNameLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
uriLabel = new JLabel();
this.$$$loadLabelText$$$(uriLabel, this.$$$getMessageFromBundle$$$("messages", "uri.text"));
MiddlePanel.add(uriLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
headerNameText = new JTextField();
headerNameText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(headerNameText, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
passText = new JTextField();
passText.setText("");
passText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(passText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
shellClsNameLabel = new JLabel();
this.$$$loadLabelText$$$(shellClsNameLabel, this.$$$getMessageFromBundle$$$("messages", "shellClsName.text"));
MiddlePanel.add(shellClsNameLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
injectorClsNameLabel = new JLabel();
this.$$$loadLabelText$$$(injectorClsNameLabel, this.$$$getMessageFromBundle$$$("messages", "injectorClsName.text"));
MiddlePanel.add(injectorClsNameLabel, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
injectorClsNameText = new JTextField();
injectorClsNameText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(injectorClsNameText, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
shellClsNameText = new JTextField();
shellClsNameText.setToolTipText("可选,默认随机生成");
MiddlePanel.add(shellClsNameText, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
TopSep = new JSeparator();
jMGPanel.add(TopSep, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
MiddleSep = new JSeparator();
jMGPanel.add(MiddleSep, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
BottomPanel = new JPanel();
BottomPanel.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
jMGPanel.add(BottomPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
enableGadget = new JCheckBox();
this.$$$loadButtonText$$$(enableGadget, this.$$$getMessageFromBundle$$$("messages", "gadget.text"));
enableGadget.setToolTipText("根据漏洞类型自动完成对类文件的封装,如继承类、实现接口、添加注解等");
BottomPanel.add(enableGadget, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
gadgetTypeBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel5 = new DefaultComboBoxModel();
defaultComboBoxModel5.addElement("JDK_AbstractTranslet");
defaultComboBoxModel5.addElement("SnakeYaml");
defaultComboBoxModel5.addElement("XALAN_AbstractTranslet");
defaultComboBoxModel5.addElement("FastjsonGroovy");
gadgetTypeBox.setModel(defaultComboBoxModel5);
BottomPanel.add(gadgetTypeBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
enableExpr = new JCheckBox();
this.$$$loadButtonText$$$(enableExpr, this.$$$getMessageFromBundle$$$("messages", "expr.text"));
enableExpr.setToolTipText("根据语句类型自动生成相应内存马注入的表达式语句");
BottomPanel.add(enableExpr, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
exprBox = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel6 = new DefaultComboBoxModel();
defaultComboBoxModel6.addElement("EL");
defaultComboBoxModel6.addElement("SpEL");
defaultComboBoxModel6.addElement("OGNL");
defaultComboBoxModel6.addElement("FreeMarker");
defaultComboBoxModel6.addElement("Velocity");
defaultComboBoxModel6.addElement("ScriptEngineManager(JS)");
exprBox.setModel(defaultComboBoxModel6);
BottomPanel.add(exprBox, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
generateButton = new JButton();
this.$$$loadButtonText$$$(generateButton, this.$$$getMessageFromBundle$$$("messages", "generate.text"));
BottomPanel.add(generateButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
TipPanel = new JPanel();
TipPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
jMGPanel.add(TipPanel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
TipPanel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
authorLabel = new JLabel();
authorLabel.setText("请勿用于非法用途");
TipPanel.add(authorLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
noticeLabel = new JLabel();
noticeLabel.setText("by pen4uin");
TipPanel.add(noticeLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
private static Method $$$cachedGetBundleMethod$$$ = null;
private String $$$getMessageFromBundle$$$(String path, String key) {
ResourceBundle bundle;
try {
Class<?> thisClass = this.getClass();
if ($$$cachedGetBundleMethod$$$ == null) {
Class<?> dynamicBundleClass = thisClass.getClassLoader().loadClass("com.intellij.DynamicBundle");
$$$cachedGetBundleMethod$$$ = dynamicBundleClass.getMethod("getBundle", String.class, Class.class);
}
bundle = (ResourceBundle) $$$cachedGetBundleMethod$$$.invoke(null, path, thisClass);
} catch (Exception e) {
bundle = ResourceBundle.getBundle(path);
}
return bundle.getString(key);
}
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
/**
* @noinspection ALL
*/
private void $$$loadButtonText$$$(AbstractButton component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return jMGPanel;
}
}
+17
View File
@@ -0,0 +1,17 @@
package jmg.gui;
import com.formdev.flatlaf.FlatLightLaf;
import jmg.gui.form.jMGForm;
import javax.swing.*;
public class jMGApp {
public static void main(String[] args) {
FlatLightLaf.setup();
SwingUtilities.invokeLater(jMGApp::createAndShowGUI);
}
private static void createAndShowGUI() {
jMGForm.start();
}
}
@@ -0,0 +1,78 @@
package jmg.gui.util;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.function.Consumer;
public class ComponentUtil {
public static DocumentListener createDocumentListener(JTextComponent textField, Consumer<String> updateFunction) {
return new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updateText();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateText();
}
@Override
public void changedUpdate(DocumentEvent e) {
// 文本改变时触发(对于普通文本字段可以忽略)
}
private void updateText() {
String text = textField.getText();
if (text.isEmpty()) {
updateFunction.accept(null);
} else {
updateFunction.accept(text);
}
}
};
}
/**
* 恢复滚动条位置
* @param scrollPane
*/
public static void restoreScrollPosition(JScrollPane scrollPane) {
try {
// windows 下窗口闪动
scrollPane.setDoubleBuffered(true);
int scrollValue = scrollPane.getVerticalScrollBar().getValue();
SwingUtilities.invokeLater(() -> {
scrollPane.getVerticalScrollBar().setValue(scrollValue);
});
} catch (Exception ignored) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
public static void setTextIfNotEmpty(JTextComponent component, Consumer<String> setter) {
String text = component.getText().trim();
if (!text.isEmpty()) {
setter.accept(text);
}
}
public static SimpleAttributeSet createSimpleAttributeSet(Color foregroundColor) {
SimpleAttributeSet attributeSet = new SimpleAttributeSet();
StyleConstants.setBold(attributeSet, true);
StyleConstants.setItalic(attributeSet, false);
StyleConstants.setForeground(attributeSet, foregroundColor);
return attributeSet;
}
}
@@ -0,0 +1,40 @@
package jmg.gui.util;
import me.gv7.woodpecker.plugin.exprs.*;
import jmg.core.config.AbstractConfig;
public class JExprUtil {
public static String[] genExprPayload(AbstractConfig config){
byte[] bytes = config.getInjectorBytes();
switch (config.getExprEncoder()){
case "EL":
return new ELExpr().genMemShell(bytes);
case "FreeMarker":
return new FreeMarkerExpr().genMemShell(bytes);
case "OGNL":
return new OGNLExpr().genMemShell(bytes);
case "SpEL":
return new SpELExpr().genMemShell(bytes);
case "Velocity":
return new VelocityExpr().genMemShell(bytes);
case "ScriptEngineManager(JS)":
return new ScriptEngineManagerExpr().genMemShell(bytes);
}
return null;
}
public static void printResult(String[] results) throws Exception {
if (results != null && results.length > 0) {
String[] var3 = results;
int var4 = results.length;
for(int var5 = 0; var5 < var4; ++var5) {
String result = var3[var5];
TextPaneUtil.successPrintln(result);
}
} else {
TextPaneUtil.warningPrintln("暂不支持\n");
}
}
}
@@ -0,0 +1,183 @@
package jmg.gui.util;
import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import jmg.core.config.Constants;
import javax.swing.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
public class MenuUtil {
public static JMenuBar createMenuBar(JFrame frame) {
JMenuBar menuBar = new JMenuBar();
menuBar.add(createSettingMenu(frame));
menuBar.add(createAboutnMenu(frame));
return menuBar;
}
private static JMenu createSettingMenu(JFrame frame) {
JMenu settingsMenu = new JMenu("设置");
settingsMenu.add(MenuUtil.createThemeMenu(frame));
return settingsMenu;
}
public static JPopupMenu createPopupMenu(JFrame frame, JTextPane textPane) {
// 创建右键菜单
JPopupMenu popupMenu = new JPopupMenu();
JMenuItem copySelected = new JMenuItem("复制选中部分");
JMenuItem copyAll = new JMenuItem("复制全部");
JMenuItem saveAs = new JMenuItem("保存为");
// 添加菜单项的动作监听器
copySelected.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String selectedText = textPane.getSelectedText();
if (selectedText != null) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(selectedText), null);
}
}
});
copyAll.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String allText = textPane.getText();
if (allText != null) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(allText), null);
}
}
});
saveAs.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int result = fileChooser.showSaveDialog(frame);
if (result == JFileChooser.APPROVE_OPTION) {
String selectedFilePath = fileChooser.getSelectedFile().getAbsolutePath();
String textToSave = textPane.getText();
try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(selectedFilePath)))) {
writer.print(textToSave);
writer.flush();
JOptionPane.showMessageDialog(frame, "文件保存成功!");
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame, "保存文件时出错:" + ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
}
}
}
});
popupMenu.add(copySelected);
popupMenu.add(copyAll);
popupMenu.add(saveAs);
return popupMenu;
}
private static JMenu createThemeMenu(JFrame frame) {
JMenu themeMenu = new JMenu("主题");
String[] themeNames = {"FlatLight", "FlatDarcula", "FlatIntelliJ", "FlatMacDark", "FlatDark", "FlatMacLight"};
for (String themeName : themeNames) {
JMenuItem themeItem = createThemeMenuItem(frame, themeName);
themeMenu.add(themeItem);
}
return themeMenu;
}
private static JMenuItem createThemeMenuItem(JFrame frame, String themeName) {
JMenuItem themeItem = new JMenuItem(themeName);
themeItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setLookAndFeel(themeName, frame);
}
});
return themeItem;
}
private static void setLookAndFeel(String themeName, JFrame frame) {
try {
switch (themeName) {
case "FlatLight":
UIManager.setLookAndFeel(new FlatLightLaf());
break;
case "FlatDark":
UIManager.setLookAndFeel(new FlatDarkLaf());
break;
case "FlatIntelliJ":
UIManager.setLookAndFeel(new FlatIntelliJLaf());
break;
case "FlatDarcula":
UIManager.setLookAndFeel(new FlatDarculaLaf());
break;
case "FlatMacLight":
UIManager.setLookAndFeel(new FlatMacLightLaf());
break;
case "FlatMacDark":
UIManager.setLookAndFeel(new FlatMacDarkLaf());
break;
default:
UIManager.setLookAndFeel(new NimbusLookAndFeel());
break;
}
SwingUtilities.updateComponentTreeUI(frame);
} catch (UnsupportedLookAndFeelException ex) {
throw new RuntimeException(ex);
}
}
private static JMenu createAboutnMenu(JFrame frame) {
try {
JMenu verMenu = new JMenu("关于");
JMenuItem authorItem = new JMenuItem("作者");
JMenuItem versionItem = new JMenuItem("版本");
versionItem.addActionListener(e -> {
try {
JOptionPane.showMessageDialog(frame, "社区版 " + Constants.JMG_VERSION);
} catch (Exception ex) {
ex.printStackTrace();
}
});
authorItem.addActionListener(e -> {
try {
Desktop desktop = Desktop.getDesktop();
URI oURL = new URI("https://github.com/pen4uin");
desktop.browse(oURL);
} catch (Exception ex) {
ex.printStackTrace();
}
});
authorItem.setToolTipText("pen4uin");
verMenu.add(authorItem);
verMenu.add(versionItem);
return verMenu;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,152 @@
package jmg.gui.util;
import jmg.core.config.AbstractConfig;
import jmg.core.config.Constants;
import jmg.core.jMGCodeApi;
import jmg.core.util.CommonUtil;
public class ResultUtil {
public static void printAntSwordBasicInfo(AbstractConfig config) {
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("密码: " + config.getPass());
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("请求头: " + config.getHeaderName() + ": " + config.getHeaderValue());
TextPaneUtil.rawPrintln("脚本类型: JSP");
TextPaneUtil.rawPrintln("");
}
public static void printGodzillaBasicInfo(AbstractConfig config) {
switch (config.getShellType()) {
case Constants.SHELL_LISTENER:
case Constants.SHELL_FILTER:
case Constants.SHELL_INTERCEPTOR:
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("加密器: JAVA_AES_BASE64");
TextPaneUtil.rawPrintln("密码: " + config.getPass());
TextPaneUtil.rawPrintln("密钥: " + config.getKey());
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("请求头: " + config.getHeaderName() + ": " + config.getHeaderValue());
TextPaneUtil.rawPrintln("脚本类型: JSP");
TextPaneUtil.rawPrintln("");
break;
case Constants.SHELL_WF_HANDLERMETHOD:
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("加密器: JAVA_AES_BASE64");
TextPaneUtil.rawPrintln("密码: " + config.getPass());
TextPaneUtil.rawPrintln("密钥: " + config.getKey());
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("");
break;
}
}
public static void printBehinderBasicInfo(AbstractConfig config) {
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("密码: " + config.getPass());
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("请求头: " + config.getHeaderName() + ": " + config.getHeaderValue());
TextPaneUtil.rawPrintln("脚本类型: JSP");
TextPaneUtil.rawPrintln("内存马类名: " + config.getShellClassName());
TextPaneUtil.rawPrintln("注入器类名: " + config.getInjectorClassName());
TextPaneUtil.rawPrintln("");
}
public static void printSuo5BasicInfo(AbstractConfig config) {
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("连接指令:");
if (config.getHeaderName().equalsIgnoreCase("user-agent")) {
TextPaneUtil.rawPrintln(String.format(" ./suo5 -d --ua '%s' -t http://", config.getHeaderValue()));
TextPaneUtil.rawPrintln(String.format(" ./suo5 -d -l 0.0.0.0:7788 --auth test:test123 --ua '%s' -t http://", config.getHeaderValue()));
} else {
TextPaneUtil.rawPrintln(String.format(" ./suo5 -H '%s: %s' -t http://", config.getHeaderName(), config.getHeaderValue()));
TextPaneUtil.rawPrintln(String.format(" ./suo5 -l 0.0.0.0:7788 --auth test:test123 -H '%s: %s' -t http://", config.getHeaderName(), config.getHeaderValue()));
}
TextPaneUtil.rawPrintln("");
}
public static void printNeoreGeorgBasicInfo(AbstractConfig config) {
TextPaneUtil.successPrintln("基础信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("密钥: " + config.getKey());
TextPaneUtil.rawPrintln("请求路径: " + config.getUrlPattern());
TextPaneUtil.rawPrintln("连接指令:");
TextPaneUtil.rawPrintln(String.format(" python3 neoreg.py -k %s -H '%s:%s' -u http://", config.getKey(), config.getHeaderName(), config.getHeaderValue()));
TextPaneUtil.rawPrintln(String.format(" python3 neoreg.py --skip --proxy http://127.0.0.1:8080 -vv -k %s -H '%s:%s' -u http:// ", config.getKey(), config.getHeaderName(), config.getHeaderValue()));
TextPaneUtil.rawPrintln("");
}
public static void printDebugInfo(AbstractConfig config) {
TextPaneUtil.successPrintln("调试信息:");
TextPaneUtil.rawPrintln("");
TextPaneUtil.rawPrintln("内存马类名: " + config.getShellClassName());
TextPaneUtil.rawPrintln("注入器类名: " + config.getInjectorClassName());
TextPaneUtil.rawPrintln("内存马字节流长度: " + config.getShellBytesLength());
TextPaneUtil.rawPrintln("注入器字节流长度: " + config.getInjectorBytesLength());
TextPaneUtil.rawPrintln("");
}
public static void resultOutput(AbstractConfig config) throws Throwable {
switch (config.getToolType()) {
case Constants.TOOL_ANTSWORD:
printAntSwordBasicInfo(config);
break;
case Constants.TOOL_BEHINDER:
printBehinderBasicInfo(config);
break;
case Constants.TOOL_GODZILLA:
printGodzillaBasicInfo(config);
break;
case Constants.TOOL_SUO5:
printSuo5BasicInfo(config);
break;
case Constants.TOOL_NEOREGEORG:
printNeoreGeorgBasicInfo(config);
break;
}
if (config.getExprEncoder() != null) {
jMGCodeApi codeApi = new jMGCodeApi(config);
codeApi.generate();
String[] results = JExprUtil.genExprPayload(config);
JExprUtil.printResult(results);
} else {
switch (config.getOutputFormat()) {
case Constants.FORMAT_CLASS:
case Constants.FORMAT_JSP:
case Constants.FORMAT_JAR:
case Constants.FORMAT_JAR_AGENT:
try {
CommonUtil.transformToFile(config);
TextPaneUtil.successPrintln("结果输出:\n");
TextPaneUtil.rawPrintln(config.getSavePath() + "\n");
} catch (Throwable e) {
}
break;
case Constants.FORMAT_BCEL:
case Constants.FORMAT_JS:
case Constants.FORMAT_BASE64:
case Constants.FORMAT_BIGINTEGER:
try {
String result = CommonUtil.transformTotext(config);
TextPaneUtil.successPrintln("结果输出:\n");
TextPaneUtil.rawPrintln(result + "\n");
} catch (Throwable e) {
}
break;
}
}
printDebugInfo(config);
}
}
@@ -0,0 +1,41 @@
package jmg.gui.util;
import jmg.antsword.generator.AntSwordGenerator;
import jmg.behinder.generator.BehinderGenerator;
import jmg.core.config.AbstractConfig;
import jmg.core.config.Constants;
import jmg.core.generator.IShellGenerator;
import jmg.custom.generator.CustomGenerator;
import jmg.godzilla.generator.GodzillaGenerator;
import jmg.neoregeorg.generator.NeoreGeorgGenerator;
import jmg.suo5.generator.Suo5Generator;
public class ShellGeneratorUtil {
IShellGenerator shellGenerator;
public void makeShell(AbstractConfig config) throws Exception {
switch (config.getToolType()) {
case Constants.TOOL_ANTSWORD:
shellGenerator = new AntSwordGenerator();
break;
case Constants.TOOL_BEHINDER:
shellGenerator = new BehinderGenerator();
break;
case Constants.TOOL_GODZILLA:
shellGenerator = new GodzillaGenerator();
break;
case Constants.TOOL_SUO5:
shellGenerator = new Suo5Generator();
break;
case Constants.TOOL_NEOREGEORG:
shellGenerator = new NeoreGeorgGenerator();
break;
case Constants.TOOL_CUSTOM:
shellGenerator = new CustomGenerator();
break;
default:
throw new IllegalArgumentException("Unsupported tool type: " + config.getToolType());
}
shellGenerator.makeShell(config);
}
}
@@ -0,0 +1,144 @@
package jmg.gui.util;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
/**
* 控制文本颜色,提升用户体验
*/
public class TextPaneUtil {
private static JTextPane textPane;
private static final Font font;
private static final SimpleAttributeSet ERROR_ATT;
private static final SimpleAttributeSet WARN_ATT;
private static final SimpleAttributeSet SUCCESS_ATT;
private static final SimpleAttributeSet RAW_ATT;
private static final SimpleAttributeSet START_ATT;
static {
font = new Font("Lucida Grande", Font.PLAIN, 13);
ERROR_ATT = ComponentUtil.createSimpleAttributeSet(new Color(255, 0, 0));
WARN_ATT = ComponentUtil.createSimpleAttributeSet(new Color(255,165,0));
SUCCESS_ATT = ComponentUtil.createSimpleAttributeSet(new Color(70,135,55));
RAW_ATT = ComponentUtil.createSimpleAttributeSet(new Color(0, 0, 0));
START_ATT = ComponentUtil.createSimpleAttributeSet(Color.gray);
}
public static void rawPrintln(String str) {
try {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("%s\n", str), RAW_ATT);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void successPrintln(String str) {
try {
// 对 jexpr-encoder-utils 输出的处理
if (str.startsWith("[+]")) {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("%s\n", str.replace("==>", "==>\n").replace("<==", "<==\n\n\n\n")), SUCCESS_ATT);
} else {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("[+] %s\n", str), SUCCESS_ATT);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void warningPrintln(String str) {
try {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("[!] %s\n", str), WARN_ATT);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void errorPrintln(String str) {
try {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("[x] %s\n", str), ERROR_ATT);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void startPrintln(String str) {
try {
textPane.getDocument().insertString(textPane.getDocument().getLength(), String.format("[>] %s\n", str), START_ATT);
} catch (Exception e) {
e.printStackTrace();
}
}
/////////////////////////////////////////////////////////////
// 以下内部类全都用于实现自动强制折行
// https://github.com/MrYKK/oimchat/blob/598aedd94767667498d66d1ed682f073f3f181b7/oim-fx/src/test/java/swing/JIMSendTextPane.java
/////////////////////////////////////////////////////////////
public static class WarpEditorKit extends StyledEditorKit {
private static final long serialVersionUID = 1L;
private ViewFactory defaultFactory = new WarpColumnFactory();
@Override
public ViewFactory getViewFactory() {
return defaultFactory;
}
}
private static class WarpColumnFactory implements ViewFactory {
public View create(Element elem) {
String kind = elem.getName();
if (kind != null) {
if (kind.equals(AbstractDocument.ContentElementName)) {
return new WarpLabelView(elem);
} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
return new ParagraphView(elem);
} else if (kind.equals(AbstractDocument.SectionElementName)) {
return new BoxView(elem, View.Y_AXIS);
} else if (kind.equals(StyleConstants.ComponentElementName)) {
return new ComponentView(elem);
} else if (kind.equals(StyleConstants.IconElementName)) {
return new IconView(elem);
}
}
// default to text display
return new LabelView(elem);
}
}
private static class WarpLabelView extends LabelView {
public WarpLabelView(Element elem) {
super(elem);
}
@Override
public float getMinimumSpan(int axis) {
switch (axis) {
case View.X_AXIS:
return 0;
case View.Y_AXIS:
return super.getMinimumSpan(axis);
default:
throw new IllegalArgumentException("Invalid axis: " + axis);
}
}
}
/////////////////////////////////////////////////////////////////////////////////
public static JTextPane getTextPane() {
return textPane;
}
public static void initTextPane(JTextPane textPane) {
TextPaneUtil.textPane = textPane;
TextPaneUtil.textPane.setEditorKit(new WarpEditorKit());
TextPaneUtil.textPane.setFont(font);
}
}
@@ -0,0 +1,14 @@
format.text=Output Format
generate.text=Generate
headerName.text=Header Key
headerValue.text=Header Value
injectorClsName.text=Injector Class Name
key.text=Key
pass.text=Password
server.text=Server Type
shell.text=Shell Type
shellClsName.text=Shell Class Name
tool.text=Tool Type
uri.text=Request URI
gadget.text=Enable Gadget Wrapping
expr.text=Enable Expr Wrapping
@@ -0,0 +1,14 @@
format.text=Output Format
generate.text=Generate
headerName.text=Request Header Key
headerValue.text=Request Header Value
injectorClsName.text=Injector Class Name
key.text=Key
pass.text=Password
server.text=Server Type
shell.text=Shell Type
shellClsName.text=Shell Class Name
tool.text=Tool Type
uri.text=Request URI
gadget.text=Enable Gadget Wrapping
expr.text=Enable Expr Wrapping
@@ -0,0 +1,14 @@
format.text=\u8F93\u51FA\u683C\u5F0F
generate.text=\u751F\u6210
headerName.text=\u8BF7\u6C42\u5934\u952E
headerValue.text=\u8BF7\u6C42\u5934\u503C
injectorClsName.text=\u6CE8\u5165\u5668\u7C7B\u540D
key.text=\u5BC6\u94A5
pass.text=\u5BC6\u7801
server.text=\u4E2D\u95F4\u4EF6/\u6846\u67B6
shell.text=\u7EC4\u4EF6\u7C7B\u578B
shellClsName.text=\u5185\u5B58\u9A6C\u7C7B\u540D
tool.text=\u5DE5\u5177\u7C7B\u578B
uri.text=\u8BF7\u6C42\u8DEF\u5F84
gadget.text=\u4E13\u9879\u6F0F\u6D1E\u5C01\u88C5
expr.text=\u8868\u8FBE\u5F0F\u8BED\u53E5\u5C01\u88C5
@@ -0,0 +1,14 @@
format.text=输出格式
generate.text=生成
headerName.text=请求头键
headerValue.text=请求头值
injectorClsName.text=注入器类名
key.text=密钥
pass.text=密码
server.text=中间件/框架
shell.text=组件类型
shellClsName.text=内存马类名
tool.text=工具类型
uri.text=请求路径
gadget.text=专项漏洞封装
expr.text=表达式语句封装