Go Back   Nexodyne Forums > Living > Technology
Reload this Page Javascript Injection
User Name
Password
Closed Thread
 
Thread Tools Display Modes

  #1  
Old 04-17-2005, 06:48 PM
Zspacejc's Avatar
Zspacejc Zspacejc is offline
Contributor Ninja
 
Join Date: Mar 2003
Posts: 1,052
Zspacejc is just really niceZspacejc is just really niceZspacejc is just really nice
Javascript Injection

Javascript Injection


Summary: Javascript injection is a nifty little technique that allows you to alter a sites contents without actually leaving the site. This can be very usefull when say, you need to spoof the server by editing some form options. Examples will be explained throughout.

Contents:
I. Injection Basics
II. Cookie Editing
III. Form Editing


I. 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. That means no http:// or whatever.

Javascript is run from the URL bar by using the javascript: protocol. In this tutorial I will only teach you the bare bones of using this, but if you are a Javascript guru, you can expand on this using plain old javascript.

The two commands covered in this tutorial 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:
Code:
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:
Code:
javascript:alert('Hello'); alert('World');

This would pop up a box that said 'Hello' and than another that says 'World'.

II. Cookie Editing

First off, check to see if the site you are visiting has set any cookies by using this script:
Code:
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.
Code:
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:
Code:
javascript:void(document.cookie="Authorized=yes");

Would either make the field "authorized" or edit it to say "yes"... now wheter 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.

