Skip to content

Commit

Permalink
Merge pull request #464 from psiinon/variant/urlparams
Browse files Browse the repository at this point in the history
Added variant/AddUrlParams.js
  • Loading branch information
thc202 authored Aug 21, 2024
2 parents 969560b + c993c4b commit 882dbc0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Standalone script 'PrivateMethodAccess.js'
- Variant script 'AddUrlParams.js'
### Changed
- Add cautionary note to help and readme.
### Fixed
Expand Down
39 changes: 39 additions & 0 deletions variant/AddUrlParams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// The parseParameter function will typically be called for every page and
// the setParameter function is called by each active plugin to bundle specific attacks

// Note that new custom input vector scripts will initially be disabled
// Right click the script in the Scripts tree and select "enable"

/*
This variant script adds arbitrary URL queries to all requests.
It can be used if you know (or suspect) that the target uses these parameters in some cases
and you want to make sure you test them on all pages, whether or not ZAP sees them being used.
*/

var AbstractPlugin = Java.type(
"org.parosproxy.paros.core.scanner.AbstractPlugin"
);

function parseParameters(helper, msg) {
// Add whichever parameters you need here, first is the name, the second is the default value
// In this case they will be appended to all requests, but you can choose to only add
// them to specific requests (like GETs) if you like by adding the relevant conditionals.
helper.addParamQuery("q", "r");
helper.addParamQuery("s", "t");
}

function setParameter(helper, msg, param, value, escaped) {
var uri = msg.getRequestHeader().getURI();
var query = uri.getEscapedQuery();
if (query == null) {
query = "";
} else {
query += "&";
}
query += param + "=";
if (value == null) {
value = "";
}
query += escaped ? value : AbstractPlugin.getURLEncode(value);
uri.setEscapedQuery(query);
}

0 comments on commit 882dbc0

Please sign in to comment.