2024-05-06 12:56:56 +08:00
|
|
|
package hae.instances.editor;
|
|
|
|
|
|
|
|
|
|
import burp.api.montoya.MontoyaApi;
|
2024-05-09 13:32:22 +08:00
|
|
|
import burp.api.montoya.core.ByteArray;
|
|
|
|
|
import burp.api.montoya.core.Range;
|
2024-05-06 12:56:56 +08:00
|
|
|
import burp.api.montoya.http.message.HttpRequestResponse;
|
|
|
|
|
import burp.api.montoya.http.message.responses.HttpResponse;
|
2024-05-12 19:02:38 +08:00
|
|
|
import burp.api.montoya.ui.Selection;
|
2024-05-06 12:56:56 +08:00
|
|
|
import burp.api.montoya.ui.editor.extension.EditorCreationContext;
|
|
|
|
|
import burp.api.montoya.ui.editor.extension.ExtensionProvidedHttpResponseEditor;
|
|
|
|
|
import burp.api.montoya.ui.editor.extension.HttpResponseEditorProvider;
|
|
|
|
|
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 ResponseEditor implements HttpResponseEditorProvider {
|
|
|
|
|
private final MontoyaApi api;
|
|
|
|
|
|
|
|
|
|
public ResponseEditor(MontoyaApi api) {
|
|
|
|
|
this.api = api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ExtensionProvidedHttpResponseEditor provideHttpResponseEditor(EditorCreationContext editorCreationContext) {
|
|
|
|
|
return new Editor(api, editorCreationContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Editor implements ExtensionProvidedHttpResponseEditor {
|
|
|
|
|
private final MontoyaApi api;
|
|
|
|
|
private final EditorCreationContext creationContext;
|
|
|
|
|
private final MessageProcessor messageProcessor;
|
|
|
|
|
private HttpRequestResponse requestResponse;
|
|
|
|
|
|
2024-05-12 19:02:38 +08:00
|
|
|
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
2024-05-06 12:56:56 +08:00
|
|
|
|
2024-05-12 19:02:38 +08:00
|
|
|
public Editor(MontoyaApi api, EditorCreationContext creationContext) {
|
2024-05-06 12:56:56 +08:00
|
|
|
this.api = api;
|
|
|
|
|
this.creationContext = creationContext;
|
|
|
|
|
this.messageProcessor = new MessageProcessor(api);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public HttpResponse getResponse() {
|
|
|
|
|
return requestResponse.response();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setRequestResponse(HttpRequestResponse requestResponse) {
|
|
|
|
|
this.requestResponse = requestResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public synchronized boolean isEnabledFor(HttpRequestResponse requestResponse) {
|
|
|
|
|
HttpResponse request = requestResponse.response();
|
|
|
|
|
if (request != null && !request.bodyToString().equals("Loading...")) {
|
|
|
|
|
List<Map<String, String>> result = messageProcessor.processResponse("", request, 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|