derhansen / logwatch-modsec2

Logwatch script for ModSecurity 2 audit logfile analysis
20 stars 8 forks source link

Reverse DNS Lookup #10

Open dsbcpas opened 10 years ago

dsbcpas commented 10 years ago

If there is any interest, I have added ip domain name lookup to logwatch services/mod_security2 by adding or editing in the following. Since I am just a sys admin and know little about perl, likely a better method but here it is. I have found it useful for loosening up the rules here and there for various ips like search engine crawls.

use Socket; my $name = ();

Start summary

$name = gethostbyaddr(inet_aton($fromip), AF_INET) or $name = "not in arpa"; print " [ip: " . sprintf("%-15s", $fromip) . "] "; print " $name ";

Top 10 blocked IPs

$name = gethostbyaddr(inet_aton($ip), AF_INET) or $name = "not in arpa"; print "\n " . sprintf("%2s", ($cnt + 1)) . ". " . $ip . " - " . $topips{$ip} . " time(s)"; print " $name ";

derhansen commented 10 years ago

Thanks for your feedback. I will check if a DNS Lookup can be implemented, so it is configurable in the config file of the service.