Skip to content

Commit

Permalink
fix: msg_type matching was wrong in specific cases
Browse files Browse the repository at this point in the history
When searching for a request message, and having a HttpReqRes object containing both a request and a response, the match  would return true, even if the intercepted message is a response
  • Loading branch information
mattebit committed Mar 4, 2024
1 parent 2acdc0c commit 2a5aebe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tool/src/main/java/migt/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessa
}

// Check that the given message matches the message type specified in the test
boolean matchMessage = message.matches_msg_type(msg_type);
boolean matchMessage = message.matches_msg_type(msg_type, messageIsRequest);

if (matchMessage) {
// If the operation's action is an intercept
Expand Down
7 changes: 5 additions & 2 deletions tool/src/main/java/migt/HTTPReqRes.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,11 @@ public void updateHeadersWHurl() throws RuntimeException {
/**
* Function to check if the given message matches a message_type
*
* @param msg_type the message type to check against it
* @param msg_type the message type to check against it
* @param is_request tells whether the message you are checking is a request or a response
* @return true or false, if matched or not respectively
*/
public boolean matches_msg_type(MessageType msg_type) {
public boolean matches_msg_type(MessageType msg_type, boolean is_request) {
boolean matchedMessage = false;
try {
/* If the response message name is searched, the getByResponse will be true.
Expand All @@ -855,6 +856,8 @@ public boolean matches_msg_type(MessageType msg_type) {
new ArrayList<>() // TODO: fix
);
} else {
// this check is done to avoid matching request messages when intercepting a response
if (is_request != msg_type.isRequest) return false;
if (!msg_type.isRequest && !isResponse) return false; // this message is not containing a response
matchedMessage = Tools.executeChecks(
msg_type.checks,
Expand Down
2 changes: 1 addition & 1 deletion tool/src/main/java/migt/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public boolean execute(List<HTTPReqRes> messageList,
currentOP.api.vars = vars;
}

if (messageList.get(i).matches_msg_type(msg_type)) {
if (messageList.get(i).matches_msg_type(msg_type, currentOP.api.is_request)) {
currentOP.setAPI(new Operation_API(messageList.get(i), msg_type.msg_to_process_is_request));
currentOP.execute();
res = currentOP.getResult();
Expand Down
12 changes: 6 additions & 6 deletions tool/src/main/java/migt/TestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public void log_test_suite(String log_folder_path) {
e.printStackTrace();
}

String log_content_csv ="";
String log_content_csv = "";
log_content_csv += "name,description,type,result,applicable\n";
for (Test t : tests) {
log_content_csv +=
StringEscapeUtils.escapeJava(t.name.replaceAll(",","")) + "," +
StringEscapeUtils.escapeJava(t.description.replaceAll(",","")) + "," +
(t.isActive ? "active" : "passive") + "," +
t.success + "," +
t.applicable + "\n";
StringEscapeUtils.escapeJava(t.name.replaceAll(",", "")) + "," +
StringEscapeUtils.escapeJava(t.description.replaceAll(",", "")) + "," +
(t.isActive ? "active" : "passive") + "," +
t.success + "," +
t.applicable + "\n";
}

File log_suite_csv = new File(test_log_folder + "results.csv");
Expand Down

0 comments on commit 2a5aebe

Please sign in to comment.