Skip to content

Commit

Permalink
Create EmailHighlighter.bambda
Browse files Browse the repository at this point in the history
 The script is designed to efficiently parse through response data to identify and filter out email addresses. It begins by establishing a set of ignored file extensions, ensuring that the script does not process irrelevant response types such as images or multimedia files. The core functionality revolves around a regular expression that is meticulously crafted to detect email addresses within the response body, excluding specific file formats in the domain part of the email to enhance accuracy.
  • Loading branch information
BugBountyzip authored Dec 6, 2023
1 parent ca9a812 commit d0a39e7
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Proxy/HTTP/EmailHighlighter.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Script to Filter Out Email Addresses in Responses and Highlight Them if Found
* Author: Tur24Tur
* GitHub: @BugBountyzip (https://github.com/BugBountyzip)
**/

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;

0 comments on commit d0a39e7

Please sign in to comment.