MCPcopy Create free account
hub / github.com/EASY233/BpScan / Log4jScan

Class Log4jScan

BPScan/src/main/java/burp/scan/Log4jScan.java:21–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19import java.util.List;
20
21public class Log4jScan {
22 static PrintWriter stdout;
23 static List<String> Features = new ArrayList<>();
24 static String ceyeDomain = YamlReader.getInstance(BurpExtender.getCallbacks()).getString("dnsLog.domain");
25 static List<String> Log4jScanHeaders = YamlReader.getInstance(BurpExtender.getCallbacks()).getStringList("scanModule.Log4jScan.ScanHeader");
26 static List<String> scandone = new ArrayList<>();
27
28 public synchronized static List<Object> ScanMain(IHttpRequestResponse baseRequestResponse, IBurpExtenderCallbacks callbacks, IExtensionHelpers helpers, PrintWriter out) throws IOException, InterruptedException {
29 stdout = out;
30 Features.clear();
31 URL url = helpers.analyzeRequest(baseRequestResponse).getUrl();
32 String baseurl = url.getProtocol() + "://" + url.getAuthority();
33 if(!scandone.contains(Common.MD5(baseurl))){
34 stdout.println("Log4j Rce Scan Start!");
35 List<Object> Success = new ArrayList<>();
36 List<String> headers = helpers.analyzeRequest(baseRequestResponse).getHeaders();
37 int size = headers.size();
38 String methond = helpers.analyzeRequest(baseRequestResponse).getMethod();;
39 //对head头添加poc
40 for(int i=0;i<size;i++){
41 String header = headers.get(i).split(":")[0];
42 if(Log4jScanHeaders.contains(header)){
43 String poc = header + ": " + Getpoc(false);
44 headers.set(i,poc);
45 }
46 }
47 //无论什么请求都有可能有?参数先直接进行处理
48 headers.set(0,ParamAddPocGet(headers.get(0)));
49 if(!methond.toLowerCase().equals("post")){
50 byte[] body = helpers.buildHttpMessage(headers, null);
51 IHttpRequestResponse requestResponse = callbacks.makeHttpRequest(baseRequestResponse.getHttpService(), body);
52 String data = Common.ceyeResult();
53 for(String randString:Features){
54 if(data.contains(randString)){
55 stdout.println("Log4j Rce find! 匹配randString值为: " + randString);
56 scandone.add(Common.MD5(baseurl));
57 Success.add(requestResponse);
58 Success.add(randString);
59 return Success;
60 }
61 }
62 }else{
63 int bodyOffset = helpers.analyzeRequest(baseRequestResponse.getRequest()).getBodyOffset();
64 String resp =new String(baseRequestResponse.getRequest());
65 String respbody = resp.substring(bodyOffset);
66 byte[] request_bodys = ParamAddPocPost(respbody).getBytes();
67 byte[] body = helpers.buildHttpMessage(headers, request_bodys);
68 IHttpRequestResponse requestResponse = callbacks.makeHttpRequest(baseRequestResponse.getHttpService(), body);
69 String data = Common.ceyeResult();
70 for(String randString:Features){
71 if(data.contains(randString)){
72 stdout.println("Log4j Rce find! 匹配randString值为: " + randString);
73 scandone.add(Common.MD5(baseurl));
74 Success.add(requestResponse);
75 Success.add(randString);
76 return Success;
77 }
78 }

Callers

nothing calls this directly

Calls 4

getInstanceMethod · 0.95
getCallbacksMethod · 0.95
getStringMethod · 0.80
getStringListMethod · 0.80

Tested by

no test coverage detected