Home > Article > Web Front-end > Javascript injection skills_javascript skills
Author: kostis90gr
Translation: Dark Soul [S.S.T]
This article has been published in the June issue of "Hacker Defense". The copyright belongs to "Hacker Defense" and the Script Security Team. Please maintain the integrity of the article when reprinting it, thank you :)
This guide is for reporting purposes only, I am not responsible if anyone uses it for illegal purposes.
By using javascript injection, the user does not have to close the website or save the page in his You can change the content of the website on your PC. This is done from the address bar of his browser. The syntax of the
command looks like this:
Copy code
javascrit :alert(#command#)
For example, if you want to see an alert box on the website http://www.example.com, then first enter the URL (www.example.com) in the address bar ), when the page is loaded, clear the URL and enter javascrit:alert("Hello World") as a new URL. This will pop up an alert box showing Hello World. However, some people will use this technique to change almost everything in the page. Any content. For example, a picture. Let us imagine that there is a logo picture of a website. By viewing the page source code (you can use "View Source Code" in the browser), we find an HTML code:
Copy code
Get information: There is a picture named hi, and the source file is hello.gif. We want Change it to bye.jpeg and store it on our site http://www.mysite.com. So the full URL of our image is http://www.mysite.com/bye.jpeg To use javascript injection, we Need to enter in the address bar:
Copy code
javascript:alert(document.hi.src="[url]http://www.mysite.com/bye.jpeg"[/url] )
You will see a tooltip saying http://www.mysite.com/bye.jpeg, and after that the image will be changed. Note though that those changes are only temporary! If you refresh Page or enter again, the changes you made will be lost, because what you changed is not the site on the server, but on your PC.
Using the same method, we can view or change the value of the variable. For example We found some source codes like this on the website:
Copy code
means assigning test to variable a. In order to view the value of the variable, we will enter:
Copy code
javascript:alert(a)
and then in order to change it from If test is changed to hello, enter:
Copy code
javascript:alert(a="hello")
But javascript injection is mainly used to change the attributes of the form. Here is what we have done Some codes:
Copy code