hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Custom Apache logs (specifically formmail logging)
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Custom Apache logs (specifically formmail logging)

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-19-2004, 02:37 PM
2Grumpy 2Grumpy is offline
Grumpy Redneck
 
Join Date: Nov 2001
Location: The South
Posts: 5,405

Custom Apache logs (specifically formmail logging)


I dunno about you other guys, but formmail abuse is our #1 cause of spam complaints. So today I finally did a little research and came up with this little jewel for logging ANY and ALL calls to "formmail" (case irrelevant) to a formmail.log in apache (/var/log/httpd/formmail.log on most systems):

Code:
LogFormat "%h %l %u %t \"%v %r\" %>s %b" formmaillog
SetEnvIf Request_URI "[F,f][O,o][R,r][M,m][M,m][A,a][I,i][L,l]" formmail
CustomLog logs/formmail.log formmaillog env=formmail
Here's an output from the formmail.log:

Code:
24.214.X.X - - [19/Jan/2004:12:24:56 -0600] "dixiesys.com GET /ForMMail.pl HTTP/1.1" 404 286
The most helpful thing is the %v in the LogFormat because this logs _virtual host_ information too so you can quickly see what vhost is getting the request.

Now all I need is a script to monitor formmail.log and alert me on a certain condition, maybe a 5 minute check and alert if more than say, 10 new lines are in the log (obviously this would need tweaking in the real world probably) so that you can catch the formmail crap before it results in XX thousand emails and several spamcop complaints! Actually I'll probably change the log location to something like /var/www/html/logs/formmail.log and then I can run a central script on a remote server that checks all my servers every few minutes by just loading this url (like www.servername.com/logs/formmail.log) so I only have to run one script rather than 54 scripts once on each server!

This is a first draft of this log rule if anyone improves it reply here and share the improvements

I spend way too much time chasing down formmail abuses

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:33 PM.
Reply With Quote


Sponsored Links
  #2  
Old 01-20-2004, 06:18 PM
Dan L Dan L is offline
Web Developer
 
Join Date: Feb 2003
Location: Connecticut
Posts: 5,441
Re: Custom Apache logs (specifically formmail logging)

Quote:
Originally posted by Dixiesys I spend way too much time chasing down formmail abuses
Nah, this is pretty helpful.

Reply With Quote
  #3  
Old 01-24-2004, 12:56 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
i tried this and it doesnt work my formmail.log is still empty

I stuck the

Code:
LogFormat "%h %l %u %t \"%v %r\" %>s %b" formmaillog
SetEnvIf Request_URI "[F,f][O,o][R,r][M,m][M,m][A,a][I,i][L,l]" formmail
CustomLog logs/formmail.log formmaillog env=formmail
right above the access log section in my httpd.conf.....is that not where it goes?


I am using the /cgi-sys/formmail.cgi and .pl that i got on my cpanel system...

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:33 PM.
Reply With Quote
Sponsored Links
  #4  
Old 01-24-2004, 01:16 AM
choon choon is offline
Retired Moderator
 
Join Date: Jul 2001
Location: Singapore
Posts: 1,790
If you are using Cpanel and from the CustomLog you have specified... which location you are trying to view?
Is it /usr/local/apache/logs/formmail.log?

Reply With Quote
  #5  
Old 01-24-2004, 01:17 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
Yeah - the log is there - but the log is empty (0 Lines)

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:34 PM.
Reply With Quote
  #6  
Old 01-24-2004, 01:19 AM
choon choon is offline
Retired Moderator
 
Join Date: Jul 2001
Location: Singapore
Posts: 1,790
I assume you have tried http://yoursite/formmail.pl ?

Reply With Quote
  #7  
Old 01-24-2004, 01:22 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
I'm using http://mysite/cgi-sys/formmail.pl (and formmail.cgi) - this is the formmail clone script cpanel comes wiht by default - does it not log the scripts available like this systemwide?

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:34 PM.
Reply With Quote
  #8  
Old 01-24-2004, 01:29 AM
2Grumpy 2Grumpy is offline
Grumpy Redneck
 
