-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09a6754
commit a8fce39
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
*** AUTO-GENERATED FILE *** | ||
This file is auto-generated by BambdaChecker. | ||
Please do not manually edit this file, or include any changes to this file in pull requests. | ||
--> | ||
# Proxy WebSockets | ||
Documentation: [Filtering the WebSockets history with Bambdas](https://portswigger.net/burp/documentation/desktop/tools/proxy/websockets-history/bambdas) | ||
## [ExtractPayloadToNotes.bambda](https://github.com/PortSwigger/bambdas/blob/main/Proxy/WS/ExtractPayloadToNotes.bambda) | ||
### Extracts JSON elements from the WebSocket message and displays it in the "Notes" column of the WebSocket History tab | ||
#### Author: Nick Coblentz (https://github.com/ncoblentz) | ||
```java | ||
//The bambda will search for json elements with the following keys. The keys below are just examples. Add the keys you want to include here: | ||
List<String> terms = List.of("target","error"); | ||
|
||
if (!message.annotations().hasNotes()) { | ||
StringBuilder builder = new StringBuilder(); | ||
String payload = utilities().byteUtils().convertToString(message.payload().getBytes()); | ||
terms.forEach(term -> { | ||
Matcher m = Pattern.compile("\"" + term + "\":\"([^\"]+)\"", Pattern.CASE_INSENSITIVE).matcher(payload); | ||
while (m.find() && m.groupCount() > 0) { | ||
for (int i = 1; i <= m.groupCount(); i++) { | ||
if (m.group(i) != null) | ||
builder.append(term + ": " + m.group(i) + " "); | ||
} | ||
} | ||
}); | ||
message.annotations().setNotes(builder.toString()); | ||
} | ||
return true; | ||
|
||
``` |