Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Javascript]Javascript Injection

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Elec0
Expert Cheater
Reputation: 0

Joined: 21 Nov 2007
Posts: 188
Location: Out of my mind, back in five minutes.

PostPosted: Wed Mar 19, 2008 2:55 pm    Post subject: [Javascript]Javascript Injection Reply with quote

Okay, I am learning different things about hacking, using HackThisSite.org. And one of the things is Javascript Injection. Personally, I found this really fun and it peaked my interest in JavaScript.

Okay, here goes.

Javascript Injection
Okay, for this you might want to sign up with HackThisSite.org just to have something to practice on.
This tutorial will cover the Basic 4 and 5 challenges in HTS.

Okay, if you want to inject JS code into a website, (let's just use CE for easy access) you type your JS code into the URL bar.

Let's do a simple alert message.
Code:

Javascript:alert("Hello World!!");


Type that in and you will get a message box saying Hello World!!. You can also have two commands on the same line, like this:

Code:

Javascript:alert("Hello"); alert("World!!");


That would display two alert boxes, one saying Hello and one saying World!!.


Cookie Editing
Okay, here is another use that you can do with JS, one of the ones that you will use a lot if you use JS injection. It's called cookie editing, you can display the cookies like this:
Code:

Javascript:alert(document.cookie);


That would display all the cookies on the page you are on. Try it now on this page, what do you get? A whole bunch of random letters? That is the PHPSESSID, otherwise known as a PHP session id.

Now, if you want to set a cookie or add a new value to a cookie, you would do it like this:
Code:

Javascript:void(document.cookie="Cookie = Value")


So, let's say that we want to make a new cookie for this page, let's call it Authorized and set the value to yes.
You would do it like this:
Code:

Javascript:void(document.cookie="Authorized = yes")




Okay, this makes sense, you say. But what does this have to do with HTS?
Well, for the basic mission #4 you have to change the email address that it sends the password to, (it won't actually send anything to you, though.)
To do that you have to change the value of that particular variable.

If you look at the source code of that part in the page, you get this:
Code:

<form action="/missions/basic/4/level4.php" method="post">
                         <input type="hidden" name="to" value="[email protected]"><input type="submit" value="Send password to Sam"></form></center><br /><br /><center><b>Password:</b><br />
                         <form action="/missions/basic/4/index.php" method="post">
                         <input type="password" name="password"><br /><br />
                         <input type="submit" value="submit"></form>


Now, when someone is using a form, the forms in the page are numbered, the first form being forms[0].
To see what the form has in it, then go to the page and type this in:
Code:

Javascript:alert(document.forms[0].to.value);


It will give you [email protected] or something.

Now, if you want to change a form with JS, you would use the void command again, like this:
Code:

Javascript:void(document.forms[0].to.value="[email protected]")


That changes the value from [email protected] to whatever you put in there.

If you are a Javascript guru, you can see that you can do a lot using JS injection.


URL Javascript Programs
Okay, I got bored and decided to write a one line program using Javascript, here is what I got:
Code:

javascript:c=window.open('','','width=200,height=100'); c.document.writeln('<html><head><script type="text/javascript">function OpenBox() { alert("Cookies: " + document.cookie); } </script><center> <br><input type="button" name="Something" onclick="OpenBox()" value="View Cookies"><br><br>Help: Just click the button.  </center></body></html>');


Long isn't it? Well, if you copy and paste that into the URL bar here, and hit enter, it will give you a new window with a button and wen you click the button, it will show you the cookies. Try it now.

But notice this part:
Code:

c=window.open('','',width=200,height=100')


That names the window c.
Now, for when I am writing to the window, you have to use a code like this:
Code:

c.document.writeln('BlahBlah.');


That would write BlahBlah to the window.
Get it?

Try writing your own single line program, then post it here, show us what you can do!



~Elec0

_________________
Back to top
View user's profile Send private message MSN Messenger
Trow
Grandmaster Cheater
Reputation: 2

Joined: 17 Aug 2006
Posts: 957

PostPosted: Fri Mar 21, 2008 2:08 am    Post subject: Reply with quote

Code:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200;DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style;DIS.position='absolute'; DIS.left=Math.sin (R*x1+i*x2+x3)*x4+x5;DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);


Usable on sites with many images, e.g. google images search result
Reference: http://www.trap17.com/index.php/rotating-images_t43121.html
The guy who posted there sure copied it from somewhere else because this is not the only place I've seen this code.

_________________
Get kidnapped often.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites