MCPcopy Index your code
hub / github.com/API-Security/APIKit / processHttpMessage

Method processHttpMessage

src/main/java/burp/CookieManager.java:95–123  ·  view source on GitHub ↗
(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)

Source from the content-addressed store, hash-verified

93 }
94
95 @Override
96 public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
97 if (messageIsRequest) {
98 // 更新 Cookie, 目前只实现了增加, 没有做删除的逻辑
99
100 IRequestInfo requestInfo = BurpExtender.getHelpers().analyzeRequest(messageInfo);
101 String origin = this.urlToOrigin(requestInfo.getUrl());
102 List<String> headers = requestInfo.getHeaders();
103
104 // 找到所有的 Cookie Header
105 List<String> cookies = headers.subList(1, headers.size()).stream().filter(
106 header -> "cookie".equalsIgnoreCase(header.split(":", 2)[0])
107 ).collect(Collectors.toList());
108
109 for (String cookieHeader : cookies) {
110 String[] temp = cookieHeader.split(":", 2);
111 if (temp.length == 2) {
112 HashMap<String, String> cookie = this.parseCookie(temp[1]);
113
114 // 合并 Cookie
115 if (this.cookies.get(origin) == null) {
116 this.cookies.put(origin, cookie);
117 } else {
118 this.cookies.get(origin).putAll(cookie);
119 }
120 }
121 }
122 }
123 }
124
125 public String getCookieHeader(URL url) {
126 HashMap<String, String> cookie = this.cookies.get(this.urlToOrigin(url));

Callers

nothing calls this directly

Calls 5

getHelpersMethod · 0.95
urlToOriginMethod · 0.95
parseCookieMethod · 0.95
getMethod · 0.80
getUrlMethod · 0.45

Tested by

no test coverage detected