The Dashboard shows visitors and robots
} ?>Security Etudes : #100 : Security : IPs
This is what I do now (script does it, on autopilot)
Why no whitelisting?
Update (Apr 06. 2013)
There is better way.
Update (May 02. 2013)
https://github.com/kickstarter/rack-attack - looks like a good idea to deal with http group of abusers
Update (Jul 28. 2013)
AutoBan - self-learning intrusion detection system in 100 lines of Perl
March 01. 2013
if ($background) { ?>Amazon.com's Web Services were used by hackers in the April attack against Sony's online entertainment services, according to a Bloomberg ...
The anonymity network Tor is often misused by hackers and criminals in order to remotely control hacked computers. In this blog post we explain why Tor is so well suited for such malicious purposes, but also how incident responders can detect Tor traffic in their networks.
SnortĀ® is an open source network intrusion prevention and detection system (IDS/IPS) developed by Sourcefire. Combining the benefits of signature, protocol, and anomaly-based inspection, Snort is the most widely deployed IDS/IPS technology worldwide. With millions of downloads and nearly 400,000 registered users, Snort has become the de facto standard for IPS.
If you've looked at web server logs, you know there are some weird clients out there. Malicious scripts probe for exploits. Scrapers download the same page dozens of times each second, or request the 10,000th page of comments for a post with only 2 comments.
Security Etudes : #101 : Security : Autoban
This is Part 2.
Now we accumulate attacks in file attack.log, but how do we learn about attacks that we don't know?
We learn from the attackers!
#!/usr/bin/perl use File::Tail; my $fname = shift || die "Use: $0 file to watch"; sub ReadCfg{ my $fn = shift; my @ret = (); my @lines = `cat $fn`; foreach my $l (@lines) { chop $l; next if (!$l); next if ($l =~ m/^#.*/); push @ret, $l; } return @ret; } my @ignore=ReadCfg("ignore.txt"); my @attack=ReadCfg("attack.txt"); my $nrules = scalar @ignore; my $narules = scalar @attack; my $ldate = localtime; open( LOG, ">>log" ); print LOG "$ldate started $0 watching '$fname' with $nrules ignore and $narules attack rules\n"; close( LOG ); my $File = File::Tail->new(name=>$fname, tail=>1, maxinterval=>0.5, interval=>0.5); die "Can't read $fname" if (!$File); while (defined($_=$File->read)) { chomp; my $line = $_; print STDERR "L: $line\n"; foreach my $ire (@ignore){ goto CONT if ( $line =~ m/\Q$ire\E/ ); } foreach my $at (@attack){ if ( $line =~ m/\Q$at\E/ ){ open( ALOG, ">>attack.log" ); print ALOG "$line\n"; close( ALOG ); goto CONT; } } open( LOG, ">>log" ); print LOG "$line\n"; close( LOG ); CONT: }
#!/usr/bin/perl sub ReadCfg{ my $fn = shift; my @ret = (); my @lines = `cat $fn`; foreach my $l (@lines) { chop $l; next if (!$l); next if ($l =~ m/^#.*/); push @ret, $l; } return @ret; } my @attack=ReadCfg("attack.txt"); my @lines = `cat attack.log`; foreach my $l (@lines){ chop $l; if ( $l =~ /(\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b)/ ){ my $ip = $1; my $cmd = ( -f "old.log" ) ? "grep $ip log old.log" : "grep $ip log"; my @morelines = `$cmd`; foreach my $ml (@morelines){ chop $ml; foreach my $a (@attack){ if ( $ml =~ m/\Q$a\E/ ){ # known attack goto NEXTL; } } print "NEW ATTACK: $ml\n"; NEXTL: } } }
ic.asp Invalid method in request azenv.php /forums /config HNAP1 anti-sec admin manager pma Failed password user unknown phppath POST /% noxdir nosuichfile.php
July 28. 2013
if ($background) { ?>Summary Console - click to zoom in
} ?>Security Etudes : #102 : AutoBan Sneak Attacks
This is Part 3.
#!/usr/bin/perl use Data::Dumper; my @lines=`cat /usr/aban/attack.log`; my %i2n = (); my %i2d = (); foreach my $l (@lines) { chop $l; #print "$l\n"; if ( $l =~ /(\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b)/ ){ my $ip = $1; $i2n{ $ip }++; my $day = substr($l,0,6); #print "$day\n"; if ( $i2d{$ip} && ($i2d{$ip} ne $day) ){ $i2d{ $ip } .= " - " . $day; } else { $i2d{ $ip } = $day; } } } foreach my $i ( sort { $i2n{$b} <=> $i2n{$a} } keys %i2n ){ my $n = $i2n{$i}; my $d = $i2d{$i}; print "$i -> $n ($d)\n"; }
October 27. 2013
if ($background) { ?>Classification Console - click to zoom in
} ?>Security Etudes : #103 : AutoBan Layered Approach
This is Part 4.
The system works very nice for me. No noise. Attakers are detected. Annoying attackers are blocked. Database of attacks signatures grows every week with no effort on my side.
I've been thinking about client/server architecture. In that scenario, users run a script on their computers, yet we share the database of attacks. If there is enough of users, it looks possible to detect attacking IPs and block them in realtime, the way yahoo and others fight spam. DM me on twitter (as of 2021 - no longer have twitter account), if you would want to secure your servers the way I secured mine. You don't need to be sysadmin for that, naturally.
I changed few things in 2021. Replaced the system with even more brute force approach, it bans aggressively. Automatically as well. Basically, a few strikes - IP is banned. Simpler that way. Works like a charm. (Aug 21 2021).
May 06. 2014
if ($background) { ?>