Skip to content

Commit c993c4b

Browse files
committed
Added variant/AddUrlParams.js
I was going to add this to the core, then realised this would be much easier and more flexible :D Signed-off-by: Simon Bennetts <[email protected]>
1 parent 969560b commit c993c4b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
## [Unreleased]
77
### Added
88
- Standalone script 'PrivateMethodAccess.js'
9+
- Variant script 'AddUrlParams.js'
910
### Changed
1011
- Add cautionary note to help and readme.
1112
### Fixed

variant/AddUrlParams.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// The parseParameter function will typically be called for every page and
2+
// the setParameter function is called by each active plugin to bundle specific attacks
3+
4+
// Note that new custom input vector scripts will initially be disabled
5+
// Right click the script in the Scripts tree and select "enable"
6+
7+
/*
8+
This variant script adds arbitrary URL queries to all requests.
9+
It can be used if you know (or suspect) that the target uses these parameters in some cases
10+
and you want to make sure you test them on all pages, whether or not ZAP sees them being used.
11+
*/
12+
13+
var AbstractPlugin = Java.type(
14+
"org.parosproxy.paros.core.scanner.AbstractPlugin"
15+
);
16+
17+
function parseParameters(helper, msg) {
18+
// Add whichever parameters you need here, first is the name, the second is the default value
19+
// In this case they will be appended to all requests, but you can choose to only add
20+
// them to specific requests (like GETs) if you like by adding the relevant conditionals.
21+
helper.addParamQuery("q", "r");
22+
helper.addParamQuery("s", "t");
23+
}
24+
25+
function setParameter(helper, msg, param, value, escaped) {
26+
var uri = msg.getRequestHeader().getURI();
27+
var query = uri.getEscapedQuery();
28+
if (query == null) {
29+
query = "";
30+
} else {
31+
query += "&";
32+
}
33+
query += param + "=";
34+
if (value == null) {
35+
value = "";
36+
}
37+
query += escaped ? value : AbstractPlugin.getURLEncode(value);
38+
uri.setEscapedQuery(query);
39+
}

0 commit comments

Comments
 (0)