Javascript for Pentester Task 5

Hello all today I am going to post another solution to the task provided at Javascript for Pentester at Pentester Academy. This task is again focused on how to play with forms in Javascript. You can view solutions to the other tasks here.

Task 5: Social Engineering | Task Link

In this task, we have to do some social engineering with XSS. This task is pretty simple, you have to just remove the form element and add a new element with text as “Website is Down! Please visit”.
To complete the task we have to start by investigating the source code, where we have to find our target area and that is form tag. Copy and URL-encode the code provided below and paste it after the url parameter in the URL bar

var frmcon = document.forms[0];
var a = document.createElement('A');
atxt = document.createTextNode('Website is Down! Please visit');
a.setAttribute("href", "");

First two lines of code will remove the form element and next four lines will create a new element, in my case I create an anchor or link with <a> tag and assign it a string value ‘Website is Down! Please visit’ and link to some hackers site. The last line will go and append the newly created child to the fourth div element (manually figured).
Replacement of form child node with another does not seem to work for me, maybe browser issues, that is why I create a new child node and append it to the div tag.
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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Send us Query
close slider