Skip to content

Commit 5c4ca0e

Browse files
committed
Updated JS scripts and removed links to vids
Signed-off-by: Simon Bennetts <[email protected]>
1 parent 3d50c3b commit 5c4ca0e

File tree

6 files changed

+88
-50
lines changed

6 files changed

+88
-50
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1414
- Update minimum ZAP version to 2.16.0 and compile with Java 17.
1515
- Add cautionary note to help and readme.
1616
- Maintenance and documentation changes.
17+
- Active and passive READMEs to include lastest JS script examples.
1718

1819
### Fixed
1920
- The following scripts were not being loaded as scan rules:
2021
- active/SSTI.js
2122
- passive/Mutliple Security Header Check.js
2223

24+
### Removed
25+
- Links to videos which no longer exist.
26+
2327
## [19] - 2024-07-01
2428
### Added
2529
- extender/arpSyndicateSubdomainDiscovery.js - uses the API of [ARPSyndicate's Subdomain Center](https://www.subdomain.center/)

active/README.md

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,47 @@ These detect potential vulnerabilities by actively attacking the target, run as
99
// Note that new active scripts will initially be disabled
1010
// Right click the script in the Scripts tree and select "enable"
1111

12+
const ScanRuleMetadata = Java.type("org.zaproxy.addon.commonlib.scanrules.ScanRuleMetadata");
13+
14+
function getMetadata() {
15+
return ScanRuleMetadata.fromYaml(`
16+
id: 12345
17+
name: Active Vulnerability Title
18+
description: Full description
19+
solution: The solution
20+
references:
21+
- https://www.example.org/reference1
22+
- https://www.example.org/reference2
23+
category: INJECTION # info_gather, browser, server, misc, injection
24+
risk: INFO # info, low, medium, high
25+
confidence: LOW # false_positive, low, medium, high, user_confirmed
26+
cweId: 0
27+
wascId: 0
28+
alertTags:
29+
name1: value1
30+
name2: value2
31+
otherInfo: Any other Info
32+
status: alpha
33+
alertRefOverrides:
34+
12345-1: {}
35+
12345-2:
36+
name: Active Vulnerability - Type XYZ
37+
description: Overridden description
38+
`);
39+
}
40+
1241
/**
1342
* Scans a "node", i.e. an individual entry in the Sites Tree.
1443
* The scanNode function will typically be called once for every page.
1544
*
1645
* @param as - the ActiveScan parent object that will do all the core interface tasks
1746
* (i.e.: sending and receiving messages, providing access to Strength and Threshold settings,
18-
* raising alerts, etc.). This is an ScriptsActiveScanner object.
47+
* raising alerts, etc.). This is an ActiveScriptHelper object.
1948
* @param msg - the HTTP Message being scanned. This is an HttpMessage object.
2049
*/
2150
function scanNode(as, msg) {
22-
// Debugging can be done using println like this
23-
print('scan called for url=' + msg.getRequestHeader().getURI().toString());
51+
// Debugging can be done using print like this
52+
print('scanNode called for url=' + msg.getRequestHeader().getURI().toString());
2453

2554
// Copy requests before reusing them
2655
msg = msg.cloneRequest();
@@ -49,19 +78,33 @@ function scanNode(as, msg) {
4978
}
5079
}
5180

81+
/**
82+
* Scans a host.
83+
* The scanHost function will be called once per host being scanned.
84+
* @param as - the ActiveScan parent object that will do all the core interface tasks
85+
* (i.e.: sending and receiving messages, providing access to Strength and Threshold settings,
86+
* raising alerts, etc.). This is an ActiveScriptHelper object.
87+
* @param msg - the HTTP Message being scanned. This is an HttpMessage object.
88+
*/
89+
function scanHost(as, msg) {
90+
// Debugging can be done using print like this
91+
const uri = msg.getRequestHeader().getURI();
92+
print(`scanHost called for host=${uri.getHost()}` + (uri.getPort() !== -1 ? `:${uri.getPort()}` : ""));
93+
}
94+
5295
/**
5396
* Scans a specific parameter in an HTTP message.
5497
* The scan function will typically be called for every parameter in every URL and Form for every page.
5598
*
5699
* @param as - the ActiveScan parent object that will do all the core interface tasks
57100
* (i.e.: sending and receiving messages, providing access to Strength and Threshold settings,
58-
* raising alerts, etc.). This is an ScriptsActiveScanner object.
101+
* raising alerts, etc.). This is an ActiveScriptHelper object.
59102
* @param msg - the HTTP Message being scanned. This is an HttpMessage object.
60103
* @param {string} param - the name of the parameter being manipulated for this test/scan.
61104
* @param {string} value - the original parameter value.
62105
*/
63106
function scan(as, msg, param, value) {
64-
// Debugging can be done using println like this
107+
// Debugging can be done using print like this
65108
print('scan called for url=' + msg.getRequestHeader().getURI().toString() +
66109
' param=' + param + ' value=' + value);
67110

@@ -76,21 +119,11 @@ function scan(as, msg, param, value) {
76119

77120
// Test the response here, and make other requests as required
78121
if (true) { // Change to a test which detects the vulnerability
79-
// risk: 0: info, 1: low, 2: medium, 3: high
80-
// confidence: 0: falsePositive, 1: low, 2: medium, 3: high, 4: confirmed
81-
as.newAlert()
82-
.setRisk(1)
83-
.setConfidence(1)
84-
.setName('Active Vulnerability title')
85-
.setDescription('Full description')
122+
// Call newAlert() if you're not using alertRefOverrides
123+
as.newAlert("12345-1")
86124
.setParam(param)
87125
.setAttack('Your attack')
88126
.setEvidence('Evidence')
89-
.setOtherInfo('Any other info')
90-
.setSolution('The solution')
91-
.setReference('References')
92-
.setCweId(0)
93-
.setWascId(0)
94127
.setMessage(msg)
95128
.raise();
96129
}
@@ -111,8 +144,3 @@ function scan(as, msg, param, value) {
111144
* Jruby : [Active default template.rb](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jruby/src/main/zapHomeFiles/scripts/templates/active/Active%20default%20template.rb)
112145
* Jython : [Active default template.py](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jython/src/main/zapHomeFiles/scripts/templates/active/Active%20default%20template.py)
113146
* Zest : [Active default template.zst](https://github.com/zaproxy/zap-extensions/blob/main/addOns/zest/src/main/zapHomeFiles/scripts/templates/active/Active%20default%20template.zst)
114-
115-
116-
## Official Videos
117-
118-
[ZAP In Ten: Active Scan Scripts](https://play.sonatype.com/watch/aEwqErXFMTYdDDQbTgnJeA) (11:38)

httpsender/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,3 @@ function responseReceived(msg, initiator, helper) {
5252
* Jython : [HttpSender default template.py](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jython/src/main/zapHomeFiles/scripts/templates/httpsender/HttpSender%20default%20template.py)
5353
* Zest : [HttpSender default template.zst](https://github.com/zaproxy/zap-extensions/blob/main/addOns/zest/src/main/zapHomeFiles/scripts/templates/httpsender/HttpSender%20default%20template.zst)
5454

55-
## Official Videos
56-
57-
[ZAP In Ten: Proxy and HttpSender Scripts](https://play.sonatype.com/watch/4no8EY1iB8RdnQLPFpYi2a) (10:14)

passive/README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,35 @@ These detect potential vulnerabilities by passively analysing traffic to and fro
1111
// Note that new passive scripts will initially be disabled
1212
// Right click the script in the Scripts tree and select "enable"
1313

14-
var PluginPassiveScanner = Java.type("org.zaproxy.zap.extension.pscan.PluginPassiveScanner");
14+
const PluginPassiveScanner = Java.type("org.zaproxy.zap.extension.pscan.PluginPassiveScanner");
15+
const ScanRuleMetadata = Java.type("org.zaproxy.addon.commonlib.scanrules.ScanRuleMetadata");
16+
17+
function getMetadata() {
18+
return ScanRuleMetadata.fromYaml(`
19+
id: 12345
20+
name: Passive Vulnerability Title
21+
description: Full description
22+
solution: The solution
23+
references:
24+
- https://www.example.org/reference1
25+
- https://www.example.org/reference2
26+
risk: INFO # info, low, medium, high
27+
confidence: LOW # false_positive, low, medium, high, user_confirmed
28+
cweId: 0
29+
wascId: 0
30+
alertTags:
31+
name1: value1
32+
name2: value2
33+
otherInfo: Any other info
34+
status: alpha
35+
alertRefOverrides:
36+
12345-1: {}
37+
12345-2:
38+
name: Passive Vulnerability - Type XYZ
39+
description: Overridden description
40+
`);
41+
}
42+
1543

1644
/**
1745
* Passively scans an HTTP message. The scan function will be called for
@@ -20,7 +48,7 @@ var PluginPassiveScanner = Java.type("org.zaproxy.zap.extension.pscan.PluginPass
2048
*
2149
* @param ps - the PassiveScan parent object that will do all the core interface tasks
2250
* (i.e.: providing access to Threshold settings, raising alerts, etc.).
23-
* This is an ScriptsPassiveScanner object.
51+
* This is a PassiveScriptHelper object.
2452
* @param msg - the HTTP Message being scanned. This is an HttpMessage object.
2553
* @param src - the Jericho Source representation of the message being scanned.
2654
*/
@@ -29,22 +57,14 @@ function scan(ps, msg, src) {
2957
if (true) { // Change to a test which detects the vulnerability
3058
// risk: 0: info, 1: low, 2: medium, 3: high
3159
// confidence: 0: falsePositive, 1: low, 2: medium, 3: high, 4: confirmed
32-
ps.newAlert()
33-
.setRisk(1)
34-
.setConfidence(1)
35-
.setName('Passive Vulnerability title')
36-
.setDescription('Full description')
60+
// Call newAlert() if you're not using alertRefOverrides
61+
ps.newAlert("12345-1")
3762
.setParam('The param')
3863
.setEvidence('Evidence')
39-
.setOtherInfo('Any other info')
40-
.setSolution('The solution')
41-
.setReference('References')
42-
.setCweId(0)
43-
.setWascId(0)
4464
.raise();
4565

46-
//addTag(String tag)
47-
ps.addTag('tag')
66+
//addHistoryTag(String tag)
67+
ps.addHistoryTag('tag')
4868
}
4969

5070
// Raise less reliable alert (that is, prone to false positives) when in LOW alert threshold
@@ -84,6 +104,4 @@ function appliesToHistoryType(historyType) {
84104
* Jython : [Passive default template.py](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jython/src/main/zapHomeFiles/scripts/templates/passive/Passive%20default%20template.py)
85105
* Zest : [Passive default template.zst](https://github.com/zaproxy/zap-extensions/blob/main/addOns/zest/src/main/zapHomeFiles/scripts/templates/passive/Passive%20default%20template.zst)
86106

87-
## Official Videos
88107

89-
[ZAP In Ten: Passive Scan Scripts](https://play.sonatype.com/watch/HfENJ3GJB3zbD6sMscDrjD) (11:55)

proxy/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,3 @@ function proxyResponse(msg) {
5555
* Jython : [Proxy default template.py](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jython/src/main/zapHomeFiles/scripts/templates/proxy/Proxy%20default%20template.py)
5656
* Zest : [Proxy default template.zst](https://github.com/zaproxy/zap-extensions/blob/main/addOns/zest/src/main/zapHomeFiles/scripts/templates/proxy/Proxy%20default%20template.zst)
5757

58-
59-
## Official Videos
60-
61-
[ZAP In Ten: Proxy and HttpSender Scripts](https://play.sonatype.com/watch/4no8EY1iB8RdnQLPFpYi2a) (10:14)
62-

targeted/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,3 @@ function invokeWith(msg) {
3030
* Jruby : [Targeted default template.rb](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jruby/src/main/zapHomeFiles/scripts/templates/targeted/Targeted%20default%20template.rb)
3131
* Jython : [Targeted default template.py](https://github.com/zaproxy/zap-extensions/blob/main/addOns/jython/src/main/zapHomeFiles/scripts/templates/targeted/Targeted%20default%20template.py)
3232
* Zest : [Targeted default template.zst](https://github.com/zaproxy/zap-extensions/blob/main/addOns/zest/src/main/zapHomeFiles/scripts/templates/targeted/Targeted%20default%20template.zst)
33-
34-
## Official Videos
35-
36-
[ZAP In Ten: Targeted Scripts](https://play.sonatype.com/watch/JzX1YkJqdk7BYTMHikh433) (10:01)

0 commit comments

Comments
 (0)