Skip to content

Added variant/AddUrlParams.js #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}