From 3419753c61739d6b02163609e53082883ff4c423 Mon Sep 17 00:00:00 2001 From: vaycore Date: Tue, 7 May 2024 16:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5=20MontoyaAPI=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=8C=85=EF=BC=9B=E5=85=BC=E5=AE=B9=20HaE=203.0=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=EF=BC=9B=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E4=B8=BA=201.6.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 +- src/main/java/burp/BurpExtender.java | 2 +- .../hae/BurpCallbacksAdapter.java | 14 +- src/main/java/burp/{vaycore => }/hae/HaE.java | 98 ++++- .../burp/hae/MessageEditorController.java | 49 +++ .../java/burp/hae/montoya/MontoyaApiImpl.java | 142 ++++++++ .../hae/montoya/extension/ExtensionImpl.java | 44 +++ .../java/burp/hae/montoya/http/HttpImpl.java | 129 +++++++ .../montoya/http/HttpRequestToBeSentImpl.java | 337 ++++++++++++++++++ .../http/HttpResponseReceivedImpl.java | 271 ++++++++++++++ .../hae/montoya/http/HttpServiceImpl.java | 46 +++ .../burp/hae/montoya/logging/LoggingImpl.java | 79 ++++ .../burp/hae/montoya/proxy/ProxyImpl.java | 68 ++++ .../montoya/ui/EditorCreationContextImpl.java | 45 +++ .../hae/montoya/ui/HttpRequestEditorImpl.java | 77 ++++ .../montoya/ui/HttpResponseEditorImpl.java | 66 ++++ .../hae/montoya/ui/UserInterfaceImpl.java | 132 +++++++ .../hae/montoya/utilities/ByteUtilsImpl.java | 80 +++++ .../hae/montoya/utilities/UtilitiesImpl.java | 62 ++++ .../vaycore/onescan/common/Constants.java | 2 +- .../onescan/ui/tab/config/OtherTab.java | 2 +- 21 files changed, 1731 insertions(+), 25 deletions(-) rename src/main/java/burp/{vaycore => }/hae/BurpCallbacksAdapter.java (97%) rename src/main/java/burp/{vaycore => }/hae/HaE.java (54%) create mode 100644 src/main/java/burp/hae/MessageEditorController.java create mode 100644 src/main/java/burp/hae/montoya/MontoyaApiImpl.java create mode 100644 src/main/java/burp/hae/montoya/extension/ExtensionImpl.java create mode 100644 src/main/java/burp/hae/montoya/http/HttpImpl.java create mode 100644 src/main/java/burp/hae/montoya/http/HttpRequestToBeSentImpl.java create mode 100644 src/main/java/burp/hae/montoya/http/HttpResponseReceivedImpl.java create mode 100644 src/main/java/burp/hae/montoya/http/HttpServiceImpl.java create mode 100644 src/main/java/burp/hae/montoya/logging/LoggingImpl.java create mode 100644 src/main/java/burp/hae/montoya/proxy/ProxyImpl.java create mode 100644 src/main/java/burp/hae/montoya/ui/EditorCreationContextImpl.java create mode 100644 src/main/java/burp/hae/montoya/ui/HttpRequestEditorImpl.java create mode 100644 src/main/java/burp/hae/montoya/ui/HttpResponseEditorImpl.java create mode 100644 src/main/java/burp/hae/montoya/ui/UserInterfaceImpl.java create mode 100644 src/main/java/burp/hae/montoya/utilities/ByteUtilsImpl.java create mode 100644 src/main/java/burp/hae/montoya/utilities/UtilitiesImpl.java diff --git a/pom.xml b/pom.xml index a7d956c..e68e73b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ burp.vaycore onescan - 1.5.2 + 1.6.0 OneScan - 8 + 17 ${jdk.version} ${jdk.version} UTF-8 @@ -22,6 +22,11 @@ burp-extender-api 2.3 + + net.portswigger.burp.extensions + montoya-api + 2023.12.1 + com.google.code.gson @@ -43,7 +48,7 @@ maven-assembly-plugin - ${plugin.name}-v${version}-jdk${jdk.version} + ${plugin.name}-v${version} false jar-with-dependencies diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index db9b98e..a19bc5f 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -1,10 +1,10 @@ package burp; +import burp.hae.HaE; import burp.vaycore.common.helper.DomainHelper; import burp.vaycore.common.helper.QpsLimiter; import burp.vaycore.common.log.Logger; import burp.vaycore.common.utils.*; -import burp.vaycore.hae.HaE; import burp.vaycore.onescan.OneScan; import burp.vaycore.onescan.bean.FpData; import burp.vaycore.onescan.bean.TaskData; diff --git a/src/main/java/burp/vaycore/hae/BurpCallbacksAdapter.java b/src/main/java/burp/hae/BurpCallbacksAdapter.java similarity index 97% rename from src/main/java/burp/vaycore/hae/BurpCallbacksAdapter.java rename to src/main/java/burp/hae/BurpCallbacksAdapter.java index 6845fef..731eeda 100644 --- a/src/main/java/burp/vaycore/hae/BurpCallbacksAdapter.java +++ b/src/main/java/burp/hae/BurpCallbacksAdapter.java @@ -1,4 +1,4 @@ -package burp.vaycore.hae; +package burp.hae; import burp.*; @@ -57,12 +57,12 @@ public OutputStream getStderr() { @Override public void printOutput(String s) { - + callbacks.printOutput(s); } @Override public void printError(String s) { - + callbacks.printError(s); } @Override @@ -343,12 +343,12 @@ public void doPassiveScan(String s, int i, boolean b, byte[] bytes, byte[] bytes @Override public IHttpRequestResponse makeHttpRequest(IHttpService iHttpService, byte[] bytes) { - return null; + return this.callbacks.makeHttpRequest(iHttpService, bytes); } @Override public IHttpRequestResponse makeHttpRequest(IHttpService iHttpService, byte[] bytes, boolean b) { - return null; + return this.callbacks.makeHttpRequest(iHttpService, bytes, b); } @Override @@ -378,7 +378,7 @@ public byte[] makeHttp2Request(IHttpService iHttpService, List list @Override public boolean isInScope(URL url) { - return false; + return this.callbacks.isInScope(url); } @Override @@ -468,7 +468,7 @@ public void setProxyInterceptionEnabled(boolean b) { @Override public String[] getBurpVersion() { - return new String[0]; + return this.callbacks.getBurpVersion(); } public void setExtensionFilename(String filename) { diff --git a/src/main/java/burp/vaycore/hae/HaE.java b/src/main/java/burp/hae/HaE.java similarity index 54% rename from src/main/java/burp/vaycore/hae/HaE.java rename to src/main/java/burp/hae/HaE.java index 764e6ad..d11360c 100644 --- a/src/main/java/burp/vaycore/hae/HaE.java +++ b/src/main/java/burp/hae/HaE.java @@ -1,8 +1,24 @@ -package burp.vaycore.hae; +package burp.hae; import burp.*; +import burp.api.montoya.BurpExtension; +import burp.api.montoya.MontoyaApi; +import burp.api.montoya.core.Annotations; +import burp.api.montoya.core.ByteArray; +import burp.api.montoya.core.HighlightColor; +import burp.api.montoya.core.ToolType; +import burp.api.montoya.http.handler.RequestToBeSentAction; +import burp.api.montoya.http.handler.ResponseReceivedAction; +import burp.api.montoya.http.message.requests.HttpRequest; +import burp.api.montoya.http.message.responses.HttpResponse; +import burp.hae.montoya.MontoyaApiImpl; +import burp.hae.montoya.http.HttpImpl; +import burp.hae.montoya.http.HttpRequestToBeSentImpl; +import burp.hae.montoya.http.HttpResponseReceivedImpl; +import burp.hae.montoya.http.HttpServiceImpl; import burp.vaycore.common.helper.UIHelper; import burp.vaycore.common.log.Logger; +import burp.vaycore.common.utils.ClassUtils; import burp.vaycore.common.utils.FileUtils; import burp.vaycore.common.utils.StringUtils; import burp.vaycore.onescan.OneScan; @@ -22,6 +38,7 @@ public class HaE { private static BurpExtender sExtender; private static IBurpExtenderCallbacks sCallbacks; private static BurpCallbacksAdapter sAdapter; + private static MontoyaApi sMontoyaApi; private static IHttpListener sHttpListener; private static Component sMainUI; @@ -78,8 +95,6 @@ public static void loadPlugin(String pluginPath, LoadPluginCallback callback) { try { URL u = new File(pluginPath).toURI().toURL(); ClassLoader loader = new URLClassLoader(new URL[]{u}); - Class c = loader.loadClass("burp.BurpExtender"); - IBurpExtender extender = (IBurpExtender) c.newInstance(); sAdapter = new BurpCallbacksAdapter(sCallbacks); sAdapter.setExtensionFilename(pluginPath); // 监听 UI 组件设置(等 UI 设置之后,再对各项参数进行检测和初始化) @@ -100,7 +115,26 @@ public static void loadPlugin(String pluginPath, LoadPluginCallback callback) { Logger.info("HaE load success! info: %s", name); callback.onLoadSuccess(); }); - extender.registerExtenderCallbacks(sAdapter); + Class c; + try { + c = loader.loadClass("burp.BurpExtender"); + IBurpExtender extender = (IBurpExtender) ClassUtils.newObjectByClass(c); + if (extender != null) { + extender.registerExtenderCallbacks(sAdapter); + } else { + throw new IllegalStateException("BurpExtender load failed."); + } + } catch (ClassNotFoundException e) { + // 尝试加载 HaE 3.0 版本入口 + c = loader.loadClass("hae.HaE"); + BurpExtension extension = (BurpExtension) ClassUtils.newObjectByClass(c); + if (extension != null) { + sMontoyaApi = new MontoyaApiImpl(sAdapter); + extension.initialize(sMontoyaApi); + } else { + throw new IllegalStateException("BurpExtension load failed."); + } + } } catch (Exception e) { callback.onLoadError("HaE load exception: " + e); } @@ -125,6 +159,7 @@ public static boolean unloadPlugin() { UIHelper.refreshUI(oneScan); sHttpListener = null; sMainUI = null; + sMontoyaApi = null; sAdapter = null; System.gc(); Logger.info("HaE unload success!"); @@ -148,17 +183,56 @@ public static boolean hasInstall() { } public static void processHttpMessage(IHttpRequestResponse messageInfo) { - if (sHttpListener != null) { - byte[] response = messageInfo.getResponse(); - boolean messageIsRequest = response == null || response.length == 0; - try { - // 调用进行处理 + byte[] respRaw = messageInfo.getResponse(); + boolean messageIsRequest = respRaw == null || respRaw.length == 0; + try { + // 调用事件处理 + if (sHttpListener != null) { sHttpListener.processHttpMessage(IBurpExtenderCallbacks.TOOL_PROXY, messageIsRequest, messageInfo); - } catch (Exception e) { - // 打印HaE处理时抛出的错误(为了不影响任务面板显示的请求结果) - Logger.error("HaE plugin error: " + e); + } else if (sMontoyaApi != null) { + montoyaProcessHttpMessage(messageIsRequest, messageInfo); } + } catch (Exception e) { + // 打印HaE处理时抛出的错误(为了不影响任务面板显示的请求结果) + Logger.error("HaE plugin error: " + e); + } + } + + /** + * 使 processHttpMessage 方法兼容 MontoyaAPI + * + * @param messageIsRequest 是否只是请求 + * @param messageInfo 请求响应信息实例 + */ + private static void montoyaProcessHttpMessage(boolean messageIsRequest, IHttpRequestResponse messageInfo) { + byte[] respRaw = messageInfo.getResponse(); + HttpImpl http = (HttpImpl) sMontoyaApi.http(); + // 构建 Annotations 类 + String comment = messageInfo.getComment(); + String colorName = messageInfo.getHighlight(); + Annotations annotations = Annotations.annotations(comment, HighlightColor.highlightColor(colorName)); + // 构建 HttpRequest 类 + HttpServiceImpl service = new HttpServiceImpl(messageInfo.getHttpService()); + HttpRequest request = HttpRequest.httpRequest(service, ByteArray.byteArray(messageInfo.getRequest())); + HttpRequestToBeSentImpl sent = new HttpRequestToBeSentImpl(request, annotations, ToolType.PROXY); + // 调用 Request 事件处理 + RequestToBeSentAction sentAction = http.httpHandler().handleHttpRequestToBeSent(sent); + // 构建 HttpResponse 类 + annotations = sentAction.annotations(); + if (messageIsRequest) { + respRaw = new byte[0]; } + HttpResponse response = HttpResponse.httpResponse(ByteArray.byteArray(respRaw)); + HttpResponseReceivedImpl received = new HttpResponseReceivedImpl(request, response, + annotations, ToolType.PROXY); + // 调用 Response 事件处理 + ResponseReceivedAction receivedAction = http.httpHandler().handleHttpResponseReceived(received); + annotations = receivedAction.annotations(); + // HaE 高亮 + comment = annotations.notes(); + colorName = annotations.highlightColor().displayName().toLowerCase(); + messageInfo.setComment(comment); + messageInfo.setHighlight(colorName); } /** diff --git a/src/main/java/burp/hae/MessageEditorController.java b/src/main/java/burp/hae/MessageEditorController.java new file mode 100644 index 0000000..d810c60 --- /dev/null +++ b/src/main/java/burp/hae/MessageEditorController.java @@ -0,0 +1,49 @@ +package burp.hae; + +import burp.IHttpService; +import burp.IMessageEditorController; + +/** + * 请求响应编辑器组件的控制器 + *

+ * Created by vaycore on 2024-05-07. + */ +public class MessageEditorController implements IMessageEditorController { + + private IHttpService service; + private byte[] request; + private byte[] response; + + @Override + public IHttpService getHttpService() { + return this.service; + } + + @Override + public byte[] getRequest() { + if (this.request == null || this.request.length == 0) { + return new byte[0]; + } + return this.request; + } + + @Override + public byte[] getResponse() { + if (this.response == null || this.response.length == 0) { + return new byte[0]; + } + return this.response; + } + + public void setHttpService(IHttpService service) { + this.service = service; + } + + public void setRequest(byte[] request) { + this.request = request; + } + + public void setResponse(byte[] response) { + this.response = response; + } +} diff --git a/src/main/java/burp/hae/montoya/MontoyaApiImpl.java b/src/main/java/burp/hae/montoya/MontoyaApiImpl.java new file mode 100644 index 0000000..3f8574b --- /dev/null +++ b/src/main/java/burp/hae/montoya/MontoyaApiImpl.java @@ -0,0 +1,142 @@ +package burp.hae.montoya; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.MontoyaApi; +import burp.api.montoya.burpsuite.BurpSuite; +import burp.api.montoya.collaborator.Collaborator; +import burp.api.montoya.comparer.Comparer; +import burp.api.montoya.decoder.Decoder; +import burp.api.montoya.extension.Extension; +import burp.api.montoya.http.Http; +import burp.api.montoya.intruder.Intruder; +import burp.api.montoya.logging.Logging; +import burp.api.montoya.organizer.Organizer; +import burp.api.montoya.persistence.Persistence; +import burp.api.montoya.proxy.Proxy; +import burp.api.montoya.repeater.Repeater; +import burp.api.montoya.scanner.Scanner; +import burp.api.montoya.scope.Scope; +import burp.api.montoya.sitemap.SiteMap; +import burp.api.montoya.ui.UserInterface; +import burp.api.montoya.utilities.Utilities; +import burp.api.montoya.websocket.WebSockets; +import burp.hae.montoya.extension.ExtensionImpl; +import burp.hae.montoya.http.HttpImpl; +import burp.hae.montoya.logging.LoggingImpl; +import burp.hae.montoya.proxy.ProxyImpl; +import burp.hae.montoya.ui.UserInterfaceImpl; +import burp.hae.montoya.utilities.UtilitiesImpl; + +/** + * MontoyaAPI 接口实现 + *

+ * Created by vaycore on 2024-05-06. + */ +public class MontoyaApiImpl implements MontoyaApi { + + private final ExtensionImpl extension; + private final Http http; + private final Logging logging; + private final Proxy proxy; + private final UserInterface userInterface; + private final UtilitiesImpl utilities; + + public MontoyaApiImpl(IBurpExtenderCallbacks callbacks) { + this.extension = new ExtensionImpl(callbacks); + this.http = new HttpImpl(callbacks); + this.logging = new LoggingImpl(callbacks); + this.proxy = new ProxyImpl(callbacks); + this.userInterface = new UserInterfaceImpl(callbacks); + this.utilities = new UtilitiesImpl(callbacks); + } + + @Override + public BurpSuite burpSuite() { + return null; + } + + @Override + public Collaborator collaborator() { + return null; + } + + @Override + public Comparer comparer() { + return null; + } + + @Override + public Decoder decoder() { + return null; + } + + @Override + public Extension extension() { + return this.extension; + } + + @Override + public Http http() { + return http; + } + + @Override + public Intruder intruder() { + return null; + } + + @Override + public Logging logging() { + return this.logging; + } + + @Override + public Organizer organizer() { + return null; + } + + @Override + public Persistence persistence() { + return null; + } + + @Override + public Proxy proxy() { + return this.proxy; + } + + @Override + public Repeater repeater() { + return null; + } + + @Override + public Scanner scanner() { + return null; + } + + @Override + public Scope scope() { + return null; + } + + @Override + public SiteMap siteMap() { + return null; + } + + @Override + public UserInterface userInterface() { + return userInterface; + } + + @Override + public Utilities utilities() { + return this.utilities; + } + + @Override + public WebSockets websockets() { + return null; + } +} diff --git a/src/main/java/burp/hae/montoya/extension/ExtensionImpl.java b/src/main/java/burp/hae/montoya/extension/ExtensionImpl.java new file mode 100644 index 0000000..6e367a0 --- /dev/null +++ b/src/main/java/burp/hae/montoya/extension/ExtensionImpl.java @@ -0,0 +1,44 @@ +package burp.hae.montoya.extension; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.core.Registration; +import burp.api.montoya.extension.Extension; +import burp.api.montoya.extension.ExtensionUnloadingHandler; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class ExtensionImpl implements Extension { + + private final IBurpExtenderCallbacks callbacks; + + public ExtensionImpl(IBurpExtenderCallbacks callbacks) { + this.callbacks = callbacks; + } + + @Override + public void setName(String extensionName) { + this.callbacks.setExtensionName(extensionName); + } + + @Override + public String filename() { + return this.callbacks.getExtensionFilename(); + } + + @Override + public boolean isBapp() { + return this.callbacks.isExtensionBapp(); + } + + @Override + public void unload() { + this.callbacks.unloadExtension(); + } + + @Override + public Registration registerUnloadingHandler(ExtensionUnloadingHandler extensionUnloadingHandler) { + return null; + } +} diff --git a/src/main/java/burp/hae/montoya/http/HttpImpl.java b/src/main/java/burp/hae/montoya/http/HttpImpl.java new file mode 100644 index 0000000..b316aa3 --- /dev/null +++ b/src/main/java/burp/hae/montoya/http/HttpImpl.java @@ -0,0 +1,129 @@ +package burp.hae.montoya.http; + +import burp.IBurpExtenderCallbacks; +import burp.IExtensionHelpers; +import burp.IHttpRequestResponse; +import burp.IHttpService; +import burp.api.montoya.core.ByteArray; +import burp.api.montoya.core.Registration; +import burp.api.montoya.http.Http; +import burp.api.montoya.http.HttpMode; +import burp.api.montoya.http.HttpService; +import burp.api.montoya.http.RequestOptions; +import burp.api.montoya.http.handler.HttpHandler; +import burp.api.montoya.http.message.HttpRequestResponse; +import burp.api.montoya.http.message.requests.HttpRequest; +import burp.api.montoya.http.message.responses.HttpResponse; +import burp.api.montoya.http.message.responses.analysis.ResponseKeywordsAnalyzer; +import burp.api.montoya.http.message.responses.analysis.ResponseVariationsAnalyzer; +import burp.api.montoya.http.sessions.CookieJar; +import burp.api.montoya.http.sessions.SessionHandlingAction; + +import java.util.List; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class HttpImpl implements Http { + + private final IBurpExtenderCallbacks callbacks; + private final IExtensionHelpers helpers; + private HttpHandler httpHandler; + + public HttpImpl(IBurpExtenderCallbacks callbacks) { + this.callbacks = callbacks; + this.helpers = callbacks.getHelpers(); + } + + @Override + public Registration registerHttpHandler(HttpHandler handler) { + this.httpHandler = handler; + return new Registration() { + @Override + public boolean isRegistered() { + return HttpImpl.this.httpHandler != null; + } + + @Override + public void deregister() { + HttpImpl.this.httpHandler = null; + } + }; + } + + public HttpHandler httpHandler() { + return httpHandler; + } + + @Override + public Registration registerSessionHandlingAction(SessionHandlingAction sessionHandlingAction) { + return null; + } + + @Override + public HttpRequestResponse sendRequest(HttpRequest request) { + HttpService httpService = request.httpService(); + IHttpService service = this.helpers.buildHttpService(httpService.host(), httpService.port(), + httpService.secure()); + IHttpRequestResponse httpReqResp = this.callbacks.makeHttpRequest(service, request.toByteArray().getBytes()); + return buildHttpRequestResponse(httpReqResp); + } + + @Override + public HttpRequestResponse sendRequest(HttpRequest request, HttpMode httpMode) { + return null; + } + + @Override + public HttpRequestResponse sendRequest(HttpRequest request, HttpMode httpMode, String connectionId) { + return null; + } + + @Override + public HttpRequestResponse sendRequest(HttpRequest request, RequestOptions requestOptions) { + return null; + } + + @Override + public List sendRequests(List requests) { + return null; + } + + @Override + public List sendRequests(List requests, HttpMode httpMode) { + return null; + } + + @Override + public ResponseKeywordsAnalyzer createResponseKeywordsAnalyzer(List keywords) { + return null; + } + + @Override + public ResponseVariationsAnalyzer createResponseVariationsAnalyzer() { + return null; + } + + @Override + public CookieJar cookieJar() { + return null; + } + + /** + * 构建 Montoya 请求响应实例 + * + * @param httpReqResp 请求响应 + * @return 请求响应实例 + */ + public static HttpRequestResponse buildHttpRequestResponse(IHttpRequestResponse httpReqResp) { + HttpRequest request = HttpRequest.httpRequest(ByteArray.byteArray(httpReqResp.getRequest())); + // 可能为空 + byte[] respRaw = httpReqResp.getResponse(); + if (respRaw == null || respRaw.length == 0) { + respRaw = new byte[0]; + } + HttpResponse response = HttpResponse.httpResponse(ByteArray.byteArray(respRaw)); + return HttpRequestResponse.httpRequestResponse(request, response); + } +} diff --git a/src/main/java/burp/hae/montoya/http/HttpRequestToBeSentImpl.java b/src/main/java/burp/hae/montoya/http/HttpRequestToBeSentImpl.java new file mode 100644 index 0000000..8fea4be --- /dev/null +++ b/src/main/java/burp/hae/montoya/http/HttpRequestToBeSentImpl.java @@ -0,0 +1,337 @@ +package burp.hae.montoya.http; + +import burp.api.montoya.core.*; +import burp.api.montoya.http.HttpService; +import burp.api.montoya.http.handler.HttpRequestToBeSent; +import burp.api.montoya.http.message.ContentType; +import burp.api.montoya.http.message.HttpHeader; +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 burp.api.montoya.http.message.requests.HttpTransformation; + +import java.util.List; +import java.util.regex.Pattern; + +/** + *

+ * Created by vaycore on 2024-05-07. + */ +public class HttpRequestToBeSentImpl implements HttpRequestToBeSent { + + private final HttpRequest request; + private final Annotations annotations; + private final ToolType toolType; + + public HttpRequestToBeSentImpl(HttpRequest request, Annotations annotations, ToolType toolType) { + this.request = request; + this.annotations = annotations; + this.toolType = toolType; + } + + @Override + public int messageId() { + return 0; + } + + @Override + public Annotations annotations() { + return this.annotations; + } + + @Override + public ToolSource toolSource() { + return new ToolSource() { + @Override + public ToolType toolType() { + return HttpRequestToBeSentImpl.this.toolType; + } + + @Override + public boolean isFromTool(ToolType... toolType) { + return false; + } + }; + } + + @Override + public boolean isInScope() { + return this.request.isInScope(); + } + + @Override + public HttpService httpService() { + return this.request.httpService(); + } + + @Override + public String url() { + return this.request.url(); + } + + @Override + public String method() { + return this.request.method(); + } + + @Override + public String path() { + return this.request.path(); + } + + @Override + public String query() { + return this.request.query(); + } + + @Override + public String pathWithoutQuery() { + return this.request.pathWithoutQuery(); + } + + @Override + public String fileExtension() { + return this.request.fileExtension(); + } + + @Override + public String httpVersion() { + return this.request.httpVersion(); + } + + @Override + public List headers() { + return this.request.headers(); + } + + @Override + public boolean hasHeader(HttpHeader header) { + return this.request.hasHeader(header); + } + + @Override + public boolean hasHeader(String name) { + return this.request.hasHeader(name); + } + + @Override + public boolean hasHeader(String name, String value) { + return this.request.hasHeader(name, value); + } + + @Override + public HttpHeader header(String name) { + return this.request.header(name); + } + + @Override + public String headerValue(String name) { + return this.request.headerValue(name); + } + + @Override + public boolean hasParameters() { + return this.request.hasParameters(); + } + + @Override + public boolean hasParameters(HttpParameterType type) { + return this.request.hasParameters(type); + } + + @Override + public ParsedHttpParameter parameter(String name, HttpParameterType type) { + return this.request.parameter(name, type); + } + + @Override + public String parameterValue(String name, HttpParameterType type) { + return this.request.parameterValue(name, type); + } + + @Override + public boolean hasParameter(String name, HttpParameterType type) { + return this.request.hasParameter(name, type); + } + + @Override + public boolean hasParameter(HttpParameter parameter) { + return this.request.hasParameter(parameter); + } + + @Override + public ContentType contentType() { + return this.request.contentType(); + } + + @Override + public List parameters() { + return this.request.parameters(); + } + + @Override + public List parameters(HttpParameterType type) { + return this.request.parameters(type); + } + + @Override + public ByteArray body() { + return this.request.body(); + } + + @Override + public String bodyToString() { + return this.request.bodyToString(); + } + + @Override + public int bodyOffset() { + return this.request.bodyOffset(); + } + + @Override + public List markers() { + return this.request.markers(); + } + + @Override + public boolean contains(String searchTerm, boolean caseSensitive) { + return this.request.contains(searchTerm, caseSensitive); + } + + @Override + public boolean contains(Pattern pattern) { + return this.request.contains(pattern); + } + + @Override + public ByteArray toByteArray() { + return this.request.toByteArray(); + } + + @Override + public HttpRequest copyToTempFile() { + return this.request.copyToTempFile(); + } + + @Override + public HttpRequest withService(HttpService service) { + return this.request.withService(service); + } + + @Override + public HttpRequest withPath(String path) { + return this.request.withPath(path); + } + + @Override + public HttpRequest withMethod(String method) { + return this.request.withMethod(method); + } + + @Override + public HttpRequest withHeader(HttpHeader header) { + return this.request.withHeader(header); + } + + @Override + public HttpRequest withHeader(String name, String value) { + return this.request.withHeader(name, value); + } + + @Override + public HttpRequest withParameter(HttpParameter parameters) { + return this.request.withParameter(parameters); + } + + @Override + public HttpRequest withAddedParameters(List parameters) { + return this.request.withAddedParameters(parameters); + } + + @Override + public HttpRequest withAddedParameters(HttpParameter... parameters) { + return this.request.withAddedParameters(parameters); + } + + @Override + public HttpRequest withRemovedParameters(List parameters) { + return this.request.withRemovedParameters(parameters); + } + + @Override + public HttpRequest withRemovedParameters(HttpParameter... parameters) { + return this.request.withRemovedParameters(parameters); + } + + @Override + public HttpRequest withUpdatedParameters(List parameters) { + return this.request.withUpdatedParameters(parameters); + } + + @Override + public HttpRequest withUpdatedParameters(HttpParameter... parameters) { + return this.request.withUpdatedParameters(parameters); + } + + @Override + public HttpRequest withTransformationApplied(HttpTransformation transformation) { + return this.request.withTransformationApplied(transformation); + } + + @Override + public HttpRequest withBody(String body) { + return this.request.withBody(body); + } + + @Override + public HttpRequest withBody(ByteArray body) { + return this.request.withBody(body); + } + + @Override + public HttpRequest withAddedHeader(String name, String value) { + return this.request.withAddedHeader(name, value); + } + + @Override + public HttpRequest withAddedHeader(HttpHeader header) { + return this.request.withAddedHeader(header); + } + + @Override + public HttpRequest withUpdatedHeader(String name, String value) { + return this.request.withUpdatedHeader(name, value); + } + + @Override + public HttpRequest withUpdatedHeader(HttpHeader header) { + return this.request.withUpdatedHeader(header); + } + + @Override + public HttpRequest withRemovedHeader(String name) { + return this.request.withRemovedHeader(name); + } + + @Override + public HttpRequest withRemovedHeader(HttpHeader header) { + return this.request.withRemovedHeader(header); + } + + @Override + public HttpRequest withMarkers(List markers) { + return this.request.withMarkers(markers); + } + + @Override + public HttpRequest withMarkers(Marker... markers) { + return this.request.withMarkers(markers); + } + + @Override + public HttpRequest withDefaultHeaders() { + return this.request.withDefaultHeaders(); + } +} diff --git a/src/main/java/burp/hae/montoya/http/HttpResponseReceivedImpl.java b/src/main/java/burp/hae/montoya/http/HttpResponseReceivedImpl.java new file mode 100644 index 0000000..8d81284 --- /dev/null +++ b/src/main/java/burp/hae/montoya/http/HttpResponseReceivedImpl.java @@ -0,0 +1,271 @@ +package burp.hae.montoya.http; + +import burp.api.montoya.core.*; +import burp.api.montoya.http.handler.HttpResponseReceived; +import burp.api.montoya.http.message.Cookie; +import burp.api.montoya.http.message.HttpHeader; +import burp.api.montoya.http.message.MimeType; +import burp.api.montoya.http.message.StatusCodeClass; +import burp.api.montoya.http.message.requests.HttpRequest; +import burp.api.montoya.http.message.responses.HttpResponse; +import burp.api.montoya.http.message.responses.analysis.Attribute; +import burp.api.montoya.http.message.responses.analysis.AttributeType; +import burp.api.montoya.http.message.responses.analysis.KeywordCount; + +import java.util.List; +import java.util.regex.Pattern; + +/** + *

+ * Created by vaycore on 2024-05-07. + */ +public class HttpResponseReceivedImpl implements HttpResponseReceived { + + private final HttpRequest request; + private final HttpResponse response; + private final Annotations annotations; + private final ToolType toolType; + + public HttpResponseReceivedImpl(HttpRequest request, HttpResponse response, + Annotations annotations, ToolType toolType) { + this.request = request; + this.response = response; + this.annotations = annotations; + this.toolType = toolType; + } + + @Override + public int messageId() { + return 0; + } + + @Override + public HttpRequest initiatingRequest() { + return this.request; + } + + @Override + public Annotations annotations() { + return this.annotations; + } + + @Override + public ToolSource toolSource() { + return new ToolSource() { + @Override + public ToolType toolType() { + return HttpResponseReceivedImpl.this.toolType; + } + + @Override + public boolean isFromTool(ToolType... toolType) { + return false; + } + }; + } + + @Override + public short statusCode() { + return this.response.statusCode(); + } + + @Override + public String reasonPhrase() { + return this.response.reasonPhrase(); + } + + @Override + public boolean isStatusCodeClass(StatusCodeClass statusCodeClass) { + return this.response.isStatusCodeClass(statusCodeClass); + } + + @Override + public String httpVersion() { + return this.response.httpVersion(); + } + + @Override + public List headers() { + return this.response.headers(); + } + + @Override + public boolean hasHeader(HttpHeader header) { + return this.response.hasHeader(header); + } + + @Override + public boolean hasHeader(String name) { + return this.response.hasHeader(name); + } + + @Override + public boolean hasHeader(String name, String value) { + return this.response.hasHeader(name, value); + } + + @Override + public HttpHeader header(String name) { + return this.response.header(name); + } + + @Override + public String headerValue(String name) { + return this.response.headerValue(name); + } + + @Override + public ByteArray body() { + return this.response.body(); + } + + @Override + public String bodyToString() { + return this.response.bodyToString(); + } + + @Override + public int bodyOffset() { + return this.response.bodyOffset(); + } + + @Override + public List markers() { + return this.response.markers(); + } + + @Override + public List cookies() { + return this.response.cookies(); + } + + @Override + public Cookie cookie(String name) { + return this.response.cookie(name); + } + + @Override + public String cookieValue(String name) { + return this.response.cookieValue(name); + } + + @Override + public boolean hasCookie(String name) { + return this.response.hasCookie(name); + } + + @Override + public boolean hasCookie(Cookie cookie) { + return this.response.hasCookie(cookie); + } + + @Override + public MimeType mimeType() { + return this.response.mimeType(); + } + + @Override + public MimeType statedMimeType() { + return this.response.statedMimeType(); + } + + @Override + public MimeType inferredMimeType() { + return this.response.inferredMimeType(); + } + + @Override + public List keywordCounts(String... keywords) { + return this.response.keywordCounts(keywords); + } + + @Override + public List attributes(AttributeType... types) { + return this.response.attributes(types); + } + + @Override + public boolean contains(String searchTerm, boolean caseSensitive) { + return this.response.contains(searchTerm, caseSensitive); + } + + @Override + public boolean contains(Pattern pattern) { + return this.response.contains(pattern); + } + + @Override + public ByteArray toByteArray() { + return this.response.toByteArray(); + } + + @Override + public HttpResponse copyToTempFile() { + return this.response.copyToTempFile(); + } + + @Override + public HttpResponse withStatusCode(short statusCode) { + return this.response.withStatusCode(statusCode); + } + + @Override + public HttpResponse withReasonPhrase(String reasonPhrase) { + return this.response.withReasonPhrase(reasonPhrase); + } + + @Override + public HttpResponse withHttpVersion(String httpVersion) { + return this.response.withHttpVersion(httpVersion); + } + + @Override + public HttpResponse withBody(String body) { + return this.response.withBody(body); + } + + @Override + public HttpResponse withBody(ByteArray body) { + return this.response.withBody(body); + } + + @Override + public HttpResponse withAddedHeader(HttpHeader header) { + return this.response.withAddedHeader(header); + } + + @Override + public HttpResponse withAddedHeader(String name, String value) { + return this.response.withAddedHeader(name, value); + } + + @Override + public HttpResponse withUpdatedHeader(HttpHeader header) { + return this.response.withUpdatedHeader(header); + } + + @Override + public HttpResponse withUpdatedHeader(String name, String value) { + return this.response.withUpdatedHeader(name, value); + } + + @Override + public HttpResponse withRemovedHeader(HttpHeader header) { + return this.response.withRemovedHeader(header); + } + + @Override + public HttpResponse withRemovedHeader(String name) { + return this.response.withRemovedHeader(name); + } + + @Override + public HttpResponse withMarkers(List markers) { + return this.response.withMarkers(markers); + } + + @Override + public HttpResponse withMarkers(Marker... markers) { + return this.response.withMarkers(markers); + } +} diff --git a/src/main/java/burp/hae/montoya/http/HttpServiceImpl.java b/src/main/java/burp/hae/montoya/http/HttpServiceImpl.java new file mode 100644 index 0000000..5879730 --- /dev/null +++ b/src/main/java/burp/hae/montoya/http/HttpServiceImpl.java @@ -0,0 +1,46 @@ +package burp.hae.montoya.http; + +import burp.IHttpService; +import burp.api.montoya.http.HttpService; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class HttpServiceImpl implements HttpService { + + private final IHttpService httpService; + + public HttpServiceImpl(IHttpService httpService) { + this.httpService = httpService; + } + + @Override + public String host() { + return this.httpService.getHost(); + } + + @Override + public int port() { + return this.httpService.getPort(); + } + + @Override + public boolean secure() { + return "https".equals(httpService.getProtocol()); + } + + @Override + public String ipAddress() { + String host = httpService.getHost(); + try { + InetAddress ip = InetAddress.getByName(host); + return ip.getHostAddress(); + } catch (UnknownHostException e) { + return "0.0.0.0"; + } + } +} diff --git a/src/main/java/burp/hae/montoya/logging/LoggingImpl.java b/src/main/java/burp/hae/montoya/logging/LoggingImpl.java new file mode 100644 index 0000000..c10eb53 --- /dev/null +++ b/src/main/java/burp/hae/montoya/logging/LoggingImpl.java @@ -0,0 +1,79 @@ +package burp.hae.montoya.logging; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.logging.Logging; +import burp.vaycore.common.utils.StringUtils; + +import java.io.PrintStream; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class LoggingImpl implements Logging { + + private final IBurpExtenderCallbacks callbacks; + private final PrintStream stdOut; + private final PrintStream stdErr; + + public LoggingImpl(IBurpExtenderCallbacks callbacks) { + this.callbacks = callbacks; + this.stdOut = new PrintStream(this.callbacks.getStdout()); + this.stdErr = new PrintStream(this.callbacks.getStderr()); + } + + @Override + public PrintStream output() { + return this.stdOut; + } + + @Override + public PrintStream error() { + return this.stdErr; + } + + @Override + public void logToOutput(String message) { + this.callbacks.printOutput(message); + } + + @Override + public void logToError(String message) { + this.logToError(message, null); + } + + @Override + public void logToError(String message, Throwable cause) { + if (StringUtils.isNotEmpty(message)) { + this.callbacks.printError(message); + } + if (cause != null) { + cause.printStackTrace(this.stdErr); + } + } + + @Override + public void logToError(Throwable cause) { + this.logToError(null, cause); + } + + @Override + public void raiseDebugEvent(String message) { + + } + + @Override + public void raiseInfoEvent(String message) { + + } + + @Override + public void raiseErrorEvent(String message) { + + } + + @Override + public void raiseCriticalEvent(String message) { + + } +} diff --git a/src/main/java/burp/hae/montoya/proxy/ProxyImpl.java b/src/main/java/burp/hae/montoya/proxy/ProxyImpl.java new file mode 100644 index 0000000..4ac5095 --- /dev/null +++ b/src/main/java/burp/hae/montoya/proxy/ProxyImpl.java @@ -0,0 +1,68 @@ +package burp.hae.montoya.proxy; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.core.Registration; +import burp.api.montoya.proxy.*; +import burp.api.montoya.proxy.http.ProxyRequestHandler; +import burp.api.montoya.proxy.http.ProxyResponseHandler; +import burp.api.montoya.proxy.websocket.ProxyWebSocketCreationHandler; + +import java.util.List; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class ProxyImpl implements Proxy { + + private final IBurpExtenderCallbacks callbacks; + + public ProxyImpl(IBurpExtenderCallbacks callbacks) { + this.callbacks = callbacks; + } + + @Override + public void enableIntercept() { + + } + + @Override + public void disableIntercept() { + + } + + @Override + public List history() { + return null; + } + + @Override + public List history(ProxyHistoryFilter filter) { + return null; + } + + @Override + public List webSocketHistory() { + return null; + } + + @Override + public List webSocketHistory(ProxyWebSocketHistoryFilter filter) { + return null; + } + + @Override + public Registration registerRequestHandler(ProxyRequestHandler handler) { + return null; + } + + @Override + public Registration registerResponseHandler(ProxyResponseHandler handler) { + return null; + } + + @Override + public Registration registerWebSocketCreationHandler(ProxyWebSocketCreationHandler handler) { + return null; + } +} diff --git a/src/main/java/burp/hae/montoya/ui/EditorCreationContextImpl.java b/src/main/java/burp/hae/montoya/ui/EditorCreationContextImpl.java new file mode 100644 index 0000000..8f7eea2 --- /dev/null +++ b/src/main/java/burp/hae/montoya/ui/EditorCreationContextImpl.java @@ -0,0 +1,45 @@ +package burp.hae.montoya.ui; + +import burp.api.montoya.core.ToolSource; +import burp.api.montoya.core.ToolType; +import burp.api.montoya.ui.editor.extension.EditorCreationContext; +import burp.api.montoya.ui.editor.extension.EditorMode; + +/** + *

+ * Created by vaycore on 2024-05-07. + */ +public class EditorCreationContextImpl implements EditorCreationContext, ToolSource { + + private final ToolType type; + private final EditorMode mode; + + public EditorCreationContextImpl(ToolType type) { + this(type, EditorMode.READ_ONLY); + } + + public EditorCreationContextImpl(ToolType type, EditorMode mode) { + this.type = type; + this.mode = mode; + } + + @Override + public ToolSource toolSource() { + return this; + } + + @Override + public EditorMode editorMode() { + return this.mode; + } + + @Override + public ToolType toolType() { + return this.type; + } + + @Override + public boolean isFromTool(ToolType... toolType) { + return false; + } +} diff --git a/src/main/java/burp/hae/montoya/ui/HttpRequestEditorImpl.java b/src/main/java/burp/hae/montoya/ui/HttpRequestEditorImpl.java new file mode 100644 index 0000000..e9cbe36 --- /dev/null +++ b/src/main/java/burp/hae/montoya/ui/HttpRequestEditorImpl.java @@ -0,0 +1,77 @@ +package burp.hae.montoya.ui; + +import burp.IBurpExtenderCallbacks; +import burp.IExtensionHelpers; +import burp.IHttpService; +import burp.IMessageEditor; +import burp.api.montoya.http.HttpService; +import burp.api.montoya.http.message.requests.HttpRequest; +import burp.api.montoya.ui.Selection; +import burp.api.montoya.ui.editor.HttpRequestEditor; +import burp.hae.MessageEditorController; + +import java.awt.*; +import java.util.Optional; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class HttpRequestEditorImpl implements HttpRequestEditor { + + private final IExtensionHelpers helpers; + private final IMessageEditor editor; + private final MessageEditorController controller; + private HttpRequest request; + + public HttpRequestEditorImpl(IBurpExtenderCallbacks callbacks, MessageEditorController controller) { + this.helpers = callbacks.getHelpers(); + this.editor = callbacks.createMessageEditor(controller, false); + this.controller = controller; + } + + @Override + public HttpRequest getRequest() { + return this.request; + } + + @Override + public void setRequest(HttpRequest request) { + byte[] message = request.toByteArray().getBytes(); + HttpService service = request.httpService(); + this.request = request; + this.editor.setMessage(message, true); + // 设置 HttpServer + if (service != null) { + IHttpService httpService = this.helpers.buildHttpService(service.host(), service.port(), service.secure()); + this.controller.setHttpService(httpService); + } + this.controller.setRequest(message); + } + + @Override + public void setSearchExpression(String expression) { + + } + + @Override + public boolean isModified() { + return false; + } + + @Override + public int caretPosition() { + return 0; + } + + @Override + public Optional selection() { + int[] bounds = this.editor.getSelectionBounds(); + return Optional.of(Selection.selection(bounds[0], bounds[1])); + } + + @Override + public Component uiComponent() { + return this.editor.getComponent(); + } +} diff --git a/src/main/java/burp/hae/montoya/ui/HttpResponseEditorImpl.java b/src/main/java/burp/hae/montoya/ui/HttpResponseEditorImpl.java new file mode 100644 index 0000000..5e92827 --- /dev/null +++ b/src/main/java/burp/hae/montoya/ui/HttpResponseEditorImpl.java @@ -0,0 +1,66 @@ +package burp.hae.montoya.ui; + +import burp.IBurpExtenderCallbacks; +import burp.IMessageEditor; +import burp.api.montoya.http.message.responses.HttpResponse; +import burp.api.montoya.ui.Selection; +import burp.api.montoya.ui.editor.HttpResponseEditor; +import burp.hae.MessageEditorController; + +import java.awt.*; +import java.util.Optional; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class HttpResponseEditorImpl implements HttpResponseEditor { + + private final IMessageEditor editor; + private final MessageEditorController controller; + private HttpResponse response; + + public HttpResponseEditorImpl(IBurpExtenderCallbacks callbacks, MessageEditorController controller) { + this.editor = callbacks.createMessageEditor(controller, false); + this.controller = controller; + } + + @Override + public HttpResponse getResponse() { + return this.response; + } + + @Override + public void setResponse(HttpResponse response) { + byte[] message = response.toByteArray().getBytes(); + this.response = response; + this.editor.setMessage(message, false); + this.controller.setResponse(message); + } + + @Override + public void setSearchExpression(String expression) { + + } + + @Override + public boolean isModified() { + return false; + } + + @Override + public int caretPosition() { + return 0; + } + + @Override + public Optional selection() { + int[] bounds = this.editor.getSelectionBounds(); + return Optional.of(Selection.selection(bounds[0], bounds[1])); + } + + @Override + public Component uiComponent() { + return this.editor.getComponent(); + } +} diff --git a/src/main/java/burp/hae/montoya/ui/UserInterfaceImpl.java b/src/main/java/burp/hae/montoya/ui/UserInterfaceImpl.java new file mode 100644 index 0000000..fe4c484 --- /dev/null +++ b/src/main/java/burp/hae/montoya/ui/UserInterfaceImpl.java @@ -0,0 +1,132 @@ +package burp.hae.montoya.ui; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.core.Registration; +import burp.api.montoya.core.ToolType; +import burp.api.montoya.ui.Theme; +import burp.api.montoya.ui.UserInterface; +import burp.api.montoya.ui.contextmenu.ContextMenuItemsProvider; +import burp.api.montoya.ui.editor.*; +import burp.api.montoya.ui.editor.extension.*; +import burp.api.montoya.ui.menu.MenuBar; +import burp.api.montoya.ui.swing.SwingUtils; +import burp.hae.MessageEditorController; + +import java.awt.*; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class UserInterfaceImpl implements UserInterface { + + private final IBurpExtenderCallbacks callbacks; + private ExtensionProvidedHttpRequestEditor httpRequestEditor; + private ExtensionProvidedHttpResponseEditor httpResponseEditor; + private final MessageEditorController messageEditorController; + + public UserInterfaceImpl(IBurpExtenderCallbacks callbacks) { + this.callbacks = callbacks; + this.messageEditorController = new MessageEditorController(); + } + + @Override + public MenuBar menuBar() { + return null; + } + + @Override + public Registration registerSuiteTab(String title, Component component) { + this.callbacks.customizeUiComponent(component); + return null; + } + + @Override + public Registration registerContextMenuItemsProvider(ContextMenuItemsProvider provider) { + return null; + } + + @Override + public Registration registerHttpRequestEditorProvider(HttpRequestEditorProvider provider) { + EditorCreationContextImpl context = new EditorCreationContextImpl(ToolType.PROXY); + httpRequestEditor = provider.provideHttpRequestEditor(context); + return new Registration() { + @Override + public boolean isRegistered() { + return UserInterfaceImpl.this.httpRequestEditor != null; + } + + @Override + public void deregister() { + UserInterfaceImpl.this.httpRequestEditor = null; + } + }; + } + + @Override + public Registration registerHttpResponseEditorProvider(HttpResponseEditorProvider provider) { + EditorCreationContextImpl context = new EditorCreationContextImpl(ToolType.PROXY); + httpResponseEditor = provider.provideHttpResponseEditor(context); + return new Registration() { + @Override + public boolean isRegistered() { + return UserInterfaceImpl.this.httpResponseEditor != null; + } + + @Override + public void deregister() { + UserInterfaceImpl.this.httpResponseEditor = null; + } + }; + } + + @Override + public Registration registerWebSocketMessageEditorProvider(WebSocketMessageEditorProvider provider) { + return null; + } + + @Override + public RawEditor createRawEditor(EditorOptions... options) { + return null; + } + + @Override + public WebSocketMessageEditor createWebSocketMessageEditor(EditorOptions... options) { + return null; + } + + @Override + public HttpRequestEditor createHttpRequestEditor(EditorOptions... options) { + return new HttpRequestEditorImpl(this.callbacks, this.messageEditorController); + } + + @Override + public HttpResponseEditor createHttpResponseEditor(EditorOptions... options) { + return new HttpResponseEditorImpl(this.callbacks, this.messageEditorController); + } + + @Override + public void applyThemeToComponent(Component component) { + + } + + @Override + public Theme currentTheme() { + return null; + } + + @Override + public Font currentEditorFont() { + return null; + } + + @Override + public Font currentDisplayFont() { + return null; + } + + @Override + public SwingUtils swingUtils() { + return null; + } +} diff --git a/src/main/java/burp/hae/montoya/utilities/ByteUtilsImpl.java b/src/main/java/burp/hae/montoya/utilities/ByteUtilsImpl.java new file mode 100644 index 0000000..624ab03 --- /dev/null +++ b/src/main/java/burp/hae/montoya/utilities/ByteUtilsImpl.java @@ -0,0 +1,80 @@ +package burp.hae.montoya.utilities; + +import burp.IBurpExtenderCallbacks; +import burp.IExtensionHelpers; +import burp.api.montoya.utilities.ByteUtils; + +import java.util.regex.Pattern; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class ByteUtilsImpl implements ByteUtils { + + private final IExtensionHelpers helpers; + + public ByteUtilsImpl(IBurpExtenderCallbacks callbacks) { + this.helpers = callbacks.getHelpers(); + } + + @Override + public int indexOf(byte[] data, byte[] searchTerm) { + return this.indexOf(data, searchTerm, false); + } + + @Override + public int indexOf(byte[] data, byte[] searchTerm, boolean caseSensitive) { + return this.indexOf(data, searchTerm, caseSensitive, 0, data.length); + } + + @Override + public int indexOf(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to) { + return this.helpers.indexOf(data, searchTerm, caseSensitive, from, to); + } + + @Override + public int indexOf(byte[] data, Pattern pattern) { + return 0; + } + + @Override + public int indexOf(byte[] data, Pattern pattern, int from, int to) { + return 0; + } + + @Override + public int countMatches(byte[] data, byte[] searchTerm) { + return 0; + } + + @Override + public int countMatches(byte[] data, byte[] searchTerm, boolean caseSensitive) { + return 0; + } + + @Override + public int countMatches(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to) { + return 0; + } + + @Override + public int countMatches(byte[] data, Pattern pattern) { + return 0; + } + + @Override + public int countMatches(byte[] data, Pattern pattern, int from, int to) { + return 0; + } + + @Override + public String convertToString(byte[] bytes) { + return this.helpers.bytesToString(bytes); + } + + @Override + public byte[] convertFromString(String string) { + return this.helpers.stringToBytes(string); + } +} diff --git a/src/main/java/burp/hae/montoya/utilities/UtilitiesImpl.java b/src/main/java/burp/hae/montoya/utilities/UtilitiesImpl.java new file mode 100644 index 0000000..c92f74e --- /dev/null +++ b/src/main/java/burp/hae/montoya/utilities/UtilitiesImpl.java @@ -0,0 +1,62 @@ +package burp.hae.montoya.utilities; + +import burp.IBurpExtenderCallbacks; +import burp.api.montoya.utilities.*; + +/** + *

+ * Created by vaycore on 2024-05-06. + */ +public class UtilitiesImpl implements Utilities { + + private final ByteUtilsImpl byteUtils; + + public UtilitiesImpl(IBurpExtenderCallbacks callbacks) { + this.byteUtils = new ByteUtilsImpl(callbacks); + } + + @Override + public Base64Utils base64Utils() { + return null; + } + + @Override + public ByteUtilsImpl byteUtils() { + return byteUtils; + } + + @Override + public CompressionUtils compressionUtils() { + return null; + } + + @Override + public CryptoUtils cryptoUtils() { + return null; + } + + @Override + public HtmlUtils htmlUtils() { + return null; + } + + @Override + public NumberUtils numberUtils() { + return null; + } + + @Override + public RandomUtils randomUtils() { + return null; + } + + @Override + public StringUtils stringUtils() { + return null; + } + + @Override + public URLUtils urlUtils() { + return null; + } +} diff --git a/src/main/java/burp/vaycore/onescan/common/Constants.java b/src/main/java/burp/vaycore/onescan/common/Constants.java index 835cbc1..521c00a 100644 --- a/src/main/java/burp/vaycore/onescan/common/Constants.java +++ b/src/main/java/burp/vaycore/onescan/common/Constants.java @@ -9,7 +9,7 @@ public interface Constants { // 插件信息 String PLUGIN_NAME = "OneScan"; - String PLUGIN_VERSION = "1.5.2"; + String PLUGIN_VERSION = "1.6.0"; boolean DEBUG = false; // 插件启动显示的信息 diff --git a/src/main/java/burp/vaycore/onescan/ui/tab/config/OtherTab.java b/src/main/java/burp/vaycore/onescan/ui/tab/config/OtherTab.java index fef6d1f..bd565ad 100644 --- a/src/main/java/burp/vaycore/onescan/ui/tab/config/OtherTab.java +++ b/src/main/java/burp/vaycore/onescan/ui/tab/config/OtherTab.java @@ -1,9 +1,9 @@ package burp.vaycore.onescan.ui.tab.config; +import burp.hae.HaE; import burp.vaycore.common.helper.UIHelper; import burp.vaycore.common.layout.HLayout; import burp.vaycore.common.utils.StringUtils; -import burp.vaycore.hae.HaE; import burp.vaycore.onescan.common.Config; import burp.vaycore.onescan.manager.FpManager; import burp.vaycore.onescan.ui.base.BaseConfigTab;