Skip to content

Commit

Permalink
Add EditorView for WebSocket messages containing JWTs.
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphFlynn committed Aug 2, 2024
1 parent 23f0eb7 commit 38cfbb1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/burp/JWTEditorExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.blackberry.jwteditor.view.SuiteView;
import com.blackberry.jwteditor.view.editor.HttpRequestEditorView;
import com.blackberry.jwteditor.view.editor.HttpResponseEditorView;
import com.blackberry.jwteditor.view.editor.WebSocketEditorView;
import com.blackberry.jwteditor.view.rsta.RstaFactory;

import java.awt.*;
Expand Down Expand Up @@ -91,6 +92,18 @@ public void initialize(MontoyaApi api) {
)
);

userInterface.registerWebSocketMessageEditorProvider(editorCreationContext ->
new WebSocketEditorView(
presenters,
rstaFactory,
api.logging(),
api.userInterface(),
api.collaborator().defaultPayloadGenerator(),
editorCreationContext.editorMode() != READ_ONLY,
isProVersion
)
);

Proxy proxy = api.proxy();
ProxyConfig proxyConfig = burpConfig.proxyConfig();
ByteUtils byteUtils = api.utilities().byteUtils();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Author : Dolph Flynn
Copyright 2024 Dolph Flynn
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.blackberry.jwteditor.view.editor;

import burp.api.montoya.collaborator.CollaboratorPayloadGenerator;
import burp.api.montoya.core.ByteArray;
import burp.api.montoya.logging.Logging;
import burp.api.montoya.ui.UserInterface;
import burp.api.montoya.ui.contextmenu.WebSocketMessage;
import burp.api.montoya.ui.editor.extension.ExtensionProvidedWebSocketMessageEditor;
import com.blackberry.jwteditor.presenter.PresenterStore;
import com.blackberry.jwteditor.view.hexcodearea.HexCodeAreaFactory;
import com.blackberry.jwteditor.view.rsta.RstaFactory;
import com.blackberry.jwteditor.view.utils.ErrorLoggingActionListenerFactory;

public class WebSocketEditorView extends EditorView implements ExtensionProvidedWebSocketMessageEditor {

public WebSocketEditorView(PresenterStore presenters,
RstaFactory rstaFactory,
Logging logging,
UserInterface userInterface,
CollaboratorPayloadGenerator collaboratorPayloadGenerator,
boolean editable,
boolean isProVersion) {
super(
presenters,
rstaFactory,
new HexCodeAreaFactory(logging, userInterface),
collaboratorPayloadGenerator,
new ErrorLoggingActionListenerFactory(logging),
editable,
isProVersion
);
}

@Override
public ByteArray getMessage() {
return ByteArray.byteArray(presenter.getMessage());
}

@Override
public void setMessage(WebSocketMessage message) {
presenter.setMessage(message.payload().toString());
}

@Override
public boolean isEnabledFor(WebSocketMessage message) {
String content = message.payload().toString();
return presenter.isEnabled(content);
}
}

0 comments on commit 38cfbb1

Please sign in to comment.