当前位置: 首页 > wzjs >正文

如何本地搭建网站nba交易最新消息

如何本地搭建网站,nba交易最新消息,建设博物馆网站,网站建设与管理专业好不好就业1 前言 历史章节: 【BurpSuite 2025最新版插件开发】基础篇1:环境搭建 【BurpSuite 2025最新版插件开发】基础篇2:插件生命周期与核心接口 【BurpSuite 2025最新版插件开发】基础篇3:请求拦截和修改简单示例 【BurpSuite 202…

1 前言

历史章节:

【BurpSuite 2025最新版插件开发】基础篇1:环境搭建

【BurpSuite 2025最新版插件开发】基础篇2:插件生命周期与核心接口

【BurpSuite 2025最新版插件开发】基础篇3:请求拦截和修改简单示例

【BurpSuite 2025最新版插件开发】基础篇4:HTTP流量处理

【BurpSuite 2025最新版插件开发】基础篇5:UI组件开发

【BurpSuite 2025最新版插件开发】基础篇6:UI组件与数据传输

本章节注意讲解 BurpSuite 插件中对于数据持久化存储的基本使用。

2 接口简介

BurpSuite 官方接口
在这里插入图片描述

2.1 PersistedList<T>:项目级列表存储

  • 功能定位
    存储有序的、可重复的数据列表,支持泛型类型(如字符串、整数等),数据随Burp项目文件保存。
  • 核心特性
    • 类型安全:通过泛型约束元素类型(如PersistedList<String>)。
    • 项目隔离:每个项目独立保存列表数据,切换项目时自动加载对应数据。
    • 动态操作:支持addremovesize等列表操作,适合存储可变数据集合(如URL历史记录)。
  • 使用场景
    存储插件运行时动态生成的列表数据(如扫描结果、自定义Payload列表)。

2.2 PersistedObject:项目级复杂对象存储(仅供专业版)

  • 功能定位
    存储单个结构化对象(如配置类、自定义数据模型),需实现java.io.Serializable接口。
  • 核心特性
    • 复杂数据支持:可存储嵌套对象、集合等复杂结构。
    • 项目绑定:数据与项目关联,适合保存项目特定的配置或状态。
    • 版本兼容性:需注意序列化版本UID,避免跨版本兼容性问题。
  • 使用场景
    存储插件的完整配置(如多模块扫描策略)或复杂状态数据。

2.3 Persistence:持久化功能入口

  • 功能定位
    工厂接口,用于创建和管理PersistedListPersistedObject实例。
  • 核心方法
    • createPersistedList(String name, Class<T> elementType):创建命名列表。
    • persistedObject(String name):获取或创建命名对象。
  • 使用场景
    插件初始化时通过montoya.persistence()获取实例,再创建具体持久化存储。

2.4 Preferences:用户级全局配置

  • 功能定位
    存储与项目无关的用户偏好或全局设置(如API密钥、界面主题)。
  • 核心特性
    • 跨项目共享:数据存储在用户配置文件中,所有项目均可访问。
    • 基本类型支持:仅支持字符串、布尔值、整数等简单类型。
    • 监听机制:可注册监听器实时响应配置变化。
  • 使用场景
    存储插件的全局设置(如默认扫描选项、认证凭证)。

2.5 持久化接口对比与选择建议

接口名称PersistedListPersistedObjectPersistencePreferences
功能定位存储有序、可重复的数据列表,支持泛型类型。存储单个结构化对象(如配置类、数据模型)。工厂接口,用于创建和管理其他持久化接口。存储用户级全局配置(与项目无关)。
数据作用域项目级(随项目文件保存)。项目级(随项目文件保存)。-用户级(跨项目共享)。
支持数据类型泛型列表(需指定元素类型)。内置类型(如HTTP请求/响应)、自定义对象。-基本类型(String、Boolean、Integer等)。
序列化要求元素需实现 Serializable(如自定义类)。文档未明确要求,但自定义对象可能需适配。-无需序列化。
核心方法add, remove, get, size, clearset, get, setChildObject, removecreatePersistedList, persistedObjectput, get, remove, addListener
典型场景存储动态生成的项目相关列表(如URL历史)。存储复杂配置或项目状态(如多模块策略)。插件初始化时获取持久化功能入口。存储全局用户偏好(如API密钥、主题)。
版本限制社区版/专业版均可使用。专业版(标注 [Professional only])。社区版/专业版均可使用。社区版/专业版均可使用。

