11package com .chave .handler ;
22
3+ import burp .api .montoya .core .ToolType ;
34import burp .api .montoya .http .handler .*;
45import burp .api .montoya .http .message .requests .HttpRequest ;
56import burp .api .montoya .logging .Logging ;
@@ -26,43 +27,43 @@ public APIHighLighterHandler() {
2627 @ Override
2728 public RequestToBeSentAction handleHttpRequestToBeSent (HttpRequestToBeSent requestToBeSent ) {
2829 try {
29- HashMap apiMatchResult = Util .getAPIMatchResult (requestToBeSent );
30- boolean isMatched = (boolean ) apiMatchResult .get ("isMatched" );
31- APIItem matchedItem = (APIItem ) apiMatchResult .get ("api" );
32-
33- if (isMatched ) {
34- // 添加到arraylist中 为了检查对应response
35- if (messageIdList .get (requestToBeSent .messageId ()) == null ) {
36- messageIdList .put (requestToBeSent .messageId (), requestToBeSent );
37- }
38-
39- // 对匹配到的接口进行标记
40- Util .setAPIFound (matchedItem .getPath (), requestToBeSent );
41-
42- // 匹配到进行高亮处理
43- Util .setHighlightColor (requestToBeSent , Color .YELLOW );
44-
45- if (SensitiveInfoConfig .IS_CHECK_SENSITIVE_INFO ) {
46- // 只对匹配到的接口进行敏感信息检查
47- HashMap sensitiveInfoMatchResult = sensitiveInfoMatchService .sensitiveInfoMatch (requestToBeSent );
48- if (!sensitiveInfoMatchResult .isEmpty ()) {
49- // 对history进行红色高亮处理
50- Util .setHighlightColor (requestToBeSent , Color .ORANGE );
51-
52- // 标记result 存在敏感信息
53- Util .setAPIResult (APIConfig .SENSITIVE_INFO_RESULT , matchedItem .getPath (), requestToBeSent );
54-
30+ // 只监听来自proxy与repeter的流量 减小检测量
31+ if (requestToBeSent .toolSource ().isFromTool (ToolType .PROXY ) || requestToBeSent .toolSource ().isFromTool (ToolType .REPEATER )) {
32+ HashMap apiMatchResult = Util .getAPIMatchResult (requestToBeSent );
33+ boolean isMatched = (boolean ) apiMatchResult .get ("isMatched" );
34+ APIItem matchedItem = (APIItem ) apiMatchResult .get ("api" );
35+
36+ if (isMatched ) {
37+ // 添加到arraylist中 为了检查对应response
38+ if (messageIdList .get (requestToBeSent .messageId ()) == null ) {
39+ messageIdList .put (requestToBeSent .messageId (), requestToBeSent );
5540 }
56- }
5741
42+ // 对匹配到的接口进行标记
43+ Util .setAPIFound (matchedItem .getPath (), requestToBeSent );
44+
45+ // 匹配到进行高亮处理
46+ Util .setHighlightColor (requestToBeSent , Color .YELLOW );
47+
48+ if (SensitiveInfoConfig .IS_CHECK_SENSITIVE_INFO ) {
49+ // 只对匹配到的接口进行敏感信息检查
50+ HashMap sensitiveInfoMatchResult = sensitiveInfoMatchService .sensitiveInfoMatch (requestToBeSent );
51+ if (!sensitiveInfoMatchResult .isEmpty ()) {
52+ // 对history进行红色高亮处理
53+ Util .setHighlightColor (requestToBeSent , Color .ORANGE );
54+ // 标记result 存在敏感信息
55+ Util .setAPIResult (APIConfig .SENSITIVE_INFO_RESULT , matchedItem .getPath (), requestToBeSent );
56+ }
57+ }
5858
59- // 刷新列表
60- Util .flushAPIList (Main .UI .getHighlighterMainUI ().getApiTable ());
59+ // 刷新列表
60+ Util .flushAPIList (Main .UI .getHighlighterMainUI ().getApiTable ());
61+ }
6162 }
62-
6363 } catch (Exception e ) {
6464 log .logToError ("request handler异常" );
6565 }
66+
6667 return null ;
6768 }
6869
0 commit comments