<?php
###################################################
## cookie jar v1.01 ##
## http://Business-PHP.com/opensource/cookiejar/ ##
## ##
## Where do spammers get your email address ##
## from? This script will help you catch address ##
## harvesters with their hand in the cookie-jar! ##
## You can easily tell where and when an address ##
## was harvested, and then take action against ##
## that server/ISP. ##
## ##
## should run on PHP 4.1.0 or later ##
## tested on PHP 4.3.1 ##
## ##
## Copyright (C) 26 Jun 2003 Atom Emet ##
## Atom*Business-PHP.com ##
## ##
## This program is free software; you can ##
## redistribute it and/or modify it under the ##
## terms of the GNU General Public License as ##
## published by the Free Software Foundation; ##
## either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope ##
## that it will be useful, but WITHOUT ANY ##
## WARRANTY; without even the implied warranty ##
## of MERCHANTABILITY or FITNESS FOR A ##
## PARTICULAR PURPOSE. See the GNU General ##
## Public License for more details. ##
## ##
## You should have received a copy of the ##
## GNU General Public License along with this ##
## program; if not, write to ##
## the Free Software Foundation, Inc. ##
## 59 Temple Place - Suite 330 ##
## Boston, MA 02111-1307, USA ##
###################################################
/*
* this script will
* generate an email address that will reveal the
* IP address and date of a spam-bot's visit.
* the info is encoded so we don't tip off the
* spam-bot that we're using it's IP address as part of the bait.
*
* this script can be used to ENCODE addresses by being
* included in other pages using PHP's include() function.
*
* this script can be used to DECODE such addresses, by
* visiting the script directly, and appending a question mark (?)
* and the string to be decoded, such as:
* http://Business-PHP.com/opensource/cookiejar/cookiejar.php?otottonntedlolitn
*
* this code was written by Atom Emet - (c) 26 june 2003 - http://Business-PHP.com/
* inspired by: http://www.kungfugrippe.com/previously/002462.php
*
* this code is hereby published under the GPL license
* http://www.gnu.org/copyleft/gpl.html
*
*/
##########################################################
## these 2 changes MUST be made for this script to work ##
##########################################################
#################################
## change this to the server that
## your collecting spam on
$your_server = 'example.com.xyz';
#####################################
## change this variable to the script
## name, relative to the server root.
## if this is not set correctly,
## the script cannot be used to DECODE
$script_name = '/opensource/cookiejar/cookiejar.php';
##################################
## these 2 changes are optional ##
##################################
####################################
## this string is the text that will
## be linked to the bait address
$bait_text = 'Sign me up!';
###########################################
## leave string1 alone!
## you are encouraged to play with string2
## but make sure there are 11 lower case letters
## and use each letter no more than once!!
$string2 = 'detoanisrhl';
## BE AWARE: after making changes to string2,
## any address that was *previously* encoded
## with a different string will not be decoded
## with a newer string.
##
## it is suggested that once the script is running
## on YOUR server, set string2 and then LEAVE IT ALONE
################################################
## nothing below this line has to be modified ##
################################################
$string1 = ' 1234567890';
if(empty($_SERVER['QUERY_STRING']) || "${script_name}" != ereg_replace('\?.*', '', $_SERVER['REQUEST_URI'])) {
#####################
## encode bot info ##
#####################
$bot_info = explode('.', $_SERVER[REMOTE_ADDR]);
$dec_ip = ($bot_info[0] * 16777216) + ($bot_info[1] * 65536) + ($bot_info[2] * 256) + $bot_info[3];
$target = $dec_ip . ' ' . date("ymd");
$target = strtr($target, "${string1}", "${string2}");
echo("\n<a href=\"mailto:${target}@${your_server}\">${bait_text}</a>\n");
} else {
#####################
## decode bot info ##
#####################
$spam_name = ereg_replace('@.*$', '', $_SERVER['QUERY_STRING']);
$spammer = explode(' ', strtr(strtolower($spam_name), "$string2", "$string1"));
$spammer_bot[] = ereg_replace('\..*', '', ($spammer[0] / 16777216));
$remainder = ($spammer[0] - ($spammer_bot[0] * 16777216));
$spammer_bot[] = ereg_replace('\..*', '', ($remainder / 65536));
$remainder = ($remainder - ($spammer_bot[1] * 65536));
$spammer_bot[] = ereg_replace('\..*', '', ($remainder / 256));
$remainder = ($remainder - ($spammer_bot[2] * 256));
$spammer_bot[] = "${remainder}";
echo("<html><head><title>Cookie Jar :: ${spam_name}</title></head><body>\n\n");
echo("<a href='/opensource/cookiejar/'>Cookie Jar</a>\n<hr>\n");
echo("Bot address: " . implode('.', $spammer_bot));
echo("\n<hr>\nDate of bot's visit: ");
echo("\n<br>Year: " . substr($spammer[1], 0, 2));
echo("\n<br>Month: " . substr($spammer[1], 2, 2));
echo("\n<br>Day: " . substr($spammer[1], 4, 2));
echo("\n<hr>\n<a href='/opensource/cookiejar/'>Information about this interface can be found here.</a>");
echo("\n\n</body></html>");
}
?>