Join us at IRC!
Capitalism is an Island of wealth in a sea of poverty
Thursday, May 17, 2012
Navigation
Members Online
Total Online: 37
Web Spiders: 17
Guests Online: 31
Members Online: 6

Registered Members: 70043
Newest Member: nixium
Latest Articles

How to prevent Cookie Stealers



FLV Blaster - Download Music and Videos Faster

website security This mini tutorial will teach you a few ways of protecting your webstie against cookie stealers.



In this article, I will be giving a few tips on how to protect against cookie stealers.


Flash Cookie Stealers
--------
Some sites allow flash to be embedded, and if your site isn't secure, people can use javascblockedript within the flash to steal cookies. In case you didn't know, the simple way of embedding a flash onto an html page is:

<embed src="somefile.swf" width="somewidth" height="someheight"></embed>

But, people can easily put javascblockedript in their flash to either steal cookies, or annoy the user. So to simply not allow javascblockedript within the flash, just add allowscblockedriptaccess="never" to the embed tag. Example:

<embed src="somefile.swf" width="somewidth" height="someheight" allowscblockedriptaccess="never"></embed>

And that way, all javascblockedript within the flash will be blocked. But, if you have a site that allows users to upload .swf's directly to your site, they can still use javascblockedript even with allowscblockedriptaccess="never". What they could do is find the exact url to their uploaded .swf on your server, and spread the exact url around instead of the embedded flash. Well, not to fear, there is still a way to stop people from stealing cookies, but unfortunately, there is no way of stopping people from using annoying javascblockedript in their uploaded flash. So anyways, I'm assuming you use php to create your cookies. Well, as of php version 5.2, there is a new parameter to the setcookie() function. In this parameter, you can specify whether or not the cookie can only be accessed through the HTTP protocol. If set to TRUE, all javascblockedript attempts to access the cookie will fail. Incase you are wondering, to access a cookie with javascblockedript, you do docu<i></i>ment.cookie.


XSS (Cross-site scblockedripting) Cookie Stealers
--------
If you have a place on your site where people can submit or print text onto a page, make sure it is secure first. If it isn't, people can submit any kind of html or javascblockedript to take control of the page. So, I will go over two php functions that can stop all html and javascblockedript from being outputted on a page.

The first function is the strip_tags() function. With this function, you can strip any kind of tag that is beging outputted. The only bad thing is it would strip non-html tags such as <lol>. Anyways, an example is below:

<?php
$text="Hello <b>World</b>";
echo strip_tags($text); //Outputs Hello World, without "World" being bold.
?>

So, applying that function around all user submitted text will ensure that your safe.


The second function is htmlentities(). I prefer this over the strip_tags() function, because it keeps everything, but doesn't allow html. It will simply turn all special characters in html to their entity form. An example:

<?php
$text="Hello <b>World</b>";
echo htmlentities($text); //Outputs Hello <b>World</b> because the < and > have been converted to their entity form.
?>
--------
Well, that concludes my mini tutorial on how to protect yourself from cookie stealers. I hope you learned something!

Comments

regit on September 01 2006 - 17:31:29
Great artical, it was very informative. Thank you for writing it :)
willeH on September 02 2006 - 22:03:53
You could use a cookie-stealer stopper plugin for firefox :) Nice article.
WhiteAcid on September 03 2006 - 22:33:48
There are several more things that should be filtered, no magic function can be made, instead the web developer has to think what context the string is being echoed into. It may be into an elements attribute, style tag. Maybe into a style or even a scblockedript tag (I've seen both done without resulting in flaws).
Zarray on March 18 2007 - 10:23:56
or turn HTTP_TRACE off
Post Comment

Sorry.

You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.
Ratings
Rating is available to members only.

Please login or register to vote.

Awesome! 45% [5 Votes]
Very Good 27% [3 Votes]
Good 9% [1 Vote]
Average 18% [2 Votes]
Poor 0% [No Votes]
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.