Skip to content

Instantly share code, notes, and snippets.

@ChieftainY2k
Created September 18, 2023 11:22
Show Gist options
  • Save ChieftainY2k/e363a09ca5e3eb8518bd6604585a3805 to your computer and use it in GitHub Desktop.
Save ChieftainY2k/e363a09ca5e3eb8518bd6604585a3805 to your computer and use it in GitHub Desktop.
ZED PROXY XSS alert(1) passive scan
//Passive scan for XSS JS alert(1)
function scan(ps, msg, src) {
var alertRisk = 2
var alertConfidence = 3
var alertTitle = 'Successful XSS attack'
var alertDesc = 'Successful XSS attack'
var alertSolution = 'Investigate Successful XSS attack, remove or mask as required'
var cweId = 79
var wascId = 8
var re = /<script>alert\(1\)/i
var url = msg.getRequestHeader().getURI().toString()
var contentType = msg.getResponseHeader().getHeader("Content-Type")
var unwantedFileTypes = ['image/png', 'image/jpeg','image/gif','application/x-shockwave-flash','application/pdf']
if (unwantedFileTypes.indexOf(""+contentType) >= 0) {
return
}
var body = msg.getResponseBody().toString()
if (re.test(body)) {
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDesc, url, '', '', body, alertSolution, body, cweId, wascId, msg)
console.log("Successful XSS attack detected");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment