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插件了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

K2epUp

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

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

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

打赏作者

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

抵扣说明:

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

余额充值