关键说明

  1. PersistedList 适合动态增删的列表场景,但查询效率依赖列表长度(O(n))。
  2. PersistedObject 支持复杂数据结构,但需注意专业版限制及可能的序列化适配。
  3. Persistence 是创建其他持久化对象的唯一入口,需通过 montoya.persistence() 获取。
  4. Preferences 适合存储与项目无关的配置,数据跨项目共享且无需序列化。

3 实战模拟

插件实现如下需求:

  • 通过 HTTP 接口获取不同类型用户的信息:token、uid、role 后进行持久化存储。
  • 在业务接口中使用不同类型用户的信息调用业务接口,来测试业务接口的权限隔离。
  • 使用 BurpSuite 版本通用PersistedList 接口实现数据持久化。

4 代码示例

4.1 服务端代码

使用 python 代码实现极简服务端,实现如下需求:

  • 预先定义了系统固定的用户和管理员信息,包含 token、uid 和 role 三个字段。
  • 实现 3 个接口:
  1. 获取用户信息接口(/user_info)

    • 请求方法:GET
    • 功能:返回预先定义的用户信息,包含 token、uid 和 role。
    • 响应示例:
      在这里插入图片描述
  2. 获取管理员信息接口(/admin_info)

    • 请求方法:GET
    • 功能:返回预先定义的管理员信息,包含 token、uid 和 role。
    • 响应示例:在这里插入图片描述
  3. 添加用户接口(/add_user)

    • 请求方法:POST

    • 请求参数:以 JSON 格式传递 token、uid 和 role 三个参数。

    • 功能:检查传入的参数是否与预先定义的管理员信息一致,若一致则返回添加成功的消息;若不一致则返回添加失败的消息。

    • 成功响应示例:在这里插入图片描述

    • 失败响应示例:
      在这里插入图片描述

服务端 python 代码:

from flask import Flask, request, jsonifyapp = Flask(__name__)# 模拟用户和管理员信息
USER_INFO = {"token": "user_token_123","uid": "user_uid_123","role": "user"
}ADMIN_INFO = {"token": "admin_token_123","uid": "admin_uid_123","role": "admin"
}# 获取用户信息接口
@app.route('/user_info', methods=['GET'])
def get_user_info():return jsonify(USER_INFO)# 获取管理员信息接口
@app.route('/admin_info', methods=['GET'])
def get_admin_info():return jsonify(ADMIN_INFO)# 添加用户接口
@app.route('/add_user', methods=['POST'])
def add_user():data = request.get_json()if not data or 'token' not in data or 'uid' not in data or 'role' not in data:return jsonify({"message": "Missing parameters"}), 400if data['token'] == ADMIN_INFO['token'] and data['uid'] == ADMIN_INFO['uid'] and data['role'] == ADMIN_INFO['role']:return jsonify({"message": "User added successfully"}), 200else:return jsonify({"message": "Adding user failed"}), 400if __name__ == '__main__':app.run(debug=True)

通过命令行启动:
在这里插入图片描述

4.2 插件代码

实现需求:

  • 拦截 HTTP 响应、持久化存储用户数据。
  • 通过右键菜单触发的业务接口的测试请求。
  • 测试请求分别使用 user 和 admin 的信息请求 /add_user 接口。
  1. Extension.java
    • 插件的主类,实现了 BurpExtension 接口,设置插件名称。
    • 创建两个 PersistedList<String> 实例,用于持久化存储用户信息和管理员信息。
    • 注册 CustomHttpHandler 来处理 HTTP 请求/响应。
    • 注册 TestMenu 右键菜单项。
