() {
100 | @java.lang.Override
101 | public pocFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
102 | return new pocFutureStub(channel, callOptions);
103 | }
104 | };
105 | return pocFutureStub.newStub(factory, channel);
106 | }
107 |
108 | /**
109 | *
110 | * `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口
111 | *
112 | */
113 | public static abstract class pocImplBase implements io.grpc.BindableService {
114 |
115 | /**
116 | *
117 | * 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应)
118 | *
119 | */
120 | public void pocscan(burp.rpc.Poc_Request request,
121 | io.grpc.stub.StreamObserver responseObserver) {
122 | asyncUnimplementedUnaryCall(getPocscanMethod(), responseObserver);
123 | }
124 |
125 | @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
126 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
127 | .addMethod(
128 | getPocscanMethod(),
129 | asyncUnaryCall(
130 | new MethodHandlers<
131 | burp.rpc.Poc_Request,
132 | burp.rpc.Poc_Response>(
133 | this, METHODID_POCSCAN)))
134 | .build();
135 | }
136 | }
137 |
138 | /**
139 | *
140 | * `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口
141 | *
142 | */
143 | public static final class pocStub extends io.grpc.stub.AbstractAsyncStub {
144 | private pocStub(
145 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
146 | super(channel, callOptions);
147 | }
148 |
149 | @java.lang.Override
150 | protected pocStub build(
151 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
152 | return new pocStub(channel, callOptions);
153 | }
154 |
155 | /**
156 | *
157 | * 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应)
158 | *
159 | */
160 | public void pocscan(burp.rpc.Poc_Request request,
161 | io.grpc.stub.StreamObserver responseObserver) {
162 | asyncUnaryCall(
163 | getChannel().newCall(getPocscanMethod(), getCallOptions()), request, responseObserver);
164 | }
165 | }
166 |
167 | /**
168 | *
169 | * `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口
170 | *
171 | */
172 | public static final class pocBlockingStub extends io.grpc.stub.AbstractBlockingStub {
173 | private pocBlockingStub(
174 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
175 | super(channel, callOptions);
176 | }
177 |
178 | @java.lang.Override
179 | protected pocBlockingStub build(
180 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
181 | return new pocBlockingStub(channel, callOptions);
182 | }
183 |
184 | /**
185 | *
186 | * 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应)
187 | *
188 | */
189 | public burp.rpc.Poc_Response pocscan(burp.rpc.Poc_Request request) {
190 | return blockingUnaryCall(
191 | getChannel(), getPocscanMethod(), getCallOptions(), request);
192 | }
193 | }
194 |
195 | /**
196 | *
197 | * `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口
198 | *
199 | */
200 | public static final class pocFutureStub extends io.grpc.stub.AbstractFutureStub {
201 | private pocFutureStub(
202 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
203 | super(channel, callOptions);
204 | }
205 |
206 | @java.lang.Override
207 | protected pocFutureStub build(
208 | io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
209 | return new pocFutureStub(channel, callOptions);
210 | }
211 |
212 | /**
213 | *
214 | * 一元模式(在一次调用中, 客户端只能向服务器传输一次请求数据, 服务器也只能返回一次响应)
215 | *
216 | */
217 | public com.google.common.util.concurrent.ListenableFuture pocscan(
218 | burp.rpc.Poc_Request request) {
219 | return futureUnaryCall(
220 | getChannel().newCall(getPocscanMethod(), getCallOptions()), request);
221 | }
222 | }
223 |
224 | private static final int METHODID_POCSCAN = 0;
225 |
226 | private static final class MethodHandlers implements
227 | io.grpc.stub.ServerCalls.UnaryMethod,
228 | io.grpc.stub.ServerCalls.ServerStreamingMethod,
229 | io.grpc.stub.ServerCalls.ClientStreamingMethod,
230 | io.grpc.stub.ServerCalls.BidiStreamingMethod {
231 | private final pocImplBase serviceImpl;
232 | private final int methodId;
233 |
234 | MethodHandlers(pocImplBase serviceImpl, int methodId) {
235 | this.serviceImpl = serviceImpl;
236 | this.methodId = methodId;
237 | }
238 |
239 | @java.lang.Override
240 | @java.lang.SuppressWarnings("unchecked")
241 | public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
242 | switch (methodId) {
243 | case METHODID_POCSCAN:
244 | serviceImpl.pocscan((burp.rpc.Poc_Request) request,
245 | (io.grpc.stub.StreamObserver) responseObserver);
246 | break;
247 | default:
248 | throw new AssertionError();
249 | }
250 | }
251 |
252 | @java.lang.Override
253 | @java.lang.SuppressWarnings("unchecked")
254 | public io.grpc.stub.StreamObserver invoke(
255 | io.grpc.stub.StreamObserver responseObserver) {
256 | switch (methodId) {
257 | default:
258 | throw new AssertionError();
259 | }
260 | }
261 | }
262 |
263 | private static abstract class pocBaseDescriptorSupplier
264 | implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
265 | pocBaseDescriptorSupplier() {}
266 |
267 | @java.lang.Override
268 | public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
269 | return burp.rpc.Scan.getDescriptor();
270 | }
271 |
272 | @java.lang.Override
273 | public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
274 | return getFileDescriptor().findServiceByName("poc");
275 | }
276 | }
277 |
278 | private static final class pocFileDescriptorSupplier
279 | extends pocBaseDescriptorSupplier {
280 | pocFileDescriptorSupplier() {}
281 | }
282 |
283 | private static final class pocMethodDescriptorSupplier
284 | extends pocBaseDescriptorSupplier
285 | implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
286 | private final String methodName;
287 |
288 | pocMethodDescriptorSupplier(String methodName) {
289 | this.methodName = methodName;
290 | }
291 |
292 | @java.lang.Override
293 | public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
294 | return getServiceDescriptor().findMethodByName(methodName);
295 | }
296 | }
297 |
298 | private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
299 |
300 | public static io.grpc.ServiceDescriptor getServiceDescriptor() {
301 | io.grpc.ServiceDescriptor result = serviceDescriptor;
302 | if (result == null) {
303 | synchronized (pocGrpc.class) {
304 | result = serviceDescriptor;
305 | if (result == null) {
306 | serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
307 | .setSchemaDescriptor(new pocFileDescriptorSupplier())
308 | .addMethod(getPocscanMethod())
309 | .build();
310 | }
311 | }
312 | }
313 | return result;
314 | }
315 | }
316 |
--------------------------------------------------------------------------------
/src/main/java/burp/scan/FingerScan.java:
--------------------------------------------------------------------------------
1 | package burp.scan;
2 |
3 | import burp.IHttpRequestResponse;
4 | import burp.IHttpService;
5 | import burp.model.finger.FingerEntry;
6 | import burp.model.log.LogEntry;
7 |
8 | import java.io.IOException;
9 | import java.net.URL;
10 | import java.security.KeyManagementException;
11 | import java.security.NoSuchAlgorithmException;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import java.util.Objects;
15 |
16 | import static burp.BurpExtender.callbacks;
17 | import static burp.BurpExtender.helpers;
18 | import static burp.Main_Vuln.*;
19 | import static burp.Main_Vuln.count;
20 | import static burp.utils.Conn.*;
21 | import static burp.utils.Finger.*;
22 |
23 | public class FingerScan {
24 | public static LogEntry Check_Finger(int toolFlag, IHttpRequestResponse messageInfo) throws IOException, NoSuchAlgorithmException, KeyManagementException {
25 | List all_finger = model_finger.getAllValue();
26 | if(stop_finger_scan || all_finger.isEmpty()){
27 | return null;
28 | }
29 | IHttpService httpService = messageInfo.getHttpService();
30 | IHttpRequestResponse soucrce_messageInfo = messageInfo;
31 | // 获取主机名
32 | String host_url = get_requests_url(messageInfo,false);
33 |
34 | String host = httpService.getHost();
35 | printDebug("Start Finger Scan Host:"+host_url);
36 | if(finger_ico_hash_map.isEmpty() || finger_ico_hash_map.get(host)==null || Objects.equals(finger_ico_hash_map.get(host), "")){
37 | printDebug("【GET ICO】"+host_url);
38 | String iconhash= get_host_ico(host_url,messageInfo);
39 | if(!iconhash.isEmpty()){
40 | printDebug("【GET ICO】"+host_url+"【Hash】"+iconhash);
41 | finger_ico_hash_map.put(host,iconhash);
42 | }else{
43 | printDebug("【GET ICO】"+host_url+"【Ico Hash】null, all faviconhash plugins is close!");
44 | }
45 | }
46 | printDebug("【Finger num】"+all_finger.size());
47 | List all_finger_result=new ArrayList<>();
48 | for(FingerEntry item :all_finger){
49 | count++;
50 | String mathc_result="";
51 | if(Objects.equals(item.method, "keyword")){
52 | mathc_result = Match_keyword_finger(messageInfo,item);
53 |
54 | } else if (Objects.equals(item.method, "faviconhash")) {
55 | mathc_result = Match_faviconhash_finger(messageInfo,item,host);
56 | }
57 | if (mathc_result!=null && !mathc_result.isEmpty()){
58 | all_finger_result.add(mathc_result);
59 | }
60 | }
61 | String tool_name="Others";
62 | URL reuslt_url;
63 | String[] head_list = get_requests_head_line(messageInfo);
64 | if(is_burp){
65 | tool_name = callbacks.getToolName(toolFlag);
66 | reuslt_url = helpers.analyzeRequest(messageInfo).getUrl();
67 | }else{
68 | String req_url;
69 | if (head_list != null) {
70 | req_url = get_requests_url(messageInfo,false)+head_list[1];
71 | }else{
72 | req_url = get_requests_url(messageInfo,false);
73 | }
74 | reuslt_url = new URL(req_url);
75 | }
76 |
77 | String enable_poc_str = String.join("$$$", all_finger_result);
78 | printDebug("【Match End】"+reuslt_url+"【Enable_poc_str】"+enable_poc_str);
79 | if (!enable_poc_str.isEmpty()){
80 | return new LogEntry(count, tool_name, soucrce_messageInfo, reuslt_url, "", "", "", 0, GetMessageStatusCode(messageInfo), enable_poc_str, "",-1,messageInfo);
81 | // return new LogEntry(count, tool_name, callbacks.saveBuffersToTempFiles(messageInfo), helpers.analyzeRequest(messageInfo).getUrl(), "", "", "", 0, (int) (helpers.analyzeResponse(messageInfo.getResponse()).getStatusCode()), enable_poc_str, "");
82 | }else{
83 | return null;
84 | }
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/burp/scan/Scan.java:
--------------------------------------------------------------------------------
1 | package burp.scan;
2 | import burp.IHttpRequestResponse;
3 | import burp.model.log.LogEntry;
4 | import java.util.Arrays;
5 |
6 | import static burp.BurpExtender.callbacks;
7 | import static burp.Main_Vuln.*;
8 | import static burp.scan.PocScan.Check_Vuln;
9 | public class Scan {
10 | public static void accept_Http_Info(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo){
11 | if (!messageIsRequest) {
12 | if((toolFlag == callbacks.TOOL_PROXY && clicks_Proxy)|| (toolFlag == callbacks.TOOL_REPEATER && clicks_Repeater)){
13 | //指纹扫描
14 | if(switchs_finger){
15 | finger_scan(toolFlag,messageInfo,true);
16 | }
17 | if(switchs_poc) {
18 | poc_scan(toolFlag,messageInfo);
19 | }
20 |
21 | }
22 | }
23 | }
24 | public static void poc_scan(int toolFlag, IHttpRequestResponse messageInfo){
25 | Thread thread = new Thread(() -> {
26 | try {
27 | Check_Vuln(toolFlag,messageInfo,null);
28 | } catch (Exception ex) {
29 | printErr(ex.getMessage());
30 | printErr(Arrays.toString(ex.getStackTrace()));
31 | }
32 | });
33 | thread.start();
34 | }
35 |
36 | public static void finger_scan(int toolFlag, IHttpRequestResponse messageInfo,Boolean enable_poc){
37 | Thread thread = new Thread(() -> {
38 | try {
39 | LogEntry finger_info = FingerScan.Check_Finger(toolFlag, messageInfo);
40 | if (finger_info != null && !finger_info.finger_scan_result.isEmpty()) {
41 | if (enable_poc && switchs_poc) {
42 | Check_Vuln(toolFlag, messageInfo, finger_info);
43 | } else {
44 | finger_info.finger_scan_result = finger_info.finger_scan_result.replaceAll("\\$\\$\\$", ",");
45 | model.addValueAt(finger_info);
46 | model.fireTableDataChanged();
47 | }
48 | }
49 | } catch (Exception ex) {
50 | printErr(ex.getMessage());
51 | printErr(Arrays.toString(ex.getStackTrace()));
52 | }
53 | });
54 | thread.start();
55 | }
56 |
57 | public static void myappscan(){
58 | Thread thread = new Thread(() -> {
59 | for(String url_str :all_scan_url){
60 | try {
61 | IHttpRequestResponse messageInfo = createHttpRequestResponse(url_str);
62 | if(messageInfo!=null && messageInfo.getResponse().length>0&& switchs_finger){
63 | finger_scan(1024,messageInfo,true);
64 | }
65 | if(messageInfo!=null && messageInfo.getResponse().length>0 && switchs_poc) {
66 | poc_scan(1024,messageInfo);
67 | }
68 | } catch (Exception ex) {
69 | printErr(ex.getMessage());
70 | printErr(Arrays.toString(ex.getStackTrace()));
71 | }
72 | }
73 | });
74 | thread.start();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/burp/testgrpc.java:
--------------------------------------------------------------------------------
1 | package burp;
2 |
3 | import burp.rpc.pocGrpc;
4 | import burp.rpc.pocGrpc;
5 | import io.grpc.ManagedChannel;
6 | import io.grpc.ManagedChannelBuilder;
7 | import burp.rpc.pocGrpc.pocBlockingStub;
8 | import burp.rpc.Poc_Request;
9 | import burp.rpc.Poc_Response;
10 |
11 | public class testgrpc {
12 | public static void main(String[] args) {
13 | ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 50051).usePlaintext().build();
14 | pocGrpc.pocBlockingStub client = pocGrpc.newBlockingStub(channel);
15 |
16 | Poc_Request requests = Poc_Request.newBuilder()
17 | .setPocType("example")
18 | .setUrl("http://example.com")
19 | .setPoc("...")
20 | .build();
21 |
22 | Poc_Response response = client.pocscan(requests);
23 | System.out.println("扫描结果: " + response.getResult());
24 | System.out.println("是否成功: " + response.getIsSuccess());
25 |
26 | channel.shutdown();
27 | }
28 | }
--------------------------------------------------------------------------------
/src/main/java/burp/utils/Config.java:
--------------------------------------------------------------------------------
1 | package burp.utils;
2 |
3 | import static burp.Main_Vuln.*;
4 | import org.yaml.snakeyaml.Yaml;
5 |
6 | import javax.swing.*;
7 | import java.io.*;
8 | import java.nio.charset.StandardCharsets;
9 | import java.nio.file.Files;
10 | import java.nio.file.Paths;
11 | import java.util.Arrays;
12 | import java.util.Map;
13 | import java.util.Objects;
14 |
15 | public class Config {
16 | public static Map read_config(String Config_PATH) throws IOException {
17 | BufferedReader in = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(Config_PATH)), StandardCharsets.UTF_8));
18 | String str;
19 | StringBuilder str_data= new StringBuilder();
20 | while ((str = in.readLine()) != null) {
21 | str_data.append(str).append("\n");
22 | }
23 | Yaml yaml = new Yaml();
24 | return yaml.load(str_data.toString());
25 | }
26 | public static void save_config() {
27 | if(Objects.equals(btn3_white.getText(), "当前白名单状态:启用")){
28 | Global_Config.put("WhiteEnable", true) ;
29 | }else{
30 | Global_Config.put("WhiteEnable",false) ;
31 | }
32 | Global_Config.put("Enable_Poc",chkbox_poc.isSelected()) ;
33 | Global_Config.put("Enable_Finger",chkbox_finger.isSelected()) ;
34 | Global_Config.put("Is_Proxy", chkbox_proxy.isSelected()) ;
35 | Global_Config.put("Is_Repeater", chkbox_repeater.isSelected()) ;
36 | Global_Config.put("Is_Debug",chkbox_is_debug.isSelected()) ;
37 | Global_Config.put("WhiteList", textField_white.getText()) ;
38 | Global_Config.put("BlackList", textField_black.getText()) ;
39 | // Global_Config.put("EnablePocList", vuln_poc_combox.getSelectedItem()) ;
40 | // Global_Config.put("DisenableFingerPocList", vuln_disenable_finger_poc_combox.getSelectedItem()) ;
41 |
42 | Poc.reload_poc();
43 | Yaml yaml = new Yaml(options);
44 | String yamlString = yaml.dump(Global_Config);
45 | try (Writer out = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(Paths.get(Config_PATH)), StandardCharsets.UTF_8))) {
46 | out.write(yamlString);
47 | } catch (IOException e) {
48 | printErr(Arrays.toString(e.getStackTrace()));
49 | }
50 | JOptionPane.showMessageDialog(null, "配置保存成功!", "提示", JOptionPane.INFORMATION_MESSAGE);
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/burp/utils/Conn.java:
--------------------------------------------------------------------------------
1 | package burp.utils;
2 |
3 | import burp.IHttpRequestResponse;
4 | import burp.IHttpService;
5 | import burp.rpc.Poc_Request;
6 | import burp.rpc.Poc_Response;
7 | import io.grpc.StatusRuntimeException;
8 |
9 | import java.net.URL;
10 | import java.nio.charset.StandardCharsets;
11 | import java.util.*;
12 |
13 | import static burp.BurpExtender.helpers;
14 | import static burp.Main_Vuln.*;
15 |
16 | public class Conn {
17 | private static final List userAgents = new ArrayList<>();
18 | static {
19 | // 初始化User-Agent列表
20 | userAgents.add("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36");
21 | userAgents.add("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36");
22 | userAgents.add("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36");
23 | userAgents.add("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0");
24 | userAgents.add("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Firefox/90.0");
25 | userAgents.add("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0");
26 | userAgents.add("Mozilla/5.0 (iPhone; CPU iPhone OS 14_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1");
27 | userAgents.add("Mozilla/5.0 (iPad; CPU OS 14_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1");
28 | }
29 | public static String Get_Random_UserAgent() {
30 | Random random = new Random();
31 | int index = random.nextInt(userAgents.size());
32 | return userAgents.get(index);
33 | }
34 | public static Boolean is_white_black(URL url)
35 | {
36 |
37 | String paths = url.getProtocol()+"://"+url.getAuthority();
38 | String black_text = (String) Global_Config.get("BlackList");
39 | //判断黑名单
40 | if(!black_text.isEmpty()){
41 | String[] blackList = black_text.split(",");
42 | for (String wl : blackList) {
43 | if (paths.contains(wl)) { // 如果在黑名单里面
44 | printDebug("【匹配到黑名单】path:" + paths + " 域名:" + wl );
45 | return false;
46 | }
47 | }
48 | }
49 |
50 | //是否继续往下执行
51 | boolean b = false;
52 | Boolean is_enable_white = (Boolean) Global_Config.get("WhiteEnable");
53 | if(is_enable_white) { // 判断是否启用白名单
54 | String white_text = (String) Global_Config.get("WhiteList");
55 | String[] whiteList = white_text.split(",");
56 | for(String wl:whiteList) {
57 | if(paths.contains(wl)) { // 如果在白名单里面
58 | b = true;
59 | break;
60 | }
61 | }
62 | if(!b) { // 如果不是白名单 那么退出
63 | printDebug("【不在白名单内】path:"+paths);
64 | }
65 |
66 | }else{
67 | b= true;
68 | }
69 | return b;
70 | }
71 | //得到请求方法 路径 HTTP版本
72 | public static String[] get_requests_head_line(IHttpRequestResponse messageInfo) {
73 | String[] return_result = new String[3];
74 | String headersPart = new String(messageInfo.getRequest(), StandardCharsets.UTF_8);
75 | List httpHeaders = new ArrayList<>(Arrays.asList(headersPart.split("\r\n")));
76 | if(httpHeaders.isEmpty()){
77 | return null;
78 | }
79 | String headUrl = httpHeaders.get(0);
80 | String[] head_list = headUrl.split(" ");
81 | if(head_list.length>=3){
82 | return head_list;
83 | } else if (head_list.length==2) {
84 | return_result[0] = head_list[0];
85 | return_result[1] = head_list[1];
86 | return_result[2] ="HTTP/1.1";
87 | } else if (head_list.length==1) {
88 | return_result[0] = head_list[0];
89 | return_result[1] = "/";
90 | return_result[2] ="HTTP/1.1";
91 | }else{
92 | return_result[0] = "GET";
93 | return_result[1] = "/";
94 | return_result[2] ="HTTP/1.1";
95 | }
96 | return return_result;
97 | }
98 | public static Map get_requests_response_head_body(byte[] req_resp_byte) {
99 | Map return_sult = new HashMap<>();
100 | String headersPart = new String(req_resp_byte, StandardCharsets.UTF_8);
101 | String[] http_body_head = headersPart.split("\n\n|\r\n\r\n");
102 | List header_list = Arrays.asList(http_body_head[0].split("\r\n|\n|\r"));
103 | return_sult.put("header",header_list);
104 | if(http_body_head.length>=2){
105 | return_sult.put("body",http_body_head[1]);
106 | }else{
107 | return_sult.put("body","");
108 | }
109 | return return_sult;
110 | }
111 |
112 | public static int GetMessageStatusCode(IHttpRequestResponse requestResponse){
113 | if(is_burp){
114 | return helpers.analyzeResponse(requestResponse.getResponse()).getStatusCode();
115 | }else{
116 |
117 | String response = new String(requestResponse.getResponse());
118 | String[] response_ =response.split("\\n");
119 | String head_line_str= response_[0];
120 | if(head_line_str.startsWith("HTTP/")){
121 | String[] head_line_list = head_line_str.split(" ");
122 | if(head_line_list.length>=2){
123 | return Integer.parseInt(head_line_list[1]);
124 | }else{
125 | return -1;
126 | }
127 | }else{
128 | return -1;
129 | }
130 | }
131 | }
132 | public static String get_requests_url(IHttpRequestResponse messageInfo,boolean is_path){
133 | IHttpService iHttpService = messageInfo.getHttpService();
134 | String host_url;
135 | if(iHttpService.getPort()!=-1){
136 | host_url = iHttpService.getProtocol()+"://"+iHttpService.getHost()+":"+iHttpService.getPort();
137 | }else{
138 | host_url = iHttpService.getProtocol()+"://"+iHttpService.getHost();
139 | }
140 | if(is_path){
141 | String[] temp = get_requests_head_line(messageInfo);
142 | if (temp != null) {
143 | host_url =host_url +temp[1];
144 | }
145 | }
146 | return host_url;
147 | }
148 |
149 | public static Poc_Response Grpc_Send(Poc_Request requests){
150 | // Poc_Response response = client.pocscan(requests);
151 | try {
152 | return client.pocscan(requests);
153 | } catch (StatusRuntimeException e) {
154 | printErr("RPC failed: "+e.getStatus());
155 | return null;
156 | }
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/src/main/java/burp/utils/CustHttpService.java:
--------------------------------------------------------------------------------
1 | package burp.utils;
2 |
3 | import burp.IHttpRequestResponse;
4 | import burp.IHttpService;
5 |
6 | import javax.net.ssl.HttpsURLConnection;
7 | import javax.net.ssl.SSLContext;
8 | import javax.net.ssl.TrustManager;
9 | import javax.net.ssl.X509TrustManager;
10 | import java.io.*;
11 | import java.net.HttpURLConnection;
12 | import java.net.URL;
13 | import java.nio.charset.StandardCharsets;
14 | import java.security.KeyManagementException;
15 | import java.security.NoSuchAlgorithmException;
16 | import java.security.cert.X509Certificate;
17 | import java.util.ArrayList;
18 | import java.util.Arrays;
19 | import java.util.List;
20 | import java.util.Objects;
21 |
22 | import static burp.Main_Vuln.printErr;
23 |
24 | public class CustHttpService {
25 | public static IHttpRequestResponse GetHttpRequestResponse(String url_str,List req_headers, String req_body) {
26 | try {
27 | List all_headers = new ArrayList<>();
28 | if(req_body==null){
29 | req_body="";
30 | }
31 | String requests_raw;
32 | String req_method="GET";
33 | String head_str = req_headers.get(0);
34 | String[] heads_list=new String[3];
35 | if(head_str.contains("HTTP")){
36 | String[] temp_head_list = head_str.split(" ");
37 | if(temp_head_list.length>=3){
38 | heads_list[0] = temp_head_list[0];
39 | heads_list[1] = temp_head_list[1];
40 | heads_list[2] = temp_head_list[2];
41 | }else if(temp_head_list.length==2){
42 | heads_list[0] = temp_head_list[0];
43 | heads_list[1] = temp_head_list[1];
44 | heads_list[2] = "HTTP/1.1";
45 | } else if (temp_head_list.length==1) {
46 | heads_list[1] ="/";
47 | heads_list[2]="HTTP/1.1";
48 | }
49 | try{
50 | all_headers = req_headers.subList(1, req_headers.size());
51 | }catch (Exception ex){
52 | printErr(ex.getMessage());
53 | printErr(Arrays.toString(ex.getStackTrace()));
54 | }
55 | req_method=heads_list[0];
56 | }else{
57 | heads_list[0] ="GET";
58 | heads_list[1] ="/";
59 | heads_list[2]="HTTP/1.1";
60 | }
61 | if(all_headers.isEmpty()){
62 | requests_raw = req_method+" "+heads_list[1]+" "+heads_list[2]+"\r\n\r\n"+req_body;
63 | }else{
64 | requests_raw = req_method+" "+heads_list[1]+" "+heads_list[2]+"\r\n"+String.join("\r\n", all_headers)+"\r\n\r\n"+req_body;
65 | }
66 |
67 | // 初始化一个信任所有证书的 SSLContext
68 | // SSLContext sslContext = createUnsafeSSLContext();
69 | // HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
70 | // 创建 URL 对象
71 | URL url = new URL(url_str);
72 |
73 | // 打开连接
74 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
75 |
76 | // 设置请求方法为 POST
77 | connection.setRequestMethod(req_method);
78 | // 设置允许输出
79 | connection.setDoOutput(true);
80 | // 设置请求头
81 | for (String single_heade :all_headers ){
82 | String[] temp_header = single_heade.split(":");
83 | if(temp_header.length==2){
84 | connection.setRequestProperty(temp_header[0],temp_header[1]);
85 | } else if (temp_header.length==1) {
86 | connection.setRequestProperty(temp_header[0],"");
87 | }
88 | }
89 | // String requests_raw = req_method+" "+url.getPath()+" HTTP/1.1\r\n"+String.join("\r\n", req_headers);;
90 | // 写入请求体
91 | try (OutputStream out = connection.getOutputStream()) {
92 | out.write(req_body.getBytes(StandardCharsets.UTF_8));
93 | }
94 | // 获取响应状态码
95 | // int responseCode = connection.getResponseCode();
96 | // 读取响应
97 | List response_header = new ArrayList<>();
98 | for (String key : connection.getHeaderFields().keySet()) {
99 | // if(!Objects.equals(key, "Accept-Ranges")) {
100 | if (key == null) {
101 | if(connection.getHeaderField(null).startsWith("HTTP/")){
102 | response_header.add(0, connection.getHeaderField(null));
103 | }else{
104 | response_header.add(connection.getHeaderField(null));
105 | }
106 | } else {
107 | response_header.add(key + ": " + connection.getHeaderField(key));
108 | }
109 | // }
110 | }
111 | String response_header_str = String.join("\r\n",response_header);
112 | StringBuilder response_body = new StringBuilder();
113 | try (InputStream in = connection.getInputStream();
114 | BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
115 | String bodyLine;
116 | while ((bodyLine = reader.readLine()) != null) {
117 | response_body.append(bodyLine);
118 | }
119 | }catch (Exception e)
120 | {
121 | if(connection.getResponseCode()==HttpURLConnection.HTTP_NOT_FOUND){
122 |
123 | }else{
124 | printErr(e.getMessage());
125 | printErr(Arrays.toString(e.getStackTrace()));
126 | }
127 |
128 | }
129 | // 关闭连接
130 | connection.disconnect();
131 | return new IHttpRequestResponse() {
132 | @Override
133 | public byte[] getRequest() {
134 | return requests_raw.getBytes();
135 | }
136 |
137 | @Override
138 | public void setRequest(byte[] bytes) {
139 |
140 | }
141 |
142 | @Override
143 | public byte[] getResponse() {
144 | return (response_header_str+"\r\n\r\n"+response_body).getBytes();
145 | }
146 |
147 | @Override
148 | public void setResponse(byte[] bytes) {
149 |
150 | }
151 |
152 | @Override
153 | public String getComment() {
154 | return null;
155 | }
156 |
157 | @Override
158 | public void setComment(String s) {
159 |
160 | }
161 |
162 | @Override
163 | public String getHighlight() {
164 | return null;
165 | }
166 |
167 | @Override
168 | public void setHighlight(String s) {
169 |
170 | }
171 |
172 | @Override
173 | public IHttpService getHttpService() {
174 | return new IHttpService() {
175 | @Override
176 | public String getHost() {
177 | return url.getHost();
178 | }
179 |
180 | @Override
181 | public int getPort() {
182 | // if (port == -1) {
183 | // if(Objects.equals(url.getProtocol(), "https")){
184 | // port=443;
185 | // }else{
186 | // port=80;
187 | // }
188 | // }
189 | return url.getPort();
190 | }
191 |
192 | @Override
193 | public String getProtocol() {
194 | return url.getProtocol();
195 | }
196 | };
197 | }
198 |
199 | @Override
200 | public void setHttpService(IHttpService iHttpService) {
201 |
202 | }
203 | };
204 | } catch (IOException e) {
205 | printErr(Arrays.toString(e.getStackTrace()));
206 | printErr(e.getMessage());
207 | }
208 | return null;
209 | }
210 | /**
211 | * 创建一个信任所有证书的 SSLContext。
212 | *
213 | * @return SSLContext
214 | * @throws NoSuchAlgorithmException 如果算法不存在
215 | * @throws KeyManagementException 如果密钥管理器初始化失败
216 | */
217 | private static SSLContext createUnsafeSSLContext() throws NoSuchAlgorithmException, KeyManagementException {
218 | // 创建一个信任所有证书的信任管理器
219 | TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
220 | @Override
221 | public void checkClientTrusted(X509Certificate[] chain, String authType) {
222 | // 信任所有客户端证书
223 | }
224 |
225 | @Override
226 | public void checkServerTrusted(X509Certificate[] chain, String authType) {
227 | // 信任所有服务器证书
228 | }
229 |
230 | @Override
231 | public X509Certificate[] getAcceptedIssuers() {
232 | return null;
233 | }
234 | }};
235 |
236 | // 使用信任所有证书的信任管理器初始化 SSLContext
237 | SSLContext sslContext = SSLContext.getInstance("TLS");
238 | sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
239 | return sslContext;
240 | }
241 | public static String get_host_ico_http_requests(String urlpath) throws IOException, NoSuchAlgorithmException, KeyManagementException {
242 |
243 |
244 | // 初始化一个信任所有证书的 SSLContext
245 | SSLContext sslContext = createUnsafeSSLContext();
246 | HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
247 | // 创建URL对象
248 | URL url = new URL(urlpath);
249 | // 打开连接
250 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
251 | // 设置请求方法为GET
252 | connection.setRequestMethod("GET");
253 | // 设置是否允许输入输出流
254 | connection.setDoInput(true);
255 | connection.setDoOutput(false);
256 | // int responseCode ;
257 | // try{
258 | // responseCode = connection.getResponseCode();
259 | // }catch (Exception ex) {
260 | // printErr("send_http_get Error:"+urlpath+" "+ex.getMessage());
261 | // return "";
262 | // }
263 | StringBuilder content = new StringBuilder();
264 | if(connection.getResponseCode()==HttpURLConnection.HTTP_OK){
265 | // 读取响应
266 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
267 | String inputLine;
268 | content = new StringBuilder();
269 | while ((inputLine = in.readLine()) != null) {
270 | content.append(inputLine);
271 | }
272 | in.close();
273 | connection.disconnect();
274 | }else{
275 | return "";
276 | }
277 | return content.toString();
278 | }
279 | }
--------------------------------------------------------------------------------
/src/main/java/burp/utils/Group.java:
--------------------------------------------------------------------------------
1 | package burp.utils;
2 | import burp.IHttpRequestResponse;
3 | import burp.IResponseInfo;
4 | import burp.Main_Vuln;
5 | import burp.model.group.GroupEntry;
6 | import burp.model.poc.PocEntry;
7 | import com.google.common.hash.Hashing;
8 | import com.google.gson.Gson;
9 | import com.google.gson.reflect.TypeToken;
10 | import javax.swing.*;
11 | import javax.swing.border.EmptyBorder;
12 | import java.awt.*;
13 | import java.awt.event.KeyAdapter;
14 | import java.awt.event.KeyEvent;
15 | import java.io.IOException;
16 | import java.lang.reflect.Type;
17 | import java.net.URL;
18 | import java.nio.charset.StandardCharsets;
19 | import java.security.KeyManagementException;
20 | import java.security.NoSuchAlgorithmException;
21 | import java.sql.Connection;
22 | import java.sql.DriverManager;
23 | import java.sql.PreparedStatement;
24 | import java.sql.SQLException;
25 | import java.util.Arrays;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.Objects;
29 | import java.util.regex.Matcher;
30 | import java.util.regex.Pattern;
31 |
32 | import static burp.BurpExtender.helpers;
33 | import static burp.Main_Vuln.*;
34 | import static burp.utils.Conn.get_requests_response_head_body;
35 | import static burp.utils.Conn.get_requests_url;
36 | import static burp.utils.CustHttpService.get_host_ico_http_requests;
37 | import static burp.utils.Poc.Add_Component;
38 | import static burp.utils.Poc.countString;
39 |
40 | public class Group {
41 | public static void Add_Group(String name,String type) {
42 | List result = get_group_by_name(name,type);
43 | if(!result.isEmpty()){
44 | return;
45 | }
46 | int last_id;
47 | // 获取最后一个元素
48 | if (model_group.getRowCount()>0) {
49 | List all_value = model_group.getAllValue();
50 | last_id = all_value.get(all_value.size() - 1).id+1;
51 | } else {
52 | last_id=1;
53 | }
54 | GroupEntry _Data = new GroupEntry(last_id,name,type,true,false);
55 | Group.Save_Group_Data(_Data);
56 | }
57 |
58 |
59 |
60 | public static String delete_Group_data(GroupEntry temp) {
61 | String sql = "delete from `group` where id = "+temp.id;
62 | return Sql.Delete(sql);
63 | }
64 |
65 | public static void reload_read_group_Data() throws SQLException {
66 | model_group.ClearData();
67 | model_group.fireTableDataChanged();
68 | String sql = "select * from `group`";
69 | List