文章总结: BurpSuiteProfessional2023.10.3版本引入Bambda功能,允许通过编写Java代码自定义过滤HTTP历史和WebSocket消息。主要接口包括ProxyHttpRequestResponse、ProxyWebSocketMessage、Utilities和logging,支持灵活筛选请求、提取特定字段、高亮敏感信息及修改请求头。实际应用包括过滤特定HTTP方法、排除特定域名、提取WebSocketJSON字段、正则匹配邮箱并高亮显示、自动计算请求体SHA256签名等。配合BambdaLibrary插件可快速使用预设规则,显著提升渗透测试效率。 综合评分: 78 文章分类: 渗透测试,安全工具,WEB安全
burp bambda使用
原创
信安路漫漫 信安路漫漫
信安路漫漫
2026年2月7日 07:02 上海
前言
bambda是burpsuite profession 2023.10.3版本引入支持的通过编写自定义代码筛选http histroy特性,在之前的版本,http history通常使用设置模式筛选请求或响应,新的版本多出了Bambda mode,并且支持将已设置的规则转换为Bambda表达式
本篇文章就来学习一下如何使用bambda。
#
主要作用
1)更加灵活的过滤想要的请求数据
2)灵活进行替换请求内容
#
bambda接口
bambda主要有下面的几个主要接口:
ProxyHttpRequestResponse
ProxyWebSocketMessage
Utilities
logging
#
ProxyHttpRequestResponse
处理burp代理的HTTP请求与响应,其常用的函数有下面的几种
查找具体的函数使用可以通过下面的链接:https://portswigger.github.io/burp-extensions-montoya-api/javadoc/burp/api/montoya/proxy/ProxyHttpRequestResponse.html
用法举例
获取请求参数
var mimeType = requestResponse.mimeType(); //获取请求的mimeType类型var path = requestResponse.request().pathWithoutQuery().toLowerCase(); //获取请求路径var methods = requestResponse.request().method(); //获取请求方法String host = requestResponse.request().httpService().host(); //获取请求host头
ProxyWebSocketMessage接口
接口简介
用于处理ws相关的请求
主要方法
参考链接:ProxyWebSocketMessage (burp-extensions-montoya-api 2025.8 API)
用法举例
message.contains("openim.ws_msg_push_ack", false) //ws信息中是否包含openim.ws_msg_push_ack字段 int listerport = message.listenerPort(); //获取ws的端口 String payload = utilities().byteUtils().convertToString(message.payload().getBytes()); //获取ws的信息并转化为字符串
Utilities接口
用于数据转换的接口,主要方法有如:base64Utils()、htmlUtils()、randomUtils()等等。
https://portswigger.github.io/burp-extensions-montoya-api/javadoc/burp/api/montoya/utilities/Utilities.html
用法举例
String payload = utilities().byteUtils().convertToString(message.payload().getBytes()); //将字节转化为字符串utilities().jsonUtils().read(payload,"head.test") //查找json字符串中的是否包含test参数
logging接口
该接口主要用于日志记录
Logging (burp-extensions-montoya-api 2025.8 API)
用法举例
logging().logToOutput("11111111"); //在consoles中输出日志
实际应用
过滤掉特定的Method请求
return !requestResponse.request().method().equals("PUT") && !requestResponse.request().method().equals("PATCH") && !requestResponse.request().method().equals("DELETE") && !requestResponse.request().method().equals("HEAD") && !requestResponse.request().method().equals("OPTIONS") && !requestResponse.request().method().equals("TRACE") && !requestResponse.request().method().equals("CONNECT");
过滤掉特定的host请求
var host = requestResponse.request().httpService().host(); String[] excludeDomain = { ".*google.*", ".*freebuf.com", ".*googleapis.com", ".*firefox.com", ".*mozilla.*", ".*baidu.com", ".*gtimg.com", ".*github.com", ".*csdn.net", ".*aliyun.com", ".*adtidy.org", ".*qianxin.com", ".*immersivetranslate.com", ".*mozilla.com", ".*openjfx.cn", ".*feishu.cn", ".*grok.com", }; boolean isExcluded = Arrays.stream(excludeDomain) .map(Pattern::compile) .anyMatch(pattern -> pattern.matcher(host).find()); if (isExcluded) { return false; } return true;
ws中过滤包含特别字符的请求
return !message.contains("msg_push_ack", false) && !message.contains("heartbeat.alive", false)
#
提取ws中json中某个字段的值
该模块可以直接在ws面板中显示一个新的字段
在这里点击新增按钮
输入下面的值
if (message.contains("cookie",false)){ return utilities().jsonUtils().read(payload,"body.cookie").replace("\"", ""); }return "";
如下图所示,新增了一个字段
提取请求中的email并高亮显示
boolean manualColorHighlightEnabled = true; // Set of file extensions to ignore Set<String> ignoredExtensions = Set.of("mp4", "mp3", "png", "gif", "jpg", "jpeg", "css", "pdf"); if (!requestResponse.hasResponse()) { return false; } // Retrieve the URL from the request part of the requestResponse object String requestUrl = requestResponse.request().url().toString(); for (String ext : ignoredExtensions) { // Check if the URL ends with any of the ignored file extensions if (requestUrl.toLowerCase().endsWith("." + ext)) { return false; } } // Extract the response body as a string and remove any leading and trailing whitespace var body = requestResponse.response().bodyToString().trim(); String emailRegexPattern = "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.(?!jpeg|png|jpg|gif|webp)[A-Z|a-z]{2,7}\\b"; Pattern emailPattern = Pattern.compile(emailRegexPattern); // Create a matcher to find email addresses in the response body Matcher emailMatcher = emailPattern.matcher(body); if (emailMatcher.find()) { if (manualColorHighlightEnabled) { requestResponse.annotations().setHighlightColor(HighlightColor.GREEN); // Add a note indicating that an email was found requestResponse.annotations().setNotes("Email Found!: " + emailMatcher.group()); } return true; } return false;
替换消息头中值
var digest = utilities.cryptoUtils().generateDigest( requestResponse.request().body(), DigestAlgorithm.SHA_256 ); var signature = HexFormat.of().formatHex(digest.getBytes());
return requestResponse.request().withAddedHeader("Content-Sha256", signature);
帮助插件
有一些已经写好的bambda,我们可以通过插件直接使用。
在商城搜索下面的插件
安装以后,可以看到一些已经写好的bambda。使用的时候可以点击复制,然后在Extensions->Bambda library ->new新建
保存即可
总结
bambda的引入帮忙我们可以用极少的时间来过滤我们想要的数据,减少在无用数据上的时间,这个功能在实际的测试中可以
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:信安路漫漫 信安路漫漫 信安路漫漫《burp bambda使用》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。








评论