Skip to content

Commit

Permalink
Create DetectDeprecatedHTMLTags.bambda
Browse files Browse the repository at this point in the history
  • Loading branch information
BugBountyzip authored Apr 5, 2024
1 parent a529711 commit 72e5c60
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Proxy/HTTP/DetectDeprecatedHTMLTags.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Bambda Script to Detect and Highlight Deprecated HTML Tags
* @author Tur24Tur / BugBountyzip (https://github.com/BugBountyzip)
* This script identifies deprecated HTML tags in HTTP responses.
* Upon detection, responses are highlighted in red and notes are appended, if enabled.
**/

boolean enableManualAnnotations = true;

// Ensure there is a response
if (!requestResponse.hasResponse()) {
return false;
}

// Get the Content-Type header of the response
String contentType = requestResponse.response().headerValue("Content-Type");
if (contentType == null || !contentType.toLowerCase().contains("text/html")) {
// Ignore responses without a Content-Type header of text/html; charset=utf-8
return false;
}

String responseBody = requestResponse.response().bodyToString();
boolean foundDeprecatedHTML = false;
StringBuilder notesBuilder = new StringBuilder();

// Expanded list of common deprecated HTML tags and attributes
List<String> deprecatedHTML = Arrays.asList("applet", "basefont", "center", "dir", "font", "isindex", "menu", "strike", "u", "frame", "frameset", "marquee", "bgsound");

for (String deprecatedTag : deprecatedHTML) {
Pattern pattern = Pattern.compile("<\\s*" + deprecatedTag + "(\\s|>).+?<\\/\\s*" + deprecatedTag + "\\s*>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(responseBody);
if (matcher.find()) {
foundDeprecatedHTML = true;
if (enableManualAnnotations) {
if (notesBuilder.length() > 0) {
notesBuilder.append(", ");
}
notesBuilder.append("Deprecated HTML detected: <").append(deprecatedTag).append(">");
}
}
}

if (foundDeprecatedHTML && enableManualAnnotations) {
requestResponse.annotations().setHighlightColor(HighlightColor.RED);
if (notesBuilder.length() > 0) {
requestResponse.annotations().setNotes(notesBuilder.toString());
}
}

return foundDeprecatedHTML;

0 comments on commit 72e5c60

Please sign in to comment.