Join Date: Nov 2001
Location: The South
Posts: 5,405
Try just accessing www.blah.com/formmail.php (whether it exists or not is irrelevant it'll still log the hit).

I just tried www.something.com/asdf/asdf/asdf/formmail.php and it was logged.

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:34 PM.
Reply With Quote
  #9  
Old 01-24-2004, 01:33 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
still 0 lines.

yes i restarted httpd, and i know its creating the log file, i deleted it, restarted httpd, accessed formmail again, and the log file is created again - but with 0 lines.

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:34 PM.
Reply With Quote
  #10  
Old 01-24-2004, 01:37 AM
choon choon is offline
Retired Moderator
 
Join Date: Jul 2001
Location: Singapore
Posts: 1,790
I wonder do you have mod_setenvif ? Is it default to have it?

Reply With Quote
  #11  
Old 01-24-2004, 01:39 AM
2Grumpy 2Grumpy is offline
Grumpy Redneck
 
Join Date: Nov 2001
Location: The South
Posts: 5,405
Hmm I've tried this on DA and Ensim servers so far and it worked but that's not a very large test bed

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:36 PM.
Reply With Quote
  #12  
Old 01-24-2004, 01:42 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
choon - i dont see it in the rpm list in WHM. How would I check to see if i have it? and If i dont have it (probably dont) How do i install it (would make another great tutorial )

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:36 PM.
Reply With Quote
  #13  
Old 01-24-2004, 01:57 AM
choon choon is offline
Retired Moderator
 
Join Date: Jul 2001
Location: Singapore
Posts: 1,790
I will test it and get back to you guys... it is compiled as default. Use this command to check as it is compiled as DSO:
Code:
cat /usr/local/apache/conf/httpd.conf \
| grep mod_setenvif
Dixiesys, have you try with SetEnvIfNoCase instead of SetEnvIf so that your regular expression matching is performed in a case-insensitive manner? I mean instead of using:
Code:
SetEnvIf Request_URI "[F,f][O,o][R,r][M,m][M,m][A,a][I,i][L,l]" formmail
you can try this:
Code:
SetEnvIfNoCase Request_URI "FoRmMaIl" formmail

Reply With Quote
  #14  
Old 01-24-2004, 02:12 AM
Akash Akash is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Illinois, USA
Posts: 7,147
^^ NoCase still doesn't work for me

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:36 PM.
Reply With Quote
  #15  
Old 01-24-2004, 03:45 AM
choon choon is offline
Retired Moderator
 
Join Date: Jul 2001
Location: Singapore
Posts: 1,790
Ok, I have it worked and here are my steps:

Step 1: Locate the line in your httpd.conf:
Code:
LogFormat "%{User-agent}i" agent
And add the following line after the above line:
Code:
LogFormat "%h %l %u %t \"%v %r\" %>s %b" formmaillog
Step 2: Locate the line in httpd.conf:
Code:
<IfModule mod_setenvif.c>
And add the following after the above line:
Code:
    # for formmail
    SetEnvIfNoCase Request_URI "formmail" formmail
Step 3: Enable each VirtualHost logging
Add the following line in those VirtualHost you want to enable logging:
Code:
CustomLog /usr/local/apache/logs/formmail.log formmaillog env=formmail
My suggestion will be change the logged file to something more useful like using a directory just for logging this formmail:
mkdir /usr/local/apache/logs/formmaillog

Then within each VirtualHost...
Code:
CustomLog /usr/local/apache/logs/formmaillog/yourdomain formmaillog env=formmail
Or below (which you can skip Step 1 if you are using this):
Code:
CustomLog /usr/local/apache/logs/formmaillog/yourdomain combined env=formmail
However I won't know by adding this within each VirtualHost will affect WHM/Cpanel or not

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Researchers Urge System Admins to Check for New Apache Web Server Backdoor Malware Web Hosting News 2013-05-01 11:35:53
MochaHost Enhances Server Performance with Tomcat Native Library Accelerator Web Hosting News 2012-08-01 15:35:20
Apache Web Server Adds Cloud Capabilities with First Major Update in 5 Years Web Hosting News 2012-02-21 16:05:02
The Apache Software Foundation Launches Hadoop v1.0 Web Hosting News 2012-01-05 18:29:16
Oracle is the Latest Vendor to Apply Patch for Apache Killer Flaw Web Hosting News 2011-09-19 14:43:58


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?