Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Latest commit

 

History

History
30 lines (19 loc) · 1.83 KB

TASK_6.md

File metadata and controls

30 lines (19 loc) · 1.83 KB

Task 6 [Try Now]

Objectives:

  1. 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.locationlocation

For POC, Click Here

More Resources

  1. Difference between onclick and addEventListener("click")
  2. window.location vs location
  3. Normal functions vs arrow function