Bots don't honor 301 :(
Larry Cook
lcook at sybase.com
Mon Jan 12 09:19:39 EST 2009
VirginSnow at vfemail.net wrote:
> I was thinking about accepting the connection, maybe sending out a few
> headers, and then the stalling the connection.
A friend, back in 2003, was having problems with bad bots so I wrote him
the following script which accepts the connection, logs and emails some
client info, and then goes into a loop sending a dot every second. Just
kicking them out did not seem like enough. They would just come back or
go bother someone else. Felt more like a community service to keep them
tied up for a while, although at the expense of his hosting service.
Some would time out quickly, but he had some held for 2+ hours and one
for 23 hours!
Larry
-----
#!/usr/local/bin/perl
require "cgi-lib.pl";
require "mail-lib.pl";
$| = 1;
print &PrintHeader;
print &HtmlTop("Spider Trap");
$time = localtime(time());
print "<p>$ENV{REMOTE_ADDR} - [$time] - \"$ENV{HTTP_USER_AGENT}\"</p>\n";
open(LOG, ">> spidertrap.log");
flock(LOG,2);
print LOG "$ENV{REMOTE_ADDR} - [$time] - \"$ENV{HTTP_USER_AGENT}\"\n";
close(LOG);
&send_mail("spidertrap\@hostdomain.com", "user1\@user1domain.com
user2\@user2domain.com", "Gotcha!",
"Date & Time: $time \n\nRemote IP: $ENV{REMOTE_ADDR}
\nReferer: \"$ENV{HTTP_REFERER}\" \nUser Agent:
\"$ENV{HTTP_USER_AGENT}\"");
$counter=0;
$last=0;
while (1) {
$counter++;
sleep 1;
print ".";
if ($counter > $last) {
if ($counter >= 10) {
print "Gotcha!!!";
$counter = 0;
}
print "<br>\n";
$last = $counter;
$counter = 0;
}
}
print &HtmlBot;
-----
More information about the gnhlug-discuss
mailing list