MCPcopy Index your code
hub / github.com/TheKingOfDuck/Copy2Java / deal

Method deal

src/main/java/burp/requestMapper.java:5–86  ·  view source on GitHub ↗
(String req)

Source from the content-addressed store, hash-verified

3public class requestMapper {
4
5 public static String deal(String req) {
6
7 String reqMethod = null;
8 String host = null;
9 String reqPath = null;
10 String reqUrl = null;
11 String headerStr = "";
12 String postData = null;
13
14 //处理传入的请求信息
15 for (String header:req.split("\n")) {
16 //System.out.println(header);
17 String[] headers = header.split(": ");
18 if (headers.length == 2){
19 if (headers[0].equals("Host")){
20 host = headers[1];
21 //System.out.println(host);
22 }else {
23 headerStr += String.format("\n Headers.put(\"%s\",\"%s\");",headers[0],headers[1].replace("\n","").replace("\r",""));
24
25 }
26 }else if(header.contains("HTTP/")){
27 reqMethod = header.split(" ")[0].toLowerCase();
28 //System.out.println(host);
29 reqPath = header.split(" ")[1];
30 }else if(!header.contains("HTTP/")){
31 postData = header.toString();
32 }
33 }
34
35 reqUrl = String.format("http://%s%s",host,reqPath);
36
37 System.out.println(reqMethod + "\t" + reqUrl + "\t" + postData);
38
39 String template = "package thekingofduck;\n" +
40 "\n" +
41 "import com.github.kevinsawicki.http.HttpRequest;\n" +
42 "import java.util.HashMap;\n" +
43 "import java.util.Map;\n" +
44 "\n" +
45 "public class AcmesecTeam {\n" +
46 " public static void setProxy(boolean proxy) {\n" +
47 " if (proxy){\n" +
48 " HttpRequest.proxyHost(\"127.0.0.1\");\n" +
49 " HttpRequest.proxyPort(8080);\n" +
50 " }\n" +
51 " }\n" +
52 "\n" +
53 " public static void main(String[] args) {\n" +
54 "\n" +
55 " setProxy(false);\n" +
56 "\n" +
57 " Map<String,String> Headers=new HashMap<String,String>();\n" +
58 "{headerStr}" +
59 "\n" +
60 " String Url= \"{reqUrl}\";\n" +
61 " String Data = \"{postData}\";\n" +
62 "\n" +

Callers 1

actionPerformedMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected