BotScout - http://botscout.com/
FSpamlist - http://www.fspamlist.com/
Stop Forum Spam - http://www.stopforumspam.com/
projecthoneypot.org http://www.projecthoneypot.org/
oder hau den Bot einfach eine Teergrube vor den Latz
FSpamlist - http://www.fspamlist.com/
Stop Forum Spam - http://www.stopforumspam.com/
projecthoneypot.org http://www.projecthoneypot.org/
oder hau den Bot einfach eine Teergrube vor den Latz
Code:
#!/usr/bin/perl
$|++;
use strict;
use warnings;
use diagnostics;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Fcntl qw(:flock);
use File::Spec;
my $max_bots = 10; # maximale Anzahl der eingesperrten Bots
my $max_time = 600; # Einsperren fuer X Sekunden
my $next_grube = ''; # naechste Grube wenn die eigene voll ist
# z.B. 'http://www.teergrubing.de/cgi-bin/teergrubing.cgi?domain='
my $shrink_time = 'on'; # on / off reduziert die $max_time bei steigender Bot-Zahl
my $log_file = File::Spec->catfile($ENV{'DOCUMENT_ROOT'},'teergrube','log.txt'); # Log-File
my $counter = File::Spec->catfile($ENV{'DOCUMENT_ROOT'},'teergrube','count.txt'); # Counter fuer Insassen
my($bot_count,$sleep_count);
sub _log_it($);
sub _count_bot($);
my $emacs_need_this = {};
$SIG{'USR1'} = \&sig_handler();
$SIG{'TERM'} = \&sig_handler();
$SIG{'PIPE'} = 'IGNORE';
my $query = new CGI;
my $domain = $query->param('domain');
_log_it("Catched BadBot $ENV{'REMOTE_ADDR'} / $ENV{'HTTP_USER_AGENT'} from $domain at " . scalar(localtime()) . "\n");
$bot_count = _count_bot(1);
if($shrink_time eq 'on'){
$max_time -= (($max_time / $max_bots) * ($bot_count - 1));
}
if($bot_count <= $max_bots){
print $query->header();
print $query->start_html(-title => 'Teergrube');
$sleep_count = 0;
while($sleep_count < $max_time){
last unless(print " \n");
sleep 1;
$sleep_count++;
}
print $query->end_html();
}else{
if(length($next_grube)){
print $query->redirect('-url' => $next_grube . $domain);
}else{
print $query->redirect('-url' => 'http://' . $ENV{'REMOTE_ADDR'});
}
}
END{
$bot_count = _count_bot(-1);
_log_it("Lost BadBot $ENV{'REMOTE_ADDR'} / $ENV{'HTTP_USER_AGENT'} from $domain at " . scalar(localtime()) . "\n");
}
sub _log_it($){
my $text = shift;
open(LOG, ">> $log_file") or die("open(LOG, >> $log_file) failed $!");
flock(LOG, LOCK_EX);
print LOG $text;
close(LOG) or die("close(LOG) failed $!");
return;
}
sub _count_bot($){
my $value = shift;
open(CNT, "+>> $counter") or die("open(CNT, >> $counter) failed $!");
flock(CNT, LOCK_EX);
seek(CNT,0,0);
my $is_count = <CNT> || 0;
$is_count += $value;
chomp($is_count);
seek(CNT,0,0);
truncate(CNT,0);
print CNT $is_count . "\n";
close(CNT) or die("close(CNT) failed $!");
return $is_count;
}
sub sig_handler(){
return unless(defined $bot_count);
warn 'SIGNAL received at ' . scalar(localtime);
$bot_count = _count_bot(-1);
_log_it("Lost BadBot from $ENV{'REMOTE_ADDR'} at " . scalar(localtime()) . "\n");
exit();
}
__END__