Version: 2.5.2 Update

This commit is contained in:
ᴋᴇʏ
2023-10-19 22:42:54 +08:00
committed by GitHub
parent 4c23d62576
commit 953b966961

View File

@@ -1,9 +1,11 @@
package burp.rule.utils; package burp.rule.utils;
import com.squareup.okhttp.OkHttpClient; import burp.*;
import com.squareup.okhttp.Request; import burp.config.ConfigEntry;
import com.squareup.okhttp.Response; import burp.config.ConfigLoader;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.net.URL;
import java.util.Arrays;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
/** /**
@@ -17,19 +19,31 @@ public class RuleTool {
} }
public void getRulesFromSite() { public void getRulesFromSite() {
String url = "https://cdn.jsdelivr.net/gh/gh0stkey/HaE@gh-pages/Rules.yml"; // 以独立线程使用BurpSuite官方请求接口获取规则
OkHttpClient httpClient = new OkHttpClient(); Thread t = new Thread(()->{
Request httpRequest = new Request.Builder().url(url).get().build();
try { try {
Response httpResponse = httpClient.newCall(httpRequest).execute(); URL url = new URL("https://cdn.jsdelivr.net/gh/gh0stkey/HaE@gh-pages/Rules.yml");
// 获取官方规则文件,在线更新写入 IHttpService iHttpService = BurpExtender.helpers.buildHttpService(url.getHost(), 443, true);
IHttpRequestResponse iHttpRequestResponse = BurpExtender.callbacks.makeHttpRequest(iHttpService, BurpExtender.helpers.buildHttpRequest(url));
byte[] responseByte = iHttpRequestResponse.getResponse();
IResponseInfo iResponseInfo = BurpExtender.helpers.analyzeResponse(responseByte);
int bodyOffset = iResponseInfo.getBodyOffset();
byte[] responseBodyByte = Arrays.copyOfRange(responseByte, bodyOffset, responseByte.length);
FileOutputStream fileOutputStream = new FileOutputStream(this.rulesFilePath); FileOutputStream fileOutputStream = new FileOutputStream(this.rulesFilePath);
fileOutputStream.write(httpResponse.body().bytes()); fileOutputStream.write(responseBodyByte);
JOptionPane.showMessageDialog(null, "Rules updated successfully!", "Info", fileOutputStream.close();
JOptionPane.showMessageDialog(null, "Rules update successfully!", "Info",
JOptionPane.INFORMATION_MESSAGE); JOptionPane.INFORMATION_MESSAGE);
} catch (Exception ignored) { } catch (Exception e) {
JOptionPane.showMessageDialog(null, "Please check your network!", "Error", JOptionPane.showMessageDialog(null, e, "Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
});
t.start();
try {
t.join();
} catch (Exception e) {
e.printStackTrace();
}
} }
} }