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

Class FastJsonScan

BPScan/src/main/java/burp/scan/FastJsonScan.java:16–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14import java.util.List;
15
16public class FastJsonScan {
17 static List<String> Features = new ArrayList<>();
18 static List<String> scandone = new ArrayList<>();
19
20
21 static String ceyeDomain = YamlReader.getInstance(BurpExtender.getCallbacks()).getString("dnsLog.domain");
22 static List<String> FastJsonPayload = YamlReader.getInstance(BurpExtender.getCallbacks()).getStringList("scanModule.FastJsonScan.payload");
23
24 public synchronized static List<Object> ScanMain(IHttpRequestResponse baseRequestResponse, IBurpExtenderCallbacks callbacks, IExtensionHelpers helpers, PrintWriter stdout) throws IOException, InterruptedException {
25 Features.clear();
26 URL url = helpers.analyzeRequest(baseRequestResponse).getUrl();
27 String baseurl = url.getProtocol() + "://" + url.getAuthority();
28 if(scandone.contains(Common.MD5(baseurl))){
29 List<String> headers = helpers.analyzeRequest(baseRequestResponse).getHeaders();
30 int bodyOffset = helpers.analyzeRequest(baseRequestResponse.getRequest()).getBodyOffset();
31 String resp =new String(baseRequestResponse.getRequest());
32 String respbody = resp.substring(bodyOffset);
33 stdout.println("fastjson 测试请求包内容为:" + respbody.trim().replace("\\r",""));
34 List<String> pocs = JsonParmAddPoc(respbody.trim().replace("\\r",""));
35 if(pocs != null){
36 stdout.println("成功获取poc!");
37 for(String poc:pocs){
38 List<Object> Success = new ArrayList<>();
39 byte[] request_bodys = poc.getBytes();
40 byte[] body = helpers.buildHttpMessage(setHeader(headers), request_bodys);
41 IHttpRequestResponse requestResponse = callbacks.makeHttpRequest(baseRequestResponse.getHttpService(), body);
42 String data = Common.ceyeResult();
43 for(String randString:Features){
44 if(data.contains(randString)){
45 stdout.println("Fastjson Rce find! 匹配randString值为: " + randString);
46 scandone.add(Common.MD5(baseurl));
47 Success.add(requestResponse);
48 Success.add(randString);
49 return Success;
50 }
51 }
52 }
53 }
54 }else{
55 stdout.println(baseurl + " Fastjson rce已扫描,跳过~");
56 }
57 return null;
58 }
59
60
61 public static List<String> setHeader(List<String> headers){
62 List<String> header = headers;
63 for(int i=1;i < headers.size();i++){
64 if(headers.get(0).contains("Content-Type:")){
65 header.set(i,"Content-Type: application/json");
66 return header;
67 }
68 }
69 return header;
70 }
71
72 public static List<String> JsonParmAddPoc(String body){
73 List<String> payloads = Getpoc();

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