diff --git a/src/main/java/controller/actionListeners/AddBulletActionListener.java b/src/main/java/controller/actionListeners/AddBulletActionListener.java index 36bb371..23b173d 100644 --- a/src/main/java/controller/actionListeners/AddBulletActionListener.java +++ b/src/main/java/controller/actionListeners/AddBulletActionListener.java @@ -32,16 +32,18 @@ public void actionPerformed(ActionEvent e){ int bulletSize = dialog.getByteSize(); if(bulletSize <= 0) return; // !!! EXIT HERE !!! - + Optional reqRespEditor = menuContext.getReqRespEditor(); - String bullet = BulletFactory.bullet(bulletSize); - HttpRequest contextReq = menuContext.getReqResp().request(); - Optional updatedReq = getRequest(contextReq, bullet); + String bullet = BulletFactory.bullet(bulletSize); + HttpRequest contextReq = menuContext.getReqResp().request(); + Optional updatedReq = getRequest(contextReq, bullet); if(updatedReq.isPresent()){ - if(_isEditorEvent() && reqRespEditor.isPresent()) // if event came from an editor then replace the request + // if event came from an editor then replace the request + if(_isEditorEvent() && reqRespEditor.isPresent()) reqRespEditor.get().setRequest(updatedReq.orElse(null)); - else // else if the event came from a viewer, then create a repeater tab + // else if the event came from a viewer, then create a repeater tab + else api.repeater().sendToRepeater(updatedReq.orElse(null)); } } diff --git a/src/main/java/controller/actionListeners/InsertBulletActionListener.java b/src/main/java/controller/actionListeners/InsertBulletActionListener.java index 434ae5d..4207181 100644 --- a/src/main/java/controller/actionListeners/InsertBulletActionListener.java +++ b/src/main/java/controller/actionListeners/InsertBulletActionListener.java @@ -52,13 +52,13 @@ public void actionPerformed(ActionEvent e){ //------------------------------------------------------------------------- public HttpRequest getRequest(MessageEditorHttpRequestResponse reqRespEditor, String bullet){ - // if selection replace selection with bullet + // if selection then replace selection with bullet if(reqRespEditor.selectionOffsets().isPresent()) { return RequestBuilder.build(reqRespEditor.requestResponse().request(), bullet, reqRespEditor.selectionOffsets().get() ); } - //else if caret insert bullet + //else if caret then insert bullet else { return RequestBuilder.build( reqRespEditor.requestResponse().request(), diff --git a/src/main/java/model/InsertPntProvider.java b/src/main/java/model/InsertPntProvider.java index 39f4cf7..36165c7 100644 --- a/src/main/java/model/InsertPntProvider.java +++ b/src/main/java/model/InsertPntProvider.java @@ -13,9 +13,9 @@ //////////////////////////////////////// public class InsertPntProvider implements AuditInsertionPointProvider{ -public InsertPntProvider(List sizes, MontoyaApi api){ +public InsertPntProvider(List sizes, MontoyaApi montoyaApi){ bulletSizes = sizes; - this.api = api; + api = montoyaApi; } @Override diff --git a/src/main/java/model/creators/RequestBuilder.java b/src/main/java/model/creators/RequestBuilder.java index ef214ab..5ebba54 100644 --- a/src/main/java/model/creators/RequestBuilder.java +++ b/src/main/java/model/creators/RequestBuilder.java @@ -2,8 +2,14 @@ import burp.api.montoya.core.Range; import burp.api.montoya.http.message.ContentType; +import burp.api.montoya.http.message.params.HttpParameter; +import burp.api.montoya.http.message.params.HttpParameterType; +import burp.api.montoya.http.message.params.ParsedHttpParameter; import burp.api.montoya.http.message.requests.HttpRequest; +import java.util.ArrayList; +import java.util.List; + //////////////////////////////////////// // CLASS RequestBuilder //////////////////////////////////////// @@ -26,7 +32,8 @@ public static HttpRequest build(HttpRequest request, String bullet, int caretPos //----------------------------------------------------------------------------- public static HttpRequest build(HttpRequest request, String bullet) { ContentType type = request.contentType(); - + + //todo: what should happen when there is a body and url parameters? switch(type){ case URL_ENCODED -> {return addBodyParam(request, bullet);} case JSON -> {return addJsonParam(request, bullet);} @@ -34,11 +41,34 @@ public static HttpRequest build(HttpRequest request, String bullet) { case MULTIPART -> {return addMultiPartParam(request, bullet);} case AMF -> {return padAmfWith(request, bullet);} case UNKNOWN -> {return bestEffort(request, bullet);} + case NONE -> {return addUrlParam(request, bullet);} default -> throw new UnsupportedOperationException("Burp was unable to identify a content type"); } } +//----------------------------------------------------------------------------- +private static HttpRequest addUrlParam(HttpRequest request, String bullet){ + int paramLen = "bullet=".length(); + HttpParameter urlParam = HttpParameter.urlParameter( + "bullet", bullet.substring(0, bullet.length() - paramLen + 1)); + + // extract all URL parameters as a list + List parsedParams = request.parameters(HttpParameterType.URL); + + // remove the parameters from the request + request = request.withRemovedParameters(parsedParams); + + // convert ParsedHttpParameter to HttpParameter + List params = new ArrayList<>(parsedParams.size() + 1); + parsedParams.forEach(p -> params.add(HttpParameter.urlParameter(p.name(), p.value()))); + + // append the `urlParam` to beginning of the list + params.add(0, urlParam); + + return request.withAddedParameters(params); +} + //----------------------------------------------------------------------------- private static HttpRequest addBodyParam(HttpRequest request, String bullet) { String param = "bullet="; @@ -130,6 +160,7 @@ private static HttpRequest padAmfWith(HttpRequest request, String bullet) { //----------------------------------------------------------------------------- private static HttpRequest bestEffort(HttpRequest request, String bullet) { + //todo: is this the best way to handle this? String strBody = request.bodyToString(); return request.withBody(bullet.concat(strBody)); } diff --git a/src/main/java/view/BulletOptionsDialog.java b/src/main/java/view/BulletOptionsDialog.java index 68652a4..d4e6a07 100644 --- a/src/main/java/view/BulletOptionsDialog.java +++ b/src/main/java/view/BulletOptionsDialog.java @@ -68,8 +68,8 @@ public int getByteSize() { private JPanel createOptionsPanel() { JPanel optionsPanel = new JPanel(); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); - - dropdown = createSizeDropdown(); + + dropdown = createSizeDropdown(); customSizeField = createCustomSizeField(); customSizeLabel = createCustomSizeLabel(); diff --git a/src/main/java/view/FerretSuiteTab.java b/src/main/java/view/FerretSuiteTab.java index a77493b..b751987 100644 --- a/src/main/java/view/FerretSuiteTab.java +++ b/src/main/java/view/FerretSuiteTab.java @@ -239,37 +239,42 @@ private JScrollPane getTablePanel() { }; // Create table model and table + JTable table = getjTable(data, columnNames); + + // Set column widths based on percentage of total table width + final int totalWidth = 1000; // Assume a total table width of 1000 pixels + table.getColumnModel().getColumn(0).setPreferredWidth((int) (totalWidth * 0.15)); // 15% + table.getColumnModel().getColumn(1).setPreferredWidth((int) (totalWidth * 0.35)); // 35% + table.getColumnModel().getColumn(2).setPreferredWidth((int) (totalWidth * 0.50)); // 50% + + // Wrap the table in a scroll pane and return it + JScrollPane scrollPane = new JScrollPane(table); + scrollPane.setPreferredSize(new Dimension(totalWidth, 400)); // Set preferred size for the scroll pane + return scrollPane; +} + +//----------------------------------------------------------------------------- +private static JTable getjTable(Object[][] data, String[] columnNames){ DefaultTableModel model = new DefaultTableModel(data, columnNames); JTable table = new JTable(model) { @Override public Class getColumnClass(int column) { return String.class; } - + @Override public boolean isCellEditable(int row, int column) { return false; // Cells are not editable } }; - + // Enable row selection table.setCellSelectionEnabled(true); table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - - // Set column widths based on percentage of total table width - final int totalWidth = 1000; // Assume a total table width of 1000 pixels - table.getColumnModel().getColumn(0).setPreferredWidth((int) (totalWidth * 0.15)); // 15% - table.getColumnModel().getColumn(1).setPreferredWidth((int) (totalWidth * 0.35)); // 35% - table.getColumnModel().getColumn(2).setPreferredWidth((int) (totalWidth * 0.50)); // 50% - - // Wrap the table in a scroll pane and return it - JScrollPane scrollPane = new JScrollPane(table); - scrollPane.setPreferredSize(new Dimension(totalWidth, 400)); // Set preferred size for the scroll pane - return scrollPane; + return table; } - } //////////////////////////////////////// // END CLASS FerretSuiteTab