NAME

POE::Filter::Snort - a POE stream filter that parses Snort logs into hashes

SYNOPSIS

#!/usr/bin/env perl

use warnings; use strict;
use POE qw(Filter::Snort Wheel::FollowTail);

POE::Session->create(
	inline_states => {
		_start  => \&start_log,
		got_rec => \&display_record,
	},
);

POE::Kernel->run();
exit;

sub start_log {
	$_[HEAP]->{watcher} = POE::Wheel::FollowTail->new(
		Filename   => "/var/log/snort/alert",
		Filter     => POE::Filter::Snort->new(),
		InputEvent => "got_rec",
	);
}

sub display_record {
	my $rec = $_[ARG0];

	print "Got a snort record:\n";
	print "\tComment: $rec->{comment}\n"  if exists $rec->{comment};
	print "\tClass  : $rec->{class}\n"    if exists $rec->{class};
	print "\tPrio   : $rec->{priority}\n" if exists $rec->{priority};
	if (exists $rec->{src_ip}) {
		if (exists $rec->{src_port}) {
			print "\tSource : $rec->{src_ip} $rec->{src_port}\n";
			print "\tDest   : $rec->{dst_ip} $rec->{dst_port}\n";
		}
		else {
			print "\tSource : $rec->{src_ip}\n";
			print "\tDest   : $rec->{dst_ip}\n";
		}

		foreach my $xref (@{$rec->{xref}}) {
			print "\tXref   : $xref\n";
		}
	} 
}

DESCRIPTION

POE::Filter::Snort parses streams containing Snort alerts. Each alert is returned as a hash containing the following fields: comment, class, priority, src_ip, dst_ip, src_port, dst_port, xref.

Most fields are optional. For example, some snort alerts don't contain a source and destination IP address. Those that do aren't always accompanied by a source and destination port.

The xref field refers to an array of URLs describing the alert in more detail. It will always exist, but it may be empty if no URLs appear in snort's configuration file.

SEE ALSO

Snort - "the de facto standard for intrusion detection/prevention" http://www.snort.org/

POE::Filter::Snort's Subversion repository is hosted at http://thirdlobe.com/projects/ . Patches and collaborators are welcome.

AUTHORS

POE::Filter::Snort is written by Rocco Caputo. His CPAN ID is RCAPUTO. You can reach him by e-mail by his CPAN ID @cpan.org.

COPYRIGHT

Copyright 2005, Rocco Caputo. All rights are reserved.

POE::Filter::Snort is free software; you may use, redistribute, and/or modify it under the same terms as Perl itself.