2024-05-06 12:56:56 +08:00
|
|
|
package hae.instances.editor;
|
|
|
|
|
|
|
|
|
|
import burp.api.montoya.MontoyaApi;
|
|
|
|
|
import burp.api.montoya.core.ByteArray;
|
|
|
|
|
import burp.api.montoya.core.Range;
|
|
|
|
|
import burp.api.montoya.ui.Selection;
|
|
|
|
|
import burp.api.montoya.ui.contextmenu.WebSocketMessage;
|
2024-05-12 19:02:38 +08:00
|
|
|
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
|
|
|
|
import burp.api.montoya.ui.editor.extension.ExtensionProvidedWebSocketMessageEditor;
|
|
|
|
|
import burp.api.montoya.ui.editor.extension.WebSocketMessageEditorProvider;
|
2024-05-06 12:56:56 +08:00
|
|
|
import hae.component.board.Datatable;
|
|
|
|
|
import hae.instances.http.utils.MessageProcessor;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class WebSocketEditor implements WebSocketMessageEditorProvider {
|
|
|
|
|
private final MontoyaApi api;
|
|
|
|
|
|
|
|
|
|
public WebSocketEditor(MontoyaApi api) {
|
|
|
|
|
this.api = api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ExtensionProvidedWebSocketMessageEditor provideMessageEditor(EditorCreationContext editorCreationContext) {
|
|
|
|
|
return new Editor(api, editorCreationContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Editor implements ExtensionProvidedWebSocketMessageEditor {
|
|
|
|
|
private final MontoyaApi api;
|
|
|
|
|
private final EditorCreationContext creationContext;
|
|
|
|
|
private final MessageProcessor messageProcessor;
|
|
|
|
|
private ByteArray message;
|
|
|
|
|
|
2024-05-12 19:02:38 +08:00
|
|
|
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
2024-05-06 12:56:56 +08:00
|
|
|
|
|
|
|
|
public Editor(MontoyaApi api, EditorCreationContext creationContext) {
|
|
|
|
|
this.api = api;
|
|
|
|
|
this.creationContext = creationContext;
|
|
|
|
|
this.messageProcessor = new MessageProcessor(api);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ByteArray getMessage() {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setMessage(WebSocketMessage webSocketMessage) {
|
|
|
|
|
this.message = webSocketMessage.payload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isEnabledFor(WebSocketMessage webSocketMessage) {
|
|
|
|
|
String websocketMessage = webSocketMessage.payload().toString();
|
|
|
|
|
if (!websocketMessage.isEmpty()) {
|
|
|
|
|
List<Map<String, String>> result = messageProcessor.processMessage("", websocketMessage, false);
|
2024-05-09 13:32:22 +08:00
|
|
|
RequestEditor.generateTabbedPaneFromResultMap(api, jTabbedPane, result);
|
2024-05-06 12:56:56 +08:00
|
|
|
return jTabbedPane.getTabCount() > 0;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String caption() {
|
|
|
|
|
return "MarkInfo";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Component uiComponent() {
|
|
|
|
|
return jTabbedPane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Selection selectedData() {
|
|
|
|
|
return new Selection() {
|
|
|
|
|
@Override
|
|
|
|
|
public ByteArray contents() {
|
2024-05-09 13:32:22 +08:00
|
|
|
Datatable dataTable = (Datatable) jTabbedPane.getSelectedComponent();
|
|
|
|
|
return ByteArray.byteArray(dataTable.getSelectedDataAtTable(dataTable.getDataTable()));
|
2024-05-06 12:56:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Range offsets() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isModified() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|