Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: fail2ban apache-hacks
PostPosted: Wed May 30, 2012 4:24 pm 
Offline
Senior Member
User avatar

Joined: Thu Nov 24, 2011 12:46 pm
Posts: 139
Location: Mesa AZ
Last night I was playing with blocking visitors that are probing for lists of web apps.

Of course, after I got the rules running, there were no attempts... Today while at work, I popped on the server to see if it had been triggered and still nothing... and while watching, one popped up.

2012-05-30 12:33:16,148 fail2ban.actions: WARNING [apache-hacks] Ban 67.207.139.63

Triggered by:
Code:
site44.errors:[Wed May 30 12:33:15 2012] [error] [client 67.207.139.63] File does not exist: /www/vhosts/site44/admin
site44.errors:[Wed May 30 12:33:15 2012] [error] [client 67.207.139.63] File does not exist: /www/vhosts/site44/admin
site44.errors:[Wed May 30 12:33:15 2012] [error] [client 67.207.139.63] File does not exist: /www/vhosts/site44/admin


Very cool...

I'm sure there is more than one way to do this.

I just compiled a list of probes that I've seen and created entries like you see below.

I could clean up the list with some wildcards etc... but I just wanted to see it work.

Filter looks like:
Code:
[Definition]
failregex = .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/~admin$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/3rdparty$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/admin$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/bbs$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/cpadmin$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/cpadmindb$
  .* \[error\] \[client (?P<host>\S*)] .*File does not exist: .*\/cpanelmysql$
...


with the entry in jail.local:
Code:
[apache-hacks]
enabled = true
port  = http,https
filter  = apache-hacks
logpath = /www/logs/*errors
maxretry = 2


The current list (growing) is attached. I haven't checked, but it might be possible to just have it parse the list and do the same thing but I am not very familiar with Fail2Ban yet.

http://p.linode.com/6753

In general, I typically use non-standard locations for web apps to begin with so any attempts at these are bogus to start with.

_________________
Kevin a.k.a. Dweeber


Top
   
 Post subject:
PostPosted: Thu May 31, 2012 11:53 am 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
When testing fail2ban regex changes you can use fail2ban-regex to see what the new pattern would match in your existing logfiles. That way you don't have to wait for the next attempt to see if it is working the way you expect.

Code:
fail2ban-regex <logfile> <filterfile>


Top
   
 Post subject:
PostPosted: Thu May 31, 2012 12:37 pm 
Offline
Senior Member
User avatar

Joined: Thu Nov 24, 2011 12:46 pm
Posts: 139
Location: Mesa AZ
Yes...

Actually, I stumbled upon that when I wrote the rule. And it tested out fine, but seeing it actually do it, was impressive. Originally I had the jail.local entry for it not pointing correctly, so it was not seeing all of the vhost logs.

_________________
Kevin a.k.a. Dweeber


Top
   
 Post subject:
PostPosted: Thu May 31, 2012 12:43 pm 
Offline
Senior Member

Joined: Fri Feb 18, 2005 4:09 pm
Posts: 594
Is this an IP address ban? I had considered this, but thought that I would be blocking [wi-fi addresses or home computers] that were taken over. I know that the University of Alabama in Birmingham here has some open WiFi hotspots I'm not eager to block, for example. I have been tolerating the -so far as I can tell - harmless Apache intrusion attempts up until now. Should I reconsider?

James


Top
   
 Post subject:
PostPosted: Thu May 31, 2012 1:25 pm 
Offline
Senior Member
User avatar

Joined: Thu Nov 24, 2011 12:46 pm
Posts: 139
Location: Mesa AZ
yes. You can however white list IP and ip blocks.

I use it for monitoring dovecot, exim and other logs as well.

For example a client who has problems setting up new outlook users may trigger the block because of too many failed attempts via iMAPP or POP3... but if you white list the IP, it won't happen.

_________________
Kevin a.k.a. Dweeber


Top
   
 Post subject:
PostPosted: Fri Jun 01, 2012 9:49 am 
Offline
Senior Member

Joined: Fri Feb 18, 2005 4:09 pm
Posts: 594
Dweeber wrote:
yes. You can however white list IP and ip blocks.


Thank you kindly, Mr. Dweeber. Is you middle name really "aka"?

James


Top
   
 Post subject:
PostPosted: Fri Jun 01, 2012 1:27 pm 
Offline
Senior Member
User avatar

Joined: Thu Nov 24, 2011 12:46 pm
Posts: 139
Location: Mesa AZ
Actually, Also Known As....

_________________
Kevin a.k.a. Dweeber


Top
   
 Post subject:
PostPosted: Fri Jun 01, 2012 2:12 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Kevin Also Known As Dweeber? That's a pretty long name. Must people are lucky to just have one middle name, let alone three.


Top
   
 Post subject:
PostPosted: Fri Jun 01, 2012 2:39 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
I had a great great uncle with 3 middle names

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri Jun 01, 2012 2:40 pm 
Offline
Senior Member
User avatar

Joined: Thu Nov 24, 2011 12:46 pm
Posts: 139
Location: Mesa AZ
Actually in real life I have 6 names. A first, a last and 4 middle names but that is a different long story.

_________________
Kevin a.k.a. Dweeber


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group