Skip to content

Commit

Permalink
Merge pull request #6 from PortSwigger/examples
Browse files Browse the repository at this point in the history
Add Proxy HTTP filter examples.
  • Loading branch information
ps-porpoise authored Nov 27, 2023
2 parents 7caba30 + 0739fe2 commit 3fdf640
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Proxy/HTTP/FilterOnCookieValue.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Filters Proxy HTTP history for requests with a specific Cookie value.
*
* @author LostCoder
**/

if (requestResponse.request().hasParameter("foo", HttpParameterType.COOKIE)) {
var cookieValue = requestResponse
.request()
.parameter("foo", HttpParameterType.COOKIE)
.value();

return cookieValue.contains("1337");
}

return false;
17 changes: 17 additions & 0 deletions Proxy/HTTP/FindJSONresponsesWithIncorrectContentType.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Finds JSON responses with wrong Content-Type
*
* The content is probably json but the content type is not application/json
*
* @author albinowax
**/

var contentType = requestResponse.hasResponse() ? requestResponse.response().headerValue("Content-Type") : null;

if (contentType != null && !contentType.contains("application/json")) {
String body = requestResponse.response().bodyToString().trim();

return body.startsWith( "{" ) || body.startsWith( "[" );
}

return false;
28 changes: 28 additions & 0 deletions Proxy/HTTP/FindRolesWithinJWTClaims.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Find role within JWT claims
*
* @author Trikster
**/

if (!requestResponse.hasResponse())
{
return false;
}

var body = requestResponse.response().bodyToString().trim();

if (requestResponse.response().hasHeader("authorization")) {
var authValue = requestResponse.response().headerValue("authorization");

if (authValue.startsWith("Bearer ey")) {
var tokens = authValue.split("\\.");

if (tokens.length == 3) {
var decodedClaims = utilities().base64Utils().decode(tokens[1], Base64DecodingOptions.URL).toString();

return decodedClaims.toLowerCase().contains("role");
}
}
}

return false;

0 comments on commit 3fdf640

Please sign in to comment.