Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Changed
- Update minimum ZAP version to 2.12.0:
- Remove compatibility code that provided the singletons (`control` and `model`) in JavaScript scripts, they can now be accessed directly always.
- Use provided singletons (`control` and `model`) in Python scripts.
- Use non-deprecated `HttpSender` constructor.
- Remove statements that return the message in HTTP Sender scripts, the message passed as parameter is used/sent always.

## [16] - 2023-03-29
Expand Down
3 changes: 1 addition & 2 deletions af-plans/juiceshop-selenium-auth/JuiceShopAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ function authenticate(helper, _paramsValues, _credentials) {
}

logger("Launching browser to authenticate to Juice Shop");
var extSel = control.getSingleton().
getExtensionLoader().getExtension(
var extSel = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.selenium.ExtensionSelenium.class);

// Change to "firefox" (or "chrome") to see the browsers being launched
Expand Down
3 changes: 1 addition & 2 deletions af-plans/juiceshop-selenium-auth/JuiceShopReset.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ if (token) {
}

// Reset the state for all users
var extUser = control.getSingleton().
getExtensionLoader().getExtension(
var extUser = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.users.ExtensionUserManagement.class);
var session = model.getSession();
var contexts = session.getContexts();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ val scriptsDir = layout.buildDirectory.dir("scripts")
zapAddOn {
addOnId.set("communityScripts")
addOnName.set("Community Scripts")
zapVersion.set("2.11.0")
zapVersion.set("2.12.0")
addOnStatus.set(AddOnStatus.ALPHA)

releaseLink.set("https://github.com/zaproxy/community-scripts/compare/v@PREVIOUS_VERSION@...v@CURRENT_VERSION@")
Expand Down
5 changes: 0 additions & 5 deletions extender/Simple Reverse Proxy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// An extender script that adds a simple reverse proxy.
// Requires a ZAP version greater than 2.7.0.

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

// To where the requests are sent.
var remoteAddress = "example.com"
Expand Down
3 changes: 0 additions & 3 deletions httpfuzzerprocessor/add_msgs_sites_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// with messages sent by the fuzzer (by default the fuzz result/messages
// are not shown in the Fuzzer tab).

var model;
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton();

var session = model.getSession();

function processMessage(utils, message) {}
Expand Down
4 changes: 0 additions & 4 deletions httpsender/Alert on HTTP Response Code Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// By default it will raise 'Info' level alerts for Client Errors (4xx) (apart from 404s) and 'Low' Level alerts for Server Errors (5xx)
// But it can be easily changed.

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var Pattern = Java.type("java.util.regex.Pattern")
pluginid = 100000 // https://github.com/zaproxy/zaproxy/blob/main/docs/scanners.md

Expand Down
4 changes: 0 additions & 4 deletions httpsender/Alert on Unexpected Content Types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// By default it will raise 'Low' level alerts for content types that are not expected to be returned by APIs.
// But it can be easily changed.

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var Pattern = Java.type("java.util.regex.Pattern")

var pluginid = 100001 // https://github.com/zaproxy/zaproxy/blob/main/docs/scanners.md
Expand Down
3 changes: 0 additions & 3 deletions standalone/Active scan rule list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// This script gives details about all of the active scan rules installed

var control;
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton();

extAscan = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.ascan.ExtensionActiveScan.NAME);

Expand Down
3 changes: 0 additions & 3 deletions standalone/Juice shop authentication by form.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
// a user with a name of test@test.com and a password of test123
// You can change any of the variables to match your environment if needed.

var control;
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton();

var By = Java.type('org.openqa.selenium.By');
var Thread = Java.type('java.lang.Thread');
var juiceshop = 'http://localhost:3000/';
Expand Down
3 changes: 0 additions & 3 deletions standalone/Juice shop authentication by google.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Juice Shop will need to be accessible via http://localhost:3000/ and you will need to change the
// username and password to match a valid Google account.

var control
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

var By = Java.type('org.openqa.selenium.By');
var Thread = Java.type('java.lang.Thread');
var juiceshop = 'http://localhost:3000/';
Expand Down
3 changes: 0 additions & 3 deletions standalone/Loop through alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//
// This is a standalone script which you can run from the Script Console

