Hi
Are all parameters that you are updating present in the request?
I've tested this out with a POC extension, but all matching parameters are updated.
import burp.api.montoya.BurpExtension;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.message.params.HttpParameter;
import burp.api.montoya.http.message.requests.HttpRequest;
import burp.api.montoya.ui.contextmenu.ContextMenuEvent;
import burp.api.montoya.ui.contextmenu.ContextMenuItemsProvider;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import static burp.api.montoya.http.message.params.HttpParameter.parameter;
import static burp.api.montoya.http.message.params.HttpParameterType.BODY;
@SuppressWarnings("unused")
public class Extension implements BurpExtension
{
@Override
public void initialize(MontoyaApi montoyaApi)
{
List<HttpParameter> newBodyParams = new ArrayList<>();
newBodyParams.add(parameter("a", "b", BODY));
newBodyParams.add(parameter("b","c",BODY));
newBodyParams.add(parameter("c","d",BODY));
montoyaApi.userInterface().registerContextMenuItemsProvider(new ContextMenuItemsProvider()
{
@Override
public List<Component> provideMenuItems(ContextMenuEvent event)
{
JMenuItem menuItem = new JMenuItem("Replace parameters and output");
menuItem.addActionListener(l -> {
HttpRequest request = event.messageEditorRequestResponse().isPresent()
? event.messageEditorRequestResponse().get().requestResponse().request()
: event.selectedRequestResponses().get(0).request();
HttpRequest newRequest = request.withUpdatedParameters(newBodyParams);
montoyaApi.logging().logToOutput(newRequest.toString());
});
return List.of(menuItem);
}
});
}
}
Example request:
GET / HTTP/2
Host: portswigger-labs.net
Accept-Encoding: gzip, deflate, br
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.127 Safari/537.36
Cache-Control: max-age=0
Content-Length: 11
a=1&b=2&c=3