MCPcopy Create free account
hub / github.com/bcvgh/daydayEXP / getFiles

Method getFiles

src/test/java/dsadas.java:102–132  ·  view source on GitHub ↗
(String dirName,HashMap header)

Source from the content-addressed store, hash-verified

100// }
101
102 public void getFiles(String dirName,HashMap header) throws UnsupportedEncodingException {
103 String Path = "https://github.com/bcvgh/daydayExp-pocs/";
104 String pocPath = Path+"tree/main/"+dirName+"/";
105 Response response = HttpTools.get(pocPath,header,"UTF-8");
106 String regex = "<script type=\"application/json\".*data-target=\"react-app.embeddedData\">(.*)</script>";
107 Pattern pattern = Pattern.compile(regex);
108 Matcher matcher = pattern.matcher(response.getText());
109 while (matcher.find()){
110 JSONObject json = JSON.parseObject(matcher.group(1));
111 JSONArray jsonArray = json.getJSONObject("payload").getJSONObject("tree").getJSONArray("items");
112 for (int i = 0 ;i<jsonArray.size();i++){
113 JSONObject a = jsonArray.getJSONObject(i);
114 String name = String.valueOf(a.get("name"));
115 Response response1 = HttpTools.get(Path+"blob/main/"+dirName+"/"+URLEncoder.encode(name,"UTF-8").replaceAll("\\+","%20"),header,"UTF-8");
116 String regex1 = "<script type=\"application/json\".*data-target=\"react-app.embeddedData\">(.*)</script>";
117 Pattern pattern1 = Pattern.compile(regex1);
118 Matcher matcher1 = pattern1.matcher(response1.getText());
119 if (matcher1.find()){
120 String pocs= "";
121 JSONObject jsonObject = JSONObject.parseObject(matcher1.group(1));
122 JSONArray jsonArray1 = jsonObject.getJSONObject("payload").getJSONObject("blob").getJSONArray("rawLines");
123 for (int s =0;s<jsonArray1.size();s++){
124 String poc = jsonArray1.getString(s);
125 pocs = pocs+poc;
126 }
127 System.out.println(pocs);
128 }
129 }
130
131 }
132 }
133
134 @Test
135 public void it() throws UnsupportedEncodingException {

Callers 1

itMethod · 0.95

Calls 2

getMethod · 0.95
getTextMethod · 0.95

Tested by

no test coverage detected