diff --git a/pom.xml b/pom.xml index 668aa13..d99b44f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.anthonyhanel Firewall-Ferret - 1.2.0 + 1.2.1 17 diff --git a/src/main/java/controller/FireWallFerretController.java b/src/main/java/controller/FireWallFerretController.java index 9e5ca94..e6572d2 100644 --- a/src/main/java/controller/FireWallFerretController.java +++ b/src/main/java/controller/FireWallFerretController.java @@ -4,8 +4,8 @@ import burp.api.montoya.core.Registration; import burp.api.montoya.ui.contextmenu.InvocationType; import model.InsertPntProvider; -import model.actionListeners.AddActionListener; -import model.actionListeners.InsertActionListener; +import controller.actionListeners.AddBulletActionListener; +import controller.actionListeners.InsertBulletActionListener; import view.FerretMenuProvider; import view.FerretSuiteTab; @@ -33,7 +33,7 @@ public FireWallFerretController( ) { _api = api; _menuContext = menuContext; - _insPointProvider = new InsertPntProvider(List.of(8, 16, 32, 64, 128, 1024)); + _insPointProvider = new InsertPntProvider(List.of(8, 16, 32, 64, 128, 1024), _api); _view = view; registerMenuContext(); @@ -65,7 +65,7 @@ public void actionPerformed(ActionEvent e){ List bulletSizes = getBulletSizeList(); _insProviderReg = _api.scanner() - .registerInsertionPointProvider(new InsertPntProvider(bulletSizes)); + .registerInsertionPointProvider(new InsertPntProvider(bulletSizes, _api)); _view.setMessage("Updating Scanner bullets to: " + bulletSizes); } @@ -82,10 +82,10 @@ private void registerMenuContext() { _api.userInterface().registerContextMenuItemsProvider(_menuContext); _menuContext.addActionListenerToInsertItem( - new InsertActionListener(_api, _menuContext, replacingInvocationType)); + new InsertBulletActionListener(_api, _menuContext, replacingInvocationType)); _menuContext.addActionListenerToAddItem( - new AddActionListener(_api, _menuContext, replacingInvocationType)); + new AddBulletActionListener(_api, _menuContext, replacingInvocationType)); } //----------------------------------------------------------------------------- diff --git a/src/main/java/model/actionListeners/AbstractListeners.java b/src/main/java/controller/actionListeners/AbstractListeners.java similarity index 97% rename from src/main/java/model/actionListeners/AbstractListeners.java rename to src/main/java/controller/actionListeners/AbstractListeners.java index 4f565d8..e5e47c9 100644 --- a/src/main/java/model/actionListeners/AbstractListeners.java +++ b/src/main/java/controller/actionListeners/AbstractListeners.java @@ -1,4 +1,4 @@ -package model.actionListeners; +package controller.actionListeners; import burp.api.montoya.MontoyaApi; import burp.api.montoya.ui.contextmenu.InvocationType; diff --git a/src/main/java/model/actionListeners/AddActionListener.java b/src/main/java/controller/actionListeners/AddBulletActionListener.java similarity index 54% rename from src/main/java/model/actionListeners/AddActionListener.java rename to src/main/java/controller/actionListeners/AddBulletActionListener.java index 6037162..36bb371 100644 --- a/src/main/java/model/actionListeners/AddActionListener.java +++ b/src/main/java/controller/actionListeners/AddBulletActionListener.java @@ -1,4 +1,4 @@ -package model.actionListeners; +package controller.actionListeners; import burp.api.montoya.MontoyaApi; import burp.api.montoya.http.message.requests.HttpRequest; @@ -9,6 +9,7 @@ import view.BulletOptionsDialog; import view.FerretMenuProvider; +import javax.swing.*; import java.awt.event.ActionEvent; import java.util.List; import java.util.Optional; @@ -16,10 +17,10 @@ //////////////////////////////////////// // CLASS AddActionListener //////////////////////////////////////// -public class AddActionListener extends AbstractListeners{ +public class AddBulletActionListener extends AbstractListeners{ //------------------------------------------------------------------------- -public AddActionListener(MontoyaApi montoyaApi, FerretMenuProvider context, List type){ +public AddBulletActionListener(MontoyaApi montoyaApi, FerretMenuProvider context, List type){ super(montoyaApi, context, type); } @@ -34,18 +35,28 @@ public void actionPerformed(ActionEvent e){ Optional reqRespEditor = menuContext.getReqRespEditor(); String bullet = BulletFactory.bullet(bulletSize); - HttpRequest contextReq = menuContext.getReqResp().request(); - HttpRequest updatedReq = getRequest(contextReq, bullet); - - if(_isEditorEvent() && reqRespEditor.isPresent()) // if event came from an editor then replace the request - reqRespEditor.get().setRequest(updatedReq); - else // else if the event came from a viewer, then create a repeater tab - api.repeater().sendToRepeater(updatedReq); + 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 + reqRespEditor.get().setRequest(updatedReq.orElse(null)); + else // else if the event came from a viewer, then create a repeater tab + api.repeater().sendToRepeater(updatedReq.orElse(null)); + } } //------------------------------------------------------------------------- -public HttpRequest getRequest(HttpRequest request, String bullet){ - return RequestBuilder.build(request, bullet); +public Optional getRequest(HttpRequest request, String bullet){ + try { + return Optional.of(RequestBuilder.build(request, bullet)); + } + catch (UnsupportedOperationException e) { + api.logging().logToError(e); + api.logging().raiseErrorEvent(e.getMessage()); + JOptionPane.showMessageDialog(this.api.userInterface().swingUtils().suiteFrame(), e.getMessage()); + return Optional.empty(); + } } } diff --git a/src/main/java/model/actionListeners/InsertActionListener.java b/src/main/java/controller/actionListeners/InsertBulletActionListener.java similarity index 91% rename from src/main/java/model/actionListeners/InsertActionListener.java rename to src/main/java/controller/actionListeners/InsertBulletActionListener.java index 3eecd49..434ae5d 100644 --- a/src/main/java/model/actionListeners/InsertActionListener.java +++ b/src/main/java/controller/actionListeners/InsertBulletActionListener.java @@ -1,4 +1,4 @@ -package model.actionListeners; +package controller.actionListeners; import burp.api.montoya.MontoyaApi; import burp.api.montoya.http.message.requests.HttpRequest; @@ -16,10 +16,10 @@ //////////////////////////////////////// // CLASS InsertActionListener //////////////////////////////////////// -public class InsertActionListener extends AbstractListeners{ +public class InsertBulletActionListener extends AbstractListeners{ //------------------------------------------------------------------------- -public InsertActionListener(MontoyaApi api, FerretMenuProvider context, List type){ +public InsertBulletActionListener(MontoyaApi api, FerretMenuProvider context, List type){ super(api, context, type); } diff --git a/src/main/java/model/BulletInsertionPoint.java b/src/main/java/model/BulletInsertionPoint.java index c16d9b7..15b14c6 100644 --- a/src/main/java/model/BulletInsertionPoint.java +++ b/src/main/java/model/BulletInsertionPoint.java @@ -3,6 +3,7 @@ import burp.api.montoya.core.ByteArray; import burp.api.montoya.core.Range; import burp.api.montoya.http.message.requests.HttpRequest; +import burp.api.montoya.logging.Logging; import burp.api.montoya.scanner.audit.insertionpoint.AuditInsertionPoint; import model.creators.BulletFactory; import model.creators.RequestBuilder; @@ -15,10 +16,11 @@ public class BulletInsertionPoint implements AuditInsertionPoint{ //----------------------------------------------------------------------------- -public BulletInsertionPoint(HttpRequest request, int kilobytes){ +public BulletInsertionPoint(HttpRequest request, int kilobytes, Logging logging){ _request = request; _baseValue = BulletFactory.bullet(kilobytes * 1024); _name = String.valueOf(kilobytes).concat("kb Bullet Insertion Point"); + _logging = logging; } //----------------------------------------------------------------------------- @@ -40,7 +42,10 @@ public HttpRequest buildHttpRequestWithPayload(ByteArray payload){ try { updatedReq = RequestBuilder.build(_request, _baseValue.concat(payload.toString())); } - catch(UnsupportedOperationException ignored) {} + catch(UnsupportedOperationException e) { + _logging.raiseErrorEvent(e.getMessage()); + _logging.logToError(e); + } return updatedReq; } @@ -54,6 +59,7 @@ public List issueHighlights(ByteArray payload){ private final String _name; private final HttpRequest _request; private final String _baseValue; +private final Logging _logging; } //////////////////////////////////////// // END CLASS BulletInsertionPoint diff --git a/src/main/java/model/InsertPntProvider.java b/src/main/java/model/InsertPntProvider.java index b0a7a2d..39f4cf7 100644 --- a/src/main/java/model/InsertPntProvider.java +++ b/src/main/java/model/InsertPntProvider.java @@ -1,5 +1,6 @@ package model; +import burp.api.montoya.MontoyaApi; import burp.api.montoya.http.message.HttpRequestResponse; import burp.api.montoya.scanner.audit.insertionpoint.AuditInsertionPoint; import burp.api.montoya.scanner.audit.insertionpoint.AuditInsertionPointProvider; @@ -12,21 +13,24 @@ //////////////////////////////////////// public class InsertPntProvider implements AuditInsertionPointProvider{ - -public InsertPntProvider(List sizes){bulletSizes = sizes;} +public InsertPntProvider(List sizes, MontoyaApi api){ + bulletSizes = sizes; + this.api = api; +} @Override public List provideInsertionPoints(HttpRequestResponse baseHttpReqResp){ List insPoints = new ArrayList<>(bulletSizes.size()); for(Integer size : bulletSizes) { - insPoints.add(new BulletInsertionPoint(baseHttpReqResp.request(), size)); + insPoints.add(new BulletInsertionPoint(baseHttpReqResp.request(), size, api.logging())); } return insPoints; } private final List bulletSizes; +private final MontoyaApi api; } //////////////////////////////////////// diff --git a/src/main/java/model/creators/RequestBuilder.java b/src/main/java/model/creators/RequestBuilder.java index 726c053..ef214ab 100644 --- a/src/main/java/model/creators/RequestBuilder.java +++ b/src/main/java/model/creators/RequestBuilder.java @@ -123,7 +123,9 @@ private static String extractBoundary(String request) { //----------------------------------------------------------------------------- private static HttpRequest padAmfWith(HttpRequest request, String bullet) { - return request; + throw new UnsupportedOperationException( + "AMF Padding in not yet supported. See https://github.com/ahanel13/Firewall-Ferret/issues/1" + + " for more information and or to contribute to the project."); } //-----------------------------------------------------------------------------