LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs > unSpawn
User Name
Password

Notices

Rate this Entry

Logwatch, webserver logs, PHP malarky

Submit "Logwatch, webserver logs, PHP malarky" to Digg Submit "Logwatch, webserver logs, PHP malarky" to del.icio.us Submit "Logwatch, webserver logs, PHP malarky" to StumbleUpon Submit "Logwatch, webserver logs, PHP malarky" to Google Submit "Logwatch, webserver logs, PHP malarky" to LinuxQuestions.org
Posted 10-03-2009 at 05:52 AM by unSpawn
Tags logwatch, patch, php

As I'm seeing more questions about (badly coded) web applications spawning rogue processes I wonder why people don't read their logs. Attacks require reconnaissance so keeping an eye on anything that looks like a prelude enables you to take measures. And please spend time updating when updates are released, installing apps properly (like not leaving the installation files around when docs remind you not to), hardening (any IDS, mod_security, Gotroot rulesets, mod_evasive or equivalent, PHPIDS, Suhosin, GreenSQL).
If you have any questions regarding this please ask them in the LQ Linux Security forum. We'd be happy to help you along.

Finding preludes to attacks by visual inspection of logfiles is cumbersome and tedious and that's why there is Logwatch to help you as it creates reports you can actually read. Logwatch unfortunately doesn't by default include rules to filter common crack signs like gotroot's mod_security/rootkits.conf but that's easily alleviated.

Locate your scripts/services/http file (might be "/usr/share/logwatch/scripts/services/http" if it's a default installation) and patch it with this:
Code:
--- http     2008-06-30 22:47:20.000000000
+++ http     2009-10-02 00:00:00.000000000
@@ -334,6 +334,45 @@
    'shtml\.exe',
    'win\.ini',
    'xxxxxxxxxxxxxxxxxxxxxx',
+   'wget%20',
+   'perl%20',
+   'nc%20',
+   'cd%20',
+   'python%20',
+   'rpm%20',
+   'yum%20',
+   'apt-get%20',
+   'emerge%20',
+   'lynx%20',
+   'links%20',
+   'mkdir%20',
+   'elinks%20',
+   'cmd%20',
+   'wget%20',
+   'lwp-download%20',
+   'lwp-request%20',
+   'lwp-mirror%20',
+   'lwp-rget%20',   
+   'uname',
+   'cvs%20',
+   'svn%20',
+   'sh%20',
+   'netstat',
+   'netcat%20',
+   'rexec%20',
+   'smbclient%20',
+   'tftp%20',   
+   'ftp%20',
+   'ncftp%20',
+   'curl%20',
+   'telnet%20',
+   'gcc%20',
+   'cc%20',
+   'whoami',
+   'killall',
+   'kill%20',
+   'rm%20',
+   'tar%20',
 );
 
 #
If there's lines in your webservers logs your Logwatch report will show:
Code:
 Attempts to use known hacks by 5 hosts were logged 35 time(s) from:
    000.0.0.0: 16 Time(s)
       uname 7 Time(s) 
       tar%20 1 Time(s) 
       cd%20 2 Time(s) 
       perl%20 1 Time(s) 
       wget%20 4 Time(s) 
       rm%20 1 Time(s) 
    000.0.0.0: 10 Time(s)
       cd%20 2 Time(s) 
       perl%20 2 Time(s) 
       wget%20 4 Time(s) 
       rm%20 2 Time(s)
which should be your cue to investigate things immediately.

Note this is a patch against a checkout of the Logwatch CVS. If patching fails (always try testing with --dry-run and the appropriate amount of --fuzz) then check the code at around line 300 between the line starting with "my @exploits = (" and "# Define some useful RE paterns".

Also note that Logwatch takes the --service arg so you could run Logwatch as a daily cronjob on all logs (which will be slow if you've got lots of logs) and something like 'logwatch --detail High --service http --range Today' as a hourly cronjob.
Posted in Uncategorized
Views 243 Comments 0 Edit Tags
« Prev     Main     Next »


All times are GMT -5. The time now is 06:05 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration