[Snort-users] Re: Help with alert_unixsock issues

Simon Biles simon.biles at ...11827...
Thu Dec 1 06:41:00 EST 2005

Try the following Perl for example :


# Include the socket libraries

use IO::Socket;

# This is the template to capture the Alert Name
# Edit this to get the additional packets.

$TEMPLATE = "A256 A*";

# Release the socket if it already exists

unlink "/var/log/snort/snort_alert";

# In case of user termination - exit gracefully.

$SIG{TERM} = $SIG{INT} = sub { exit 0 };

# Open up the socket.
my $client = IO::Socket::UNIX->new(Type => SOCK_DGRAM,
                   Local => "/var/log/snort/snort_alert")
  or die "Socket: $@";

print STDOUT "Socket Open ... \n";

# Loop receiving data from the socket, pulling out the
# alert name and printing it.

my $data;

while ( true ) {
    @FIELDS = unpack($TEMPLATE, $data);

    print "@FIELDS[0] \n";


# At termination close up the socket again.

END {unlink "/var/log/snort/snort_alert";}

Simon Biles
CISSP, OPSA, BS7799 Lead Auditor, MBCS

More information about the Snort-users mailing list