import burp.api.montoya.BurpExtension;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.persistence.PersistedList;@SuppressWarnings("unused")
public class Extension implements BurpExtension {@Overridepublic void initialize(MontoyaApi montoyaApi) {montoyaApi.extension().setName("My Extension");// 创建持久化对象PersistedList<String> userInfoList = PersistedList.persistedStringList();PersistedList<String> adminInfoList = PersistedList.persistedStringList();// HTTP 监听器montoyaApi.http().registerHttpHandler(new CustomHttpHandler(montoyaApi, userInfoList, adminInfoList));// 注册右键-测试请求montoyaApi.userInterface().registerContextMenuItemsProvider(new TestMenu(montoyaApi, userInfoList, adminInfoList));}
}
  1. CustomHttpHandler.java
    • 该类实现了 HttpHandler 接口,用于监听和处理 HTTP 请求与响应。
    • handleHttpResponseReceived 方法中,检查响应内容是否包含 "role": "user""role": "admin",并分别将这些信息添加到 userInfoListadminInfoList 中。
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.handler.*;
import burp.api.montoya.persistence.PersistedList;public class CustomHttpHandler implements HttpHandler {private final MontoyaApi montoyaApi;private final PersistedList<String> userInfoList;private final PersistedList<String> adminInfoList;public CustomHttpHandler(MontoyaApi montoyaApi, PersistedList<String> userInfoList, PersistedList<String> adminInfoList) {this.montoyaApi = montoyaApi;this.userInfoList = userInfoList;this.adminInfoList = adminInfoList;}@Overridepublic RequestToBeSentAction handleHttpRequestToBeSent(HttpRequestToBeSent httpRequestToBeSent) {return RequestToBeSentAction.continueWith(httpRequestToBeSent);}@Overridepublic ResponseReceivedAction handleHttpResponseReceived(HttpResponseReceived httpResponseReceived) {// 持久化存储if (httpResponseReceived.bodyToString().contains("\"role\": \"user\"")) {userInfoList.add(httpResponseReceived.body().toString());String userValue = userInfoList.stream().findFirst().orElse("无用户信息");montoyaApi.logging().logToOutput("获取 UserInfoList: " + userValue);}if (httpResponseReceived.bodyToString().contains("\"role\": \"admin\"")) {adminInfoList.add(httpResponseReceived.body().toString());String adminValue = adminInfoList.stream().findFirst().orElse("无管理员信息");montoyaApi.logging().logToOutput("获取 AdminInfoList: " + adminValue);}// 打印响应montoyaApi.logging().logToOutput("响应体: " + httpResponseReceived.bodyToString());return ResponseReceivedAction.continueWith(httpResponseReceived);}
}
  1. TestMenu.java
    • 该类实现了 ContextMenuItemsProvider 接口,为 Burp 的上下文菜单提供自定义菜单项。
    • 提供一个名为“测试请求”的菜单项;点击菜单项后会调用 MyRequest.sendTestRequest(...) 方法,传递 userInfoListadminInfoList
    • 使用事件监听机制来触发请求。
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.persistence.PersistedList;
import burp.api.montoya.ui.contextmenu.ContextMenuEvent;
import burp.api.montoya.ui.contextmenu.ContextMenuItemsProvider;import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;public class TestMenu implements ContextMenuItemsProvider {private final MontoyaApi montoyaApi;private final PersistedList<String> userInfoList;private final PersistedList<String> adminInfoList;public TestMenu(MontoyaApi montoyaApi, PersistedList<String> userInfoList, PersistedList<String> adminInfoList) {this.montoyaApi = montoyaApi;this.userInfoList = userInfoList;this.adminInfoList = adminInfoList;}@Overridepublic List<Component> provideMenuItems(ContextMenuEvent event) {List<Component> menuItems = new ArrayList<>();JMenuItem menuItem = new JMenuItem("测试请求");menuItem.addActionListener(e -> {MyRequest myRequest = new MyRequest(montoyaApi);myRequest.sendTestRequest(userInfoList, adminInfoList);});menuItems.add(menuItem);return menuItems;}
}
  1. MyRequest.java
    • 该类封装了发送 HTTP 请求的逻辑。
    • sendTestRequest(...) 方法从 PersistedList<String> 中提取第一个用户信息和管理员信息;如果信息为空,则记录错误日志;
    • 使用 SwingWorker 异步执行网络操作,避免阻塞主线程;
    • sendRequest(...) 方法解析 JSON 数据,并构造新的 HTTP POST 请求发送到服务器。
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.HttpService;
import burp.api.montoya.http.message.requests.HttpRequest;
import burp.api.montoya.persistence.PersistedList;
import burp.api.montoya.utilities.json.JsonUtils;import javax.swing.*;public class MyRequest {private final MontoyaApi montoyaApi;public MyRequest(MontoyaApi montoyaApi) {this.montoyaApi = montoyaApi;}public void sendTestRequest(PersistedList<String> userInfoList, PersistedList<String> adminInfoList) {String userValue = userInfoList.stream().findFirst().orElse("");String adminValue = adminInfoList.stream().findFirst().orElse("");if (userValue.isEmpty() || adminValue.isEmpty()) {montoyaApi.logging().logToError("no user info or admin info");return;}new SwingWorker<Void, Void>() {@Overrideprotected Void doInBackground() {sendRequest(userInfoList, "user");sendRequest(adminInfoList, "admin");return null;}}.execute();}private void sendRequest(PersistedList<String> dataList, String roleType) {try {String infoValue = dataList.stream().findFirst().orElse(null);if (infoValue == null) {montoyaApi.logging().logToError("数据为空: " + roleType);return;}JsonUtils jsonUtils = montoyaApi.utilities().jsonUtils();String role = jsonUtils.readString(infoValue, "role");String token = jsonUtils.readString(infoValue, "token");String uid = jsonUtils.readString(infoValue, "uid");String requestBody = String.format("{\"role\":\"%s\",\"token\":\"%s\",\"uid\":\"%s\"}", role, token, uid);HttpService httpService = HttpService.httpService("localhost", 5000, false);HttpRequest httpRequest = HttpRequest.httpRequest().withPath("/add_user").withService(httpService).withBody(requestBody).withHeader("Content-Type", "application/json").withMethod("POST");montoyaApi.http().sendRequest(httpRequest);} catch (Exception e) {montoyaApi.logging().logToError("error:" + e.getMessage());}}
}

5 效果展示

5.1 抓包接口获取用户数据

获取 user 信息:
在这里插入图片描述
获取 admin 信息:
在这里插入图片描述
日志打印:
在这里插入图片描述

5.2 右键触发测试请求

触发请求 /add_user 接口:
在这里插入图片描述
日志打印:可以看到输出日志符合服务端的判断。

插件:

sendRequest(userInfoList, "user");
sendRequest(adminInfoList, "admin");

服务端:

if data['token'] == ADMIN_INFO['token'] and data['uid'] == ADMIN_INFO['uid'] and data['role'] == ADMIN_INFO['role']:return jsonify({"message": "User added successfully"}), 200else:return jsonify({"message": "Adding user failed"}), 400

在这里插入图片描述

6 总结

  • 整个插件的功能流程如下:

    1. 拦截响应:通过 CustomHttpHandler 类拦截 HTTP 响应,识别包含 "role": "user""role": "admin"的响应体,并将其持久化存储到 PersistedList 中;
    2. 持久化存储:使用 Montoya API 的 PersistedList 来保存用户和管理员信息;
    3. 触发测试请求:通过右键菜单项(由 TestMenu 类实现)触发测试请求;
    4. 异步发送请求:在后台线程中使用 MyRequest 类发送包含用户和管理员信息的 HTTP 请求,避免阻塞 UI。
  • 本插件适用于需要从响应中提取特定信息基于这些信息发起新请求的安全测试场景。

:由于社区版不支持保存项目到本地,因此要最大程度的发挥persistence的作用建议使用专业版

http://www.dtcms.com/wzjs/116598.html

相关文章:

  • 如何网站做专题seo推广是什么意思
  • 建设银行属于哪里推推蛙贴吧优化
  • 西安网站建设培训学校怎么做网络广告推广
  • 厦门企业自助建站系统优化网站的意思
  • 短视频关键词优化深圳网站建设优化
  • 成都网站设计新闻关键词搜索排名工具
  • 太平洋电脑配置报价官网东莞百度seo
  • 北京网站开发费用大型网站建设公司
  • 蓬莱市住房和规划建设管理局网站宁德市高中阶段招生信息平台
  • 我的世界怎么做充值点卷网站数据推广公司
  • 政府网站怎样建设google搜索引擎官网
  • 黄山网站建设哪家强东莞网络推广系统
  • 如何使用好单库选品库做网站网站之家查询
  • ftp做网站青岛关键词优化报价
  • 免费做网站数据分析师培训机构推荐
  • 响应式模板网站模板网站怎么优化
  • 武汉正规的做网站公司百度统计收费吗
  • 网站开发过程中的方法百度客服24小时电话
  • 世界上最大的在线设计平台网站优化效果
  • 做触屏网站seo费用
  • 网站建设制作文案潍坊seo外包平台
  • 网站安全建设论文广告外链购买平台
  • 建设网站系统软件推广的渠道是哪里找的
  • 网站建设的风险识别单页网站怎么优化
  • 网站服务器做缓存排名优化工具
  • 公司网站建设怎么选择主机大小免费发布推广的平台有哪些
  • 网站建设费计入什么科目360优化大师软件
  • 百度在线做网站成都排名推广
  • php做网站不兼容ie8企业网站怎么做
  • 建设工程合同的形式百度seo关键词优化排名