]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Introduce message parser for HTTPD related notifications.
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 18 Feb 2016 12:13:31 +0000 (13:13 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 18 Feb 2016 12:13:31 +0000 (13:13 +0100)
This new messge parser is able to detect htaccess related
brute-force login attempts on a running HTTPD server and
to report the source IP-address (IPv4 and IPv6).

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
modules/Parser.pm

index 4f03bf958064598ff5e9a38974f6ea46805bb713..65f770879014c893167314513ea32af66fcad2a7 100644 (file)
@@ -9,6 +9,7 @@ our @EXPORT_OK = qw(IsSupportedParser Parser);
 # This hash contains all supported parsers and which function
 # has to be called to parse messages in the right way.
 my %logfile_parsers = (
+       "httpd" => \&message_parser_httpd,
        "snort" => \&message_parser_snort,
        "ssh" => \&message_parser_ssh,
 );
@@ -129,4 +130,55 @@ sub message_parser_ssh (@) {
        return;
 }
 
+#
+## The HTTPD message parser.
+#
+## This subfunction is used for parsing and detecting different attacks
+## against a running HTTPD service.
+#
+sub message_parser_httpd (@) {
+       my @message = @_;
+
+       # The name of the parser module.
+       my $name = "HTTPD";
+
+       # Variable to store the grabbed IP-address.
+       my $address;
+
+       # Variable to store the parsed event.
+       my $message;
+
+       # Loop through all lines, in case multiple one have
+       # been passed.
+       foreach my $line (@message) {
+               # This will catch brute-force attacks against htaccess logins (username).
+               if ($line =~ /.*\[error\] \[client (.*)\] user(.*) not found:.*/) {
+                       # Store the grabbed IP-address.
+                       $address = $1;
+
+                       # Set event message.
+                       $message = "Possible WUI brute-force attack, wrong user: $2.";
+               }
+
+               # Detect htaccess password brute-forcing against a username.
+               elsif ($line =~ /.*\[error\] \[client (.*)\] user(.*): authentication failure for.*/) {
+                       # Store the extracted IP-address.
+                       $address = $1;
+
+                       # Set event message.
+                       $message = "Possible WUI brute-force attack, wrong password for user: $2.";
+               }
+       }
+
+       # Check if at least the IP-address information has been extracted.
+       if (defined ($address)) {
+               # Return the extracted values and event message.
+               return "$address $name $message";
+       }
+
+       # If we got here, the provided message is not affected by any filter and
+       # therefore can be skipped. Return nothing (False) in this case.
+       return;
+}
+
 1;