Javascript for Pentester Task 8

Hello Security Guys, today I am going to post another solution to the task provided at Javascript for Pentester at Pentester Academy. In this task, we will learn how to use event listeners, how an attacker can play more with these event listeners. You can view solutions to the other tasks here.

Task 8: Event Listener | Task Link

The task is just a play, this task is pretty much designed for extending our understanding with Javascript. In task 8, we have to pop an alert with password inside it when a user clicks on submit button.
In this task, the injection point is changed to ’email’ and our old <script> tag does not work due to special character escaping used at the server end and that we can verify by viewing the source code of the page. For this to complete, we will use event listeners like “onmouseover”, “onmouseclick” etc.

"onmouseover="function eventlistener(){alert(document.forms[0].elements[1].value);} document.forms[0].onsubmit = eventlistener;

Copy and URL-encode the code and paste it after the ’email’ parameter on the same page and send it to your victim. When victim enters his/her email-id and password into the field and clicks submit button, the javascript will run and pops an alert with password inside it. I will prefer to use Firefox for doing this, as chrome does not allow XSS to happen with its XSS-Auditor.
That’s all. Refer this post as a quick solution for the Javascript for Pentester tasks. For an in-depth video tutorial, please refer to the video solutions provided at Pentester Academy website.