var control
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extAlert = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.alert.ExtensionAlert.NAME)
if (extAlert != null) {
Expand Down
3 changes: 0 additions & 3 deletions standalone/Loop through history table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Standalone scripts have no template.
// They are only evaluated when you run them.

var control
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extHist = control.getExtensionLoader().getExtension(
org.parosproxy.paros.extension.history.ExtensionHistory.NAME)
if (extHist != null) {
Expand Down
3 changes: 0 additions & 3 deletions standalone/SecurityCrawlMazeScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//
// You will need to have run one or both of the ZAP spiders against https://security-crawl-maze.app/

var model
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

// Expected results sourced from:
// https://raw.githubusercontent.com/google/security-crawl-maze/master/blueprints/utils/resources/expected-results.json

Expand Down
3 changes: 0 additions & 3 deletions standalone/Traverse sites tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Standalone scripts have no template.
// They are only evaluated when you run them.

var model
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

function listChildren(node, level) {
var j;
for (j=0;j<node.getChildCount();j++) {
Expand Down
2 changes: 1 addition & 1 deletion standalone/WebSocketExportToOrg.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
reload(sys)
sys.setdefaultencoding('utf-8')

extWebSocket = Control.getSingleton().getExtensionLoader().getExtension(ExtensionWebSocket.NAME)
extWebSocket = control.getExtensionLoader().getExtension(ExtensionWebSocket.NAME)
pathToOrgFile = "/path/to/file.org"
printSummary = True
base = PyOrgMode.OrgDataStructure()
Expand Down
3 changes: 0 additions & 3 deletions standalone/alertAndPluginDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* It's tab separated so you can simply copy/paste it into Excel (or whatever).
*/

var control
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extAlert = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.alert.ExtensionAlert.NAME)

Expand Down
4 changes: 2 additions & 2 deletions standalone/extHistoryEnumerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from org.parosproxy.paros.view import AbstractFrame;
from org.zaproxy.zap.utils import ZapTextArea;

sessionId = Model.getSingleton().getSession();
tbHist = Model.getSingleton().getDb().getTableHistory();
sessionId = model.getSession();
tbHist = model.getDb().getTableHistory();

""" Change this variable to match the expression you are looking for """
regex='soapactio.+';
Expand Down
3 changes: 0 additions & 3 deletions standalone/historySourceTagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Author: kingthorin+owaspzap@gmail.com
// 20160207: Initial release

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extHist = control.getExtensionLoader().
getExtension(org.parosproxy.paros.extension.history.ExtensionHistory.NAME);

Expand Down
2 changes: 1 addition & 1 deletion standalone/load_context_from_burp.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def build_proper_regex(protocol, host):


def create_new_context(ctx_name):
session = Model().getSingleton().getSession()
session = model.getSession()
new_context = session.getNewContext(ctx_name)
return new_context

Expand Down
4 changes: 2 additions & 2 deletions standalone/past_cookies_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
""" Change this regex to match the desired domain """
cookie_domain_regex = ".+"

sessionId = Model.getSingleton().getSession();
tbHist = Model.getSingleton().getDb().getTableHistory();
sessionId = model.getSession();
tbHist = model.getDb().getTableHistory();

def collect(msg):
""" Collecting cookie from HttpMessage """
Expand Down
3 changes: 0 additions & 3 deletions standalone/scan_rule_list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// This script gives details about all of the scan rules installed

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extAscan = control.getExtensionLoader().getExtension(
org.zaproxy.zap.extension.ascan.ExtensionActiveScan.NAME);

Expand Down
5 changes: 2 additions & 3 deletions targeted/ElasticSearchExploit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// Shoutout to /u/cartogram for the POC rce command
// Requires elasticsearch running, default port is 9200 check via nmap/portscanner

var model
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()
var HttpSender = Java.type("org.parosproxy.paros.network.HttpSender")

function invokeWith(msg) {
// give the user some info
Expand All @@ -27,7 +26,7 @@ function invokeWith(msg) {
// update the length to take in account of the changes
msg.getRequestHeader().setContentLength(msg.getRequestBody().length());
// create a new sender
var sender = new org.parosproxy.paros.network.HttpSender(model.getOptionsParam().getConnectionParam(), true, 6)
var sender = new HttpSender(HttpSender.MANUAL_REQUEST_INITIATOR)
// send our new request
sender.sendAndReceive(msg)

Expand Down
3 changes: 0 additions & 3 deletions targeted/Find largest subtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ tot = 0
maxparent = ""
maxsub = 0

var model
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

function recurseDown(node) {
//print('recurseDown node: ' + node.getHierarchicNodeName() + " " + node.getChildCount())
tot++
Expand Down
3 changes: 0 additions & 3 deletions targeted/Remove 302s.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// The default criteria is leaf nodes with a response code of 302 but you can change that to anything you need
// Targeted scripts can only be invoked by you, the user, eg via a right-click option on the Sites or History tabs

var model
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

function recurseDown(sitestree, node) {
//print('recurseDown node: ' + node.getHierarchicNodeName() + " " + node.getChildCount())
// Loop down through the children first
Expand Down
7 changes: 1 addition & 6 deletions targeted/WordPress User Enumeration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@

var pluginid = 100032;

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var URI = Java.type("org.apache.commons.httpclient.URI");
var HttpSender = Java.type("org.parosproxy.paros.network.HttpSender");
var HistoryReference = Java.type("org.parosproxy.paros.model.HistoryReference");
var ExtensionAlert = Java.type("org.zaproxy.zap.extension.alert.ExtensionAlert");
var Alert = Java.type("org.parosproxy.paros.core.scanner.Alert");

var session = model.getSession();
var connectionParams = model.getOptionsParam().getConnectionParam();
var extLoader = control.getExtensionLoader();

// Print statements using script name
Expand Down Expand Up @@ -155,7 +150,7 @@ function sendReq(msg, query) {
isNaN(query) ? uri.setPath(query) : uri.setQuery("author=" + query);
logger("URL -> " + uri.toString());
// Initialise the sender
var sender = new HttpSender(connectionParams, true, 6);
var sender = new HttpSender(HttpSender.MANUAL_REQUEST_INITIATOR);
// Send and Receive Request
sender.sendAndReceive(newReq);
// Debugging
Expand Down
6 changes: 1 addition & 5 deletions targeted/cve-2021-22214.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

var pluginid = 100024;

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var HttpSender = Java.type("org.parosproxy.paros.network.HttpSender")
var HistoryReference = Java.type("org.parosproxy.paros.model.HistoryReference")
var HttpHeader = Java.type("org.parosproxy.paros.network.HttpHeader")
Expand Down Expand Up @@ -88,7 +84,7 @@ function invokeWith(msg) {
*/
function sendReq(msg) {
var newReq = generateRequest(msg);
var sender = new HttpSender(model.getOptionsParam().getConnectionParam(), true, 6)
var sender = new HttpSender(HttpSender.MANUAL_REQUEST_INITIATOR)
sender.sendAndReceive(newReq);
// Debugging
// logger("Request Header -> " + newReq.getRequestHeader().toString())
Expand Down
7 changes: 1 addition & 6 deletions targeted/cve-2021-41773-apache-path-trav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
* Based on: https://github.com/RootUp/PersonalStuff/blob/master/http-vuln-cve-2021-41773.nse
*/

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var HttpSender = Java.type("org.parosproxy.paros.network.HttpSender")
var HistoryReference = Java.type("org.parosproxy.paros.model.HistoryReference")
var HttpHeader = Java.type("org.parosproxy.paros.network.HttpHeader")
Expand Down Expand Up @@ -43,8 +39,7 @@ function invokeWith(msg) {
logger("Testing Script against URL - " + url);

msg.getRequestHeader().getURI().setEscapedPath(attackPath);
var connectionParams = model.getOptionsParam().getConnectionParam();
var sender = new HttpSender(connectionParams, true, 6);
var sender = new HttpSender(HttpSender.MANUAL_REQUEST_INITIATOR);
sender.sendAndReceive(msg);
var status = msg.getResponseHeader().getStatusCode();
var rebody = msg.getResponseBody().toString();
Expand Down
7 changes: 1 addition & 6 deletions targeted/dns-email-spoofing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
var pluginid = 100031;
var providerAddress = "dns.google";

var control, model
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()
if (!model) model = Java.type("org.parosproxy.paros.model.Model").getSingleton()

var URI = Java.type("org.apache.commons.httpclient.URI");
var HttpSender = Java.type("org.parosproxy.paros.network.HttpSender");
var HistoryReference = Java.type("org.parosproxy.paros.model.HistoryReference");
var ExtensionAlert = Java.type("org.zaproxy.zap.extension.alert.ExtensionAlert");
var Alert = Java.type("org.parosproxy.paros.core.scanner.Alert");

var session = model.getSession();
var connectionParams = model.getOptionsParam().getConnectionParam();
var extLoader = control.getExtensionLoader();

// Print statements using script name
Expand Down Expand Up @@ -121,7 +116,7 @@ function fetchRecords(msg, policy) {
msg.getRequestHeader().setURI(requestUri);
logger("Fetching TXT records for domain - " + domain);

var sender = new HttpSender(connectionParams, true, 6);
var sender = new HttpSender(HttpSender.MANUAL_REQUEST_INITIATOR);
sender.sendAndReceive(msg);
// Debugging
// logger("Request Header -> " + msg.getRequestHeader().toString())
Expand Down