Commit 569a3a72 authored by dmorley's avatar dmorley

mobile page

parent e3a214bd
.section
.container-fluid
<h2>Thank you for your help! Without I would have to put ads on the site.</h2><br>
<h3>Paypal Options:</h3>
<hr><table border=0><tr><td>
<br>Or set your own amount: <a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LYECDKTKRXGV8&item_name=Diasporg+Pod&currency_code=USD&source=url">Paypal</a><br>
%br
<h3>Other Options:</h3><br><a href="https://flattr.com/thing/125882">Flattr</a><br>
<a href="https://liberapay.com/diasporg/donate">Liberapay</a><br>
Bitcoin: 16oAnzoYCy8YDFffve9D6N7KLwou3Z3c8H <br>
Bitcoin Cash: 1G3ye1Sva2do6SFqRgcMdaR2xt5nLcwn7W <br>
Litecoin: LVGkBcxZyqqJF1epE8fGXCbe1mfTRdZ5Qb <br>
ETH: 0x16cE51e97106bbF2E757Eb997129db07869F835f <br>
</td></tr></table>
#!/usr/bin/perl -T
use strict;
use warnings;
## Customized for diasp.org setup
## Calomel.org .:. https://calomel.org
## name : web_server_abuse_detection.pl
## version : 0.04
my $log = "/home/david/diaspora/log/production.log";
## how many seconds before an unseen ip is considered old and removed from the hash?
my $expire_time = 9200;
## how many error log lines before we trigger blocking abusive ips and clean up
## of old ips in the hash? make sure this value is greater than $errors_block above.
my $cleanup_time = 10;
## clear the environment and set our path
$ENV{ENV} ="";
$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin";
## declare some internal variables and the hash of abusive ip addresses
my ( $ip, $errors, $time, $newtime, $newerrors, $username, $date );
my $trigger_count=1;
my %abusive_ips = ();
## open the log file. we are using the system binary tail which is smart enough
## to follow rotating logs. We could have used File::Tail, but tail is easier.
open(LOG,"/usr/bin/tail -90000000 $log |") || die "ERROR: could not open log file.\n";
while(<LOG>) {
## process the log line if it contains one of these error codes
if ($_ =~ m/event=registration status=successful/)
{
## Whitelisted ips. This is where you can whitelist ips that cause errors,
if ($_ !~ m/^(66\.249\.|192\.168\.)/)
{
## extract the ip address from the log line and get the current unix time
$time = time();
($ip) = $_ =~ m/ip=(.*?)\s/;
($username) = $_ =~ m/user=(.*?)\s/;
## if an ip address has never been seen before we need
## to initialize the errors value to avoid warning messages.
$abusive_ips{ $ip }{ 'errors' } = 0 if not defined $abusive_ips{ $ip }{ 'errors' };
## increment the error counter and update the time stamp.
$abusive_ips{ $ip }{ 'errors' } = $abusive_ips{ $ip }->{ 'errors' } + 1;
$abusive_ips{ $ip }{ 'time' } = $time;
if ($abusive_ips{ $ip }->{ 'errors' } >= 3 ) {
print "abuse from ip $ip username $username \n";
print "fail2ban-client set manban banip $ip \n\n";
}
## increment the trigger counter which is used for the following clean up function.
$trigger_count++;
## clean up function: when the trigger counter reaches the $cleanup_time we
## remove any old hash entries from the $abusive_ips hash
if ($trigger_count >= $cleanup_time) {
my $time_current = time();
## clean up ip addresses we have not seen in a long time
while (($ip, $time) = each(%abusive_ips)){
if ( ($time_current - $abusive_ips{ $ip }->{ 'time' } ) >= $expire_time) {
delete($abusive_ips{ $ip });
}
}
## reset the trigger counter
$trigger_count = 1;
}
}
}
}
#### EOF ####
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment