-
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.
Create HighlightResponsesWithDeveloperNotes
* This script identifies and highlights HTTP responses containing developer notes in HTML, JavaScript, or other files. * It differentiates the types of files and highlights them accordingly: green for HTML, yellow for JavaScript, and blue for other types.
- Loading branch information
1 parent
3deb882
commit f97407b
Showing
1 changed file
with
61 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,61 @@ | ||
/** | ||
* Bambda Script to Highlight Responses with Developer Notes | ||
* This script identifies and highlights HTTP responses containing developer notes in HTML, JavaScript, or other files. | ||
* It differentiates the types of files and highlights them accordingly: green for HTML, yellow for JavaScript, and blue for other types. | ||
* Author: Tur24Tur | ||
* GitHub: @BugBountyzip (https://github.com/BugBountyzip) | ||
**/ | ||
|
||
boolean manualColorHighlightEnabled = true; | ||
Set<String> ignoredExtensions = Set.of("mp4", "mp3", "png", "gif", "jpg", "jpeg", "css", "pdf"); | ||
|
||
if (!requestResponse.hasResponse()) { | ||
return false; | ||
} | ||
|
||
String requestUrl = requestResponse.request().url().toString(); | ||
String fileExtension = requestUrl.substring(requestUrl.lastIndexOf('.') + 1).toLowerCase(); | ||
|
||
if (ignoredExtensions.contains(fileExtension)) { | ||
return false; | ||
} | ||
|
||
String contentType = requestResponse.response().headerValue("Content-Type"); | ||
boolean isHtml = contentType != null && contentType.toLowerCase().contains("text/html"); | ||
boolean isJavaScript = contentType != null && contentType.toLowerCase().contains("application/javascript"); | ||
boolean foundDeveloperNotes = false; | ||
StringBuilder notesBuilder = new StringBuilder(); | ||
HighlightColor highlightColor = HighlightColor.BLUE; // Default color | ||
|
||
if (isHtml || fileExtension.equals("html") || fileExtension.equals("htm")) { | ||
highlightColor = HighlightColor.GREEN; | ||
} else if (isJavaScript || fileExtension.equals("js")) { | ||
highlightColor = HighlightColor.YELLOW; | ||
} | ||
|
||
String responseBody = requestResponse.response().bodyToString(); | ||
String[] commentPatterns = {"<!--(.*?)-->", "/[*][*](.*?)[*][*]/"}; | ||
|
||
for (String pattern : commentPatterns) { | ||
Pattern regexPattern = Pattern.compile(pattern, Pattern.DOTALL); | ||
Matcher matcher = regexPattern.matcher(responseBody); | ||
|
||
while (matcher.find()) { | ||
foundDeveloperNotes = true; | ||
if (manualColorHighlightEnabled) { | ||
if (notesBuilder.length() > 0) { | ||
notesBuilder.append("; "); | ||
} | ||
notesBuilder.append("Developer note found: ").append(matcher.group()); | ||
} | ||
} | ||
} | ||
|
||
if (foundDeveloperNotes) { | ||
requestResponse.annotations().setHighlightColor(highlightColor); | ||
if (manualColorHighlightEnabled && notesBuilder.length() > 0) { | ||
requestResponse.annotations().setNotes(notesBuilder.toString()); | ||
} | ||
} | ||
|
||
return foundDeveloperNotes; |