CAPE-Utils

 view release on metacpan or  search on metacpan

src_bin/suricata_extract_submit  view on Meta::CPAN

#!/usr/bin/env perl

use File::Find::Rule;
use warnings;
use strict;
use Config::Tiny;
use File::Slurp qw(append_file write_file read_file);
use Time::Piece;
use File::MimeInfo::Magic;
use Net::Subnet qw(subnet_matcher);
use LWP::UserAgent;
use HTTP::Request::Common;
use File::Temp qw/ tempdir  /;
use File::Copy;
use POSIX 'strftime';
use Sys::Syslog;
use JSON;
use Sys::Hostname;
use Proc::PID::File;
use Pod::Usage;
use Getopt::Long;
use Web::ACL;

=head1 NAME

suricata_extract_submit - Submits files extracted by Suricata to mojo_cape_submit for detonation via CAPEv2

=head1 VERSION

1.0.0

=cut

sub version {
	print "suricata_extract_submit v. 1.0.0\n";
}

=head1 SYNOPSIS

suricata_extract_submit

*/5 * * * * /usr/local/bin/suricata_extract_submit 2> /dev/null > /dev/null

=head1 DESCRIPTION

What is printed to standard out is also sent to syslog.

This requires having the file-store output configured akin to below.

      - file-store:
          version: 2
          enabled: yes
          dir: /var/log/suricata/files
          write-fileinfo: yes
          stream-depth: 0
          force-hash: [sha1, md5]
          xff:
            enabled: no
            mode: extra-data
            deployment: reverse
            header: X-Forwarded-For

The force-hash values are optional as this script will automatically compute
those for inclusion as well SHA256.

This will use `/var/run/suricata_extract_submit.pid` as a PID file
to ensure only a single instance is running.

May be checked to see if it has hung like below. Below will alert if a PID
file with a M time of older than 5 minutes.

    /usr/local/libexec/nagios/check_file_age -i -f /var/run/suricata_extract_submit.pid



( run in 1.079 second using v1.01-cache-2.11-cpan-5837b0d9d2c )