Logwatch and Mod_security

Does anyone have a logwatch filter for the mod_security module?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

derhansen/logwatch-modsec2 on GitHub has a great example of a Logwatch filter for mod_security. The email output it generates looks like:

--------------------- ModSecurity2 (mod_security2) Begin ------------------------


subdomain.domain.tld - 2 time(s)
[ip:] [id: 981231 ] [msg: SQL Comment Sequence Detected.]  - 1 time(s)
[ip:] [id: 981231 ] [msg: SQL Comment Sequence Detected.]  - 1 time(s) - 1 time(s)
[ip:] [id: 990012 ] [msg: Rogue web site crawler]  - 1 time(s)
[ip:] [id: 981318 ] [msg: SQL Injection Attack: Common Injection Testing Detected]  - 5 time(s)
[ip:] [id: 950901 ] [msg: SQL Injection Attack: SQL Tautology Detected.]  - 2 time(s)

www.anothersite.tld - 1 time(s)
[ip:] [id: 958291 ] [msg: Range: field exists and begins with 0.]  - 1 time(s)

TOP 10 BLOCKED IPS: - 2 time(s) - 1 time(s) - 1 time(s) - 1 time(s) - 1 time(s)

---------------------- ModSecurity2 (mod_security2) End -------------------------

If you’re just looking for an example of parsing the log file, the perl script that does that is here.