Montoya新建带GUI的BurpSuite插件

新建类Register.java代码如下:

import burp.api.montoya.BurpExtension;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.logging.Logging;
import com.yxzs.ui.UIMain;

public class Register implements BurpExtension {
    @Override
    public void initialize(MontoyaApi montoyaApi) {
        Logging logging=montoyaApi.logging();
        logging.logToOutput("Loading ...");
        // 加载插件时打印消息2
        logging.logToOutput("Register ...");
        // 设置插件名称
        montoyaApi.extension().setName("EncDec");
        // 注册 HttpHandler 类,可以处理http请求及响应
        // 新建类Modify,引用HttpHandler方法
        montoyaApi.http().registerHttpHandler(new Modify(montoyaApi));
        // 注册 ITab 类,并设置名称BpEnc,新建一个类 UIMain 用户定义GUI页面
        // 不想要GUI可以不写下面代码
        montoyaApi.userInterface().registerSuiteTab("BpGUI",new UIMain(montoyaApi).getRoot());
    }
}

Modify类代码如下:

import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.handler.*;
import burp.api.montoya.logging.Logging;
import burp.api.montoya.proxy.http.InterceptedResponse;
import burp.api.montoya.proxy.http.ProxyResponseToBeSentAction;

public class Modify implements HttpHandler {
    // 使用implements继承 HttpHandler 类
    private final Logging logging;
    // 引用Logging类,burpsuite插件打印日志 
    // 通过logging.logToOutput();打印信息
    public Modify(MontoyaApi api) {
        this.logging = api.logging();
    }
    // 处理http请求包
    public RequestToBeSentAction handleHttpRequestToBeSent(HttpRequestToBeSent requestToBeSent) {
        // 返回请求路径: requestToBeSent.path();
        // 返回完整请求URL: requestToBeSent.url();
        // 返回请求方法(post/get等): requestToBeSent.method();
        // 返回请求头(类型List<HttpHeader>): requestToBeSent.headers();
        // 返回请求主体字符串: requestToBeSent.bodyToString();
        // 更新请求头信息: requestToBeSent.withUpdatedHeader();
        // 添加请求头信息: requestToBeSent.withAddedHeader();
        // 删除请求头: requestToBeSent.withRemovedHeader();
        // 修改请求主体部分: requestToBeSent.withBody();
        // 返回BurpSuite工具类型,请求来自哪个部分,如Repeater、Intruder、Porxy等: requestToBeSent.toolSource().toolType().toolName();
        // 获取请求ID: int reqid = requestToBeSent.messageId();
        // 遍历请求头
        List<HttpHeader> headers = requestToBeSent.headers();
        for (HttpHeader header : headers) {
            logging.logToOutput(header.name() + ": " + header.value());
        }
        // 修改后的响应包通过 return RequestToBeSentAction.continueWith(HttpRequest request);返回
        
        return RequestToBeSentAction.continueWith(requestToBeSent);
        // 函数默认返回null,不处理请求
        // return null;
    }
    // 处理接收到的http响应包
    public ResponseReceivedAction handleHttpResponseReceived(HttpResponseReceived responseReceived) {
        //大部分方法与请求一致
        // 修改后的响应包通过 return ResponseReceivedAction.continueWith();返回
        ResponseReceivedAction.continueWith(responseReceived);
        // 函数默认返回null,不处理请求
        // return null;
    }
    // 发送的http响应包时修改响应内容
    public ProxyResponseToBeSentAction handleResponseToBeSent(InterceptedResponse interceptedResponse) {
        // 修改后的响应包通过 return ProxyResponseToBeSentAction.continueWith();返回
        // 函数默认返回null,不处理请求
        return null;
    }
}

UIMain类代码如下:

使用 Idea IDE 的Swing UI设计器,新建一个GUI窗体,就可以方便设计GUI页面了

import javax.swing.*;
import java.awt.*;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.logging.Logging;

public class UIMain {
    // 设置JPanel设置为root
    private JPanel root;
    // 引用Logging类,burpsuite插件打印日志 
    private Logging logging = null;
    
    public UIMain(MontoyaApi montoyaApi) {
        // 通过logging.logToOutput();打印信息
        this.logging = montoyaApi.logging();
        
        //下面可以添加各类监听器
        
        **....此处省略....**
    
    }
    
    // 通过函数返回JPanel
    public JPanel getRoot() {
        return root;
    }
}

下面可以根据自己需求利用Montoya扩展接口编写BurpSuite插件了。

Burpsuite是一款用于Web应用程序的渗透测试工具,它可以帮助安全专业人员识别和利用应用程序中的漏洞。在使用Burpsuite时,可以通过发送截断的请求到Burpsuite Intruder并设置Payload进行测试。 关于Burpsuite插件的编写,官方并没有提供详细的文档,但提供了很多相关案例供开发者参考,并且需要自行阅读和配置Java环境。 在编写Burpsuite插件时,可以封装一个类来包装请求和响应参数,方便界面上显示请求响应、来源等信息。这个类可以定义如下: ```java package com.qj.bc.customlogger; import burp.api.montoya.core.ToolSource; import burp.api.montoya.http.message.requests.HttpRequest; import burp.api.montoya.http.message.responses.HttpResponse; public class HttpResponseReceived { private ToolSource toolSource; private HttpRequest request; private HttpResponse response; public HttpResponseReceived(ToolSource toolSource, HttpRequest request, HttpResponse response) { this.toolSource = toolSource; this.request = request; this.response = response; } public ToolSource toolSource(){ return toolSource; } public HttpRequest initiatingRequest(){ return request; } public HttpResponse getResponse(){ return response; } } ``` 通过添加表格数据源,可以将请求和响应的信息添加到表格中进行展示。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Burpsuite 上](https://blog.youkuaiyun.com/weixin_50666634/article/details/125733993)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [BurpSuite实战教程03-BurpSuite插件开发](https://blog.youkuaiyun.com/liaomin416100569/article/details/129188554)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

K2epUp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值