Javascript Injection is a facility by which we can insert our own javascript codes into the websites, either by entering the code into the address bar, or by finding an XSS(Cross site Scripting) vulnerability in a website. Note that the changes can only be seen by you and are not permanent. This is because JavaScript is a ‘client-side’ language.
This can be very useful when one needs to spoof the server by editing some form option.
Javascript Injection Shall be briefly covered up in the following three parts
1. Injection Basics
2. Cookie Editing
3. Form Editing
1. Injection Basics
Javascript injections are run from the URL bar of the page you are visiting. To use them, you must first completly empty the URL from the URL bar.
Javascript is run from the URL bar by using the javascript: protocol. If you are a Javascript expert, you can expand on this using plain old javascript.
The two commands covered in this Article are the alert(); and void(); commands. These are pretty much all you will need in most situations. For your first javascript, you will make a simple window appear, first go to any website and then type the following into your URL bar:
javascript:alert(’Hello, World’);
You should get a little dialog box that says “Hello, World”. This will be altered later to have more practical uses.
You can also have more than one command run at the same time:
javascript:alert(’Hello’); alert(’World’);
This would pop up a box that said ‘Hello’ and than another that says ‘World’.
2. Cookie Editing
DO NOT USE THIS INFORMATION TO COMMIT CYBER CRIMES
First off, check to see if the site you are visiting has set any cookies by using this script:
javascript:alert(document.cookie);
This will pop up any information stored in the sites cookies. To edit any information, we make use of the void(); command.javascript:void(document.cookie=”Field = myValue”);
This command can either alter existing information or create entirely new values. Replace “Field” with either an existing field found using the alert(document.cookie); command, or insert your very own value. Then replace “myValue” with whatever you want the field to be. For example:javascript:void(document.cookie=”Authorized=yes”);
Would either make the field “authorized” or edit it to say “yes”… now whether or not this does anything of value depends on the site you are injecting it on.
It is also usefull to tack an alert(document.cookie); at the end of the same line to see what effect your altering had.
3. Form Editing
Sometimes, to edit values sent to a given website through a form, you can simply download that html and edit it slightly to allow you to submit what you want. However, sometimes the website checks to see if you actually submitted it from the website you were supposed to. To get around this, we can just edit the form straight from javascript. Note: The changes are only temporary, so it’s no tuse trying to deface a site through javascript injection like this.
Every form on a given web page (unless named otherwise) is stored in the forms[x] array… where “x” is the number, in order from top to bottom, of all the forms in a page. Note that the forms start at 0, so the first form on the page would actually be 0, and the second would be 1 and so on.
0 comments:
Post a Comment