Task 6 [Try Now]
Objectives:
- Capture all Mouse Clicks and Redirect to http://PentesterAcademy.com
In js, when you are working on browser everytime you interact with the web there are so many events going on the page. For exmaple: mouse moving, keyboard press or event current window active or not.
But in this challenge we have to focus on click event.
The very first I have thought was to list all elements using document.querySelectorAll("*")
and then iterate over each and every node. This is the naive approach and would work efficiently if you have few nodes like in this challenge
So what I thought of is to add the event listener with document itself, because document object itself is an element.
document.addEventListener("click", (evt) => {
evt.preventDefault();
location = "http://PentesterAcademy.com";
});
I could've used function(evt)
, but keeping payload short and simple is also a responsibility of an exploit developer. Similarily with window.location
⇒ location
For POC, Click Here
More Resources