Closed Nzoth9 closed 1 year ago
This doesn't seem to be an issue with the Montoya API. In addition, there is some progress, so I close it. Sorry for the fuss.
Sorry for reopening this issue.
I am trying to get all the matched parts as follows and get the index value with the indexOf
function.
if(responseReceived.inferredMimeType().toString() == "HTML") {
List<String> matches = new ArrayList<>();
String content = null;
try {
content = new String(responseReceived.body().getBytes(), "utf-8");
Pattern pattern = Pattern.compile("<!--.*?-->", Pattern.DOTALL | Pattern.MULTILINE);
Matcher matcher = pattern.matcher(content);
while(matcher.find()) { matches.add(matcher.group()); }
} catch (UnsupportedEncodingException e) {
this.api.logging().logToError(e.toString());
}
for(int index=0; index<matches.size(); index++) {
this.logging.logToOutput(matches.get(index));
this.logging.logToOutput(String.format("%d", content.indexOf(index)));
}
} else {
return continueWith(responseReceived);
}
But maybe because of the encoding, only -1
is output.
Is there a function that can solve the encoding?
When you are using content.indexOf(index)
, you are looking for the first instance of index
, which is a number.
Are you sure you don't want to be getting indexOf(matches.get(index))
?
Hi, @Hannah-PortSwigger, Thank you for reply <3
Hi, Burp Team! How are you? I'm making a custom extension. What I want to do is modify
HttpHandler
to remove all comments in HTML.The following is a part of
MyHttpHandler.java
.Then it will output like this.
However, Java for testing matches well, as follows:
I think it's because of my lack of JAVA skills. All annotations are not imported. Do you know a good way? Have a good day! <3