Skip to content

Commit

Permalink
Adding Regex Match to conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmoore-ncc2 committed Jan 10, 2019
1 parent d760d88 commit 06a38e8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/burp/Conditions/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Condition {
Expand Down Expand Up @@ -138,9 +139,9 @@ public static String[] getMatchRelationshipOptions(String inputString) {
case "Listener Port":
return new String[]{"Matches", "Does Not Match"};
case "String In Request":
return new String[]{"Matches", "Does Not Match"};
return new String[]{"Matches", "Does Not Match", "Matches Regex", "Does Not Match Regex"};
case "String In Response":
return new String[]{"Matches", "Does Not Match"};
return new String[]{"Matches", "Does Not Match", "Matches Regex", "Does Not Match Regex"};
case "Request Length":
return new String[]{"Is Greater Than", "Is Less Than", "Equals"};
case "Response Length":
Expand Down Expand Up @@ -235,17 +236,25 @@ private boolean checkStringInRequest(IHttpRequestResponse messageInfo) {
switch (this.matchRelationship) {
case "Matches":
return new String(messageInfo.getRequest()).contains(this.matchCondition);
default:
case "Does Not Match":
return !(new String(messageInfo.getRequest()).contains(this.matchCondition));
case "Matches Regex":
return Pattern.compile(this.matchCondition).matcher(new String(messageInfo.getRequest())).find();
default:
return !(Pattern.compile(this.matchCondition).matcher(new String(messageInfo.getRequest())).find());
}
}

private boolean checkStringInResponse(IHttpRequestResponse messageInfo) {
switch (this.matchRelationship) {
case "Matches":
return new String(messageInfo.getResponse()).contains(this.matchCondition);
default:
case "Does Not Match":
return !(new String(messageInfo.getResponse()).contains(this.matchCondition));
case "Matches Regex":
return Pattern.compile(this.matchCondition).matcher(new String(messageInfo.getResponse())).find();
default:
return !(Pattern.compile(this.matchCondition).matcher(new String(messageInfo.getResponse())).find());
}
}

Expand Down

0 comments on commit 06a38e8

Please sign in to comment.