Skip to content

Commit d2bc3aa

Browse files
committed
add file AddHeaderXFowardForRandomIP.js to httpsender
1 parent ea1849e commit d2bc3aa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @author Ruffenach Timothée
2+
// Add in Header response X-Forwarded-For: Random IP
3+
// The sendingRequest and responseReceived functions will be called for all requests/responses sent/received by ZAP,
4+
// including automated tools (e.g. active scanner, fuzzer, ...)
5+
6+
// Note that new HttpSender scripts will initially be disabled
7+
// Right click the script in the Scripts tree and select "enable"
8+
9+
// For the latest list of 'initiator' values see the HttpSender class:
10+
// https://github.com/zaproxy/zaproxy/blob/main/zap/src/main/java/org/parosproxy/paros/network/HttpSender.java
11+
// 'helper' just has one method at the moment: helper.getHttpSender() which returns the HttpSender
12+
// instance used to send the request.
13+
14+
// In order to facilitate identifying ZAP traffic and Web Application Firewall exceptions, ZAP is accompanied
15+
// by this script which can be used to add a specific header to all traffic that passes through
16+
// or originates from ZAP. e.g.: X-ZAP-Initiator: 3
17+
18+
function sendingRequest(msg, initiator, helper) {
19+
var random_ip = Math.floor(Math.random() * 254)+ "." + Math.floor(Math.random() * 254) + "." + Math.floor(Math.random() * 254) + "." + Math.floor(Math.random() * 254);
20+
msg.getRequestHeader().setHeader("X-Forwarded-For", random_ip);
21+
}
22+
23+
function responseReceived(msg, initiator, helper) {
24+
// Nothing to do here
25+
}

0 commit comments

Comments
 (0)