III. 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 webpage (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. Lets take this example:
Code:
<form action="http://www.website.com/submit.php" method="post"> <input type="hidden" name="to" value="admin@website.com">

Note:Since this is the first form on the page, it is forms[0]

Say this form was used to email, say vital server information to the admin of the website. You can't just download the script and edit it because the submit.php page looks for a referer. You can check to see what value a certain form element has by using this script:
Code:
javascript:alert(document.forms[0].to.value)

This is similar to the alert(document.cookie); discussed previously. In this case, It would pop up an alert that says "admin@website.com"

So here's how to Inject your email into it. You can use pretty much the same technique as the cookies editing shown earlier:
Code:
javascript:void(document.forms[0].to.value="email@nhacks.com")

This would change the email of the form to be "email@nhacks.com". Then you could use the alert(); script shown above to check your work. Or you can couple both of these commands on one line.

That's pretty much all there is to it. PM me, or post any quesitons or comments regarding this tutorial. As always, rep is always appreciated.


XD
-Zspacejc 4/17/05
__________________
Reply With Quote

  #2  
Old 04-30-2005, 05:20 PM
NeoHackerPets's Avatar
NeoHackerPets NeoHackerPets is offline
Nexodyne Newbie
 
Join Date: Apr 2005
Location: Nowhere
Posts: 13
NeoHackerPets is on a distinguished road
Talking

Ooo, finally, thanks!
Reply With Quote

  #3  
Old 05-02-2005, 06:27 PM
Ace in the hole Ace in the hole is offline
Nexodyne Newbie
 
Join Date: May 2005
Posts: 13
Ace in the hole is on a distinguished road
nice
Reply With Quote

  #4  
Old 05-29-2005, 12:39 AM
jc301290's Avatar
jc301290 jc301290 is offline
Nexodyne Newbie
 
Join Date: May 2005
Posts: 80
jc301290 is on a distinguished road
cool!!But most data is encrypted... any help?
Reply With Quote

  #5  
Old 05-29-2005, 07:23 AM
Zspacejc's Avatar
Zspacejc Zspacejc is offline
Contributor Ninja
 
Join Date: Mar 2003
Posts: 1,052
Zspacejc is just really niceZspacejc is just really niceZspacejc is just really nice
I doubt that it's encrypted if it's using forms like the examples above... but it could be. Show me the source code of the site or send me the URL and I'll check it out.

In most cases, the website will just have their data lying out in the open when it comes to forms. However it is very rarely that you will be able to completly compromise a website just through their forms.
__________________
Reply With Quote

  #6  
Old 05-29-2005, 10:23 PM
jc301290's Avatar
jc301290 jc301290 is offline
Nexodyne Newbie
 
Join Date: May 2005
Posts: 80
jc301290 is on a distinguished road
oops...phrased it wrongly. What i meant was for cookies, which usually has its data encrypted...i tried putting them through basic hash decryptors, but no luck...But still, thanks for offering to help me Zspacejc!
Reply With Quote

  #7  
Old 05-31-2005, 08:46 AM
Lucas Lucas is offline
NVT Champion
 
Join Date: May 2002
Location: Canada
Age: 34
Posts: 2,198
Lucas is a glorious beacon of lightLucas is a glorious beacon of lightLucas is a glorious beacon of light
Send a message via ICQ to Lucas Send a message via AIM to Lucas Send a message via MSN to Lucas Send a message via Yahoo to Lucas
Quote:
Originally Posted by jc301290
oops...phrased it wrongly. What i meant was for cookies, which usually has its data encrypted...i tried putting them through basic hash decryptors, but no luck...But still, thanks for offering to help me Zspacejc!

its probably md5...good luck decrypting it
Reply With Quote

  #8  
Old 05-31-2005, 02:18 PM
Zspacejc's Avatar
Zspacejc Zspacejc is offline
Contributor Ninja
 
Join Date: Mar 2003
Posts: 1,052
Zspacejc is just really niceZspacejc is just really niceZspacejc is just really nice
Problem with MD5 is that the time it takes to decrypt rises exponentially with every character in the original word. An 8 letter, non-dictionary original string can take a really, really, really long time.
__________________
Reply With Quote

  #9  
Old 05-31-2005, 03:03 PM
XEgittoX's Avatar
XEgittoX XEgittoX is offline
Retired
 
Join Date: Dec 2002
Location: Probably at home, if I'm posting here.
Age: 34
Posts: 1,071
XEgittoX is a jewel in the roughXEgittoX is a jewel in the rough
Send a message via AIM to XEgittoX
What was the encryption some chinese people recently cracked? It was really strong :S
__________________
If I sound negative, it's probably cause I'm not in a good mood, don't bash me about it. If I'm being positive, praise me to high heaven and I'll love you forever.
Reply With Quote

  #10  
Old 05-31-2005, 03:23 PM
Zspacejc's Avatar
Zspacejc Zspacejc is offline
Contributor Ninja
 
Join Date: Mar 2003
Posts: 1,052
Zspacejc is just really niceZspacejc is just really niceZspacejc is just really nice
MD5 has been crackable for years. The thing is that it was almost impossible to reverse engineer the MD5 (I.E. Look at the MD5 string and say "Okay, this couple of letters is 'A'". Every MD5 hash is 32 characters long, no matter how long the original input was. An MD5 hash is the by-product of a complex mathmatical sequence.

MD5 has been concievable crackable for years by simply ("or not so simply") bruteforcing the hash by encrypting random strings into MD5 and then comparing them to the hash given. Brute-forcings take a long time however.

It would seem that recently, as Egitto pointed out, that a couple of chineese guys recenltly 'solved' the MD5 hashing system quite analytically. They proved that two different strings can have the same MD5 hash.

Wikipedia Article on MD5
__________________
Reply With Quote

  #11  
Old 06-25-2005, 12:42 PM
OceanSoul OceanSoul is offline
Nexodyne Newbie
 
Join Date: Jun 2005
Posts: 1
OceanSoul is on a distinguished road
That was a great tutorial. Helped a lot.
Thanks!
Reply With Quote

  #12  
Old 06-25-2005, 07:29 PM
ispikedthepunch's Avatar
ispikedthepunch ispikedthepunch is offline
Contributor
 
Join Date: Mar 2004
Posts: 1,314
ispikedthepunch has a spectacular aura aboutispikedthepunch has a spectacular aura about
Grey Star

You guys heard of the Greasemonkey extension for Firefox? It's basically JS injection on crack. Check out this article for some cool videos of what you can do with it: http://blogs.pcworld.com/techlog/archives/000693.html
__________________
|
Reply With Quote

  #13  
Old 06-26-2005, 09:54 AM
Zspacejc's Avatar
Zspacejc Zspacejc is offline
Contributor Ninja
 
Join Date: Mar 2003
Posts: 1,052
Zspacejc is just really niceZspacejc is just really niceZspacejc is just really nice
Awesome, but I don't know how it's functionality compares to JS injection. I mean greasemonkey is awesome for changing the way a site functions, but it might be a bit combersome to change around the forms rather than just run one line of a JS injection code.
__________________
Reply With Quote

  #14  
Old 06-29-2005, 07:30 PM
icyone34 icyone34 is offline
Nexodyne Newbie
 
Join Date: Jun 2005
Posts: 1
icyone34 is on a distinguished road
Thumbs up

that hack thing is pretty cool but can the cokie editing thing be used
to edit your np on neopets if so can you please explain how to do it on neopets

thanks
Reply With Quote

  #15  
Old 06-29-2005, 08:48 PM
aaaaa aaaaa is offline
Contributor
 
Join Date: Jun 2003
Location: My room
Age: 33
Posts: 1,627
aaaaa is just really niceaaaaa is just really niceaaaaa is just really nice
Send a message via AIM to aaaaa Send a message via MSN to aaaaa
Quote:
Originally Posted by icyone34
that hack thing is pretty cool but can the cokie editing thing be used
to edit your np on neopets if so can you please explain how to do it on neopets

thanks



It can't be used to do that, unless you discovered some awsome cool glitch. Chances of that happening, and with JS, are very very small.
__________________
Drywall
Reply With Quote
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 12:14 PM.


vBulletin style developed by Transverse Styles

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
All content copyright ©2004 NeoHacks LLC. (http://nexodyne.com/)