Simple Cookie Stealing

For the rest of these lessons we will assume that this site has a group of users who can login, and that their details are stored in a cookie.

This is like sites such as Hotmail.com, Livejournal, and Freshmeat.

If we assume that the site has the ability to send a message to other users then we can proceed.

Javascript Cookie Access

As an aside if you're not used to JavaScript, the following code will display a users cookie.

alert(document.cookie);

Test it by clicking here.

The Test

Now if we have a text area where a user can leave a message for another user we could be naive and just copy the message, and display it directly to the other user.

We'll soon see that would be a bad idea.

You can test this quite easily by playing with the following box:



Here's a clue, what happens if you type the following text?

<script>
alert(document.cookie);
</script>