nuclei-templates/headless/postmessage-tracker.yaml

67 lines
1.7 KiB
YAML
Raw Normal View History

2021-03-10 08:33:40 +00:00
id: postmessage-tracker
info:
name: Postmessage Tracker
2021-04-06 06:46:11 +00:00
author: pdteam
2021-03-10 08:33:40 +00:00
severity: info
reference:
- https://github.com/vinothsparrow/iframe-broker/blob/main/static/script.js
2021-03-10 08:33:40 +00:00
tags: headless,postmessage
headless:
- steps:
- action: setheader
args:
part: response
key: Content-Security-Policy
value: "default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"
- action: script
args:
hook: true
code: |
(function() {window.alerts = [];
2021-03-10 08:33:40 +00:00
function logger(found) {
window.alerts.push(found);
}
2021-03-10 08:33:40 +00:00
function getStackTrace () {
var stack;
try {
throw new Error('');
}
catch (error) {
stack = error.stack || '';
2021-03-10 08:33:40 +00:00
}
stack = stack.split('\n').map(function (line) { return line.trim(); });
return stack.splice(stack[0] == 'Error' ? 2 : 1);
}
2021-03-10 08:33:40 +00:00
var oldListener = Window.prototype.addEventListener;
2021-03-10 08:33:40 +00:00
Window.prototype.addEventListener = function(type, listener, useCapture) {
if(type === 'message') {
logger(getStackTrace());
}
return oldListener.apply(this, arguments);
};
})();
2021-03-10 08:33:40 +00:00
- args:
url: "{{BaseURL}}"
action: navigate
- action: waitload
- action: script
name: alerts
args:
code: "window.alerts"
matchers:
- type: word
part: alerts
words:
- "at Window.addEventListener"
extractors:
- type: kval
part: alerts
kval:
- alerts