From: Martin Holste Date: Mon, 27 Feb 2012 16:54:44 +0000 (-0600) Subject: Added Shadowserver plugin. X-Git-Tag: suricata-1.3beta1~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33d8453581a8889eac1c23d5f39529c310c23ee2;p=thirdparty%2Fsuricata.git Added Shadowserver plugin. --- diff --git a/contrib/file_processor/Processor/ShadowServer.pm b/contrib/file_processor/Processor/ShadowServer.pm new file mode 100644 index 0000000000..c9c7a5f9a0 --- /dev/null +++ b/contrib/file_processor/Processor/ShadowServer.pm @@ -0,0 +1,49 @@ +package Processor::ShadowServer; +use Moose; +extends 'Processor'; +use Data::Dumper; +use LWP::UserAgent; +use JSON; + +has 'md5' => (is => 'ro', isa => 'Str', required => 1); +has 'ua' => (is => 'rw', isa => 'LWP::UserAgent', required => 1, default => sub { return LWP::UserAgent->new(agent => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'); }); +has 'url_template' => (is => 'ro', isa => 'Str', required => 1, default => 'http://innocuous.shadowserver.org/api/?query=%s'); +sub name { 'ShadowServer' } +sub description { 'Processor for shadowserver.com' } + +sub process { + my $self = shift; + my $url = sprintf($self->url_template, $self->md5); + $self->log->debug('Getting url ' . $url); + my $response = $self->ua->get($url); + if ($response->code eq 200){ + if ($response->decoded_content =~ /No match/){ + $self->log->debug('No result'); + return 0; + } + elsif ($response->decoded_content =~ /Whitelisted/){ + $self->log->info('Whitelisted'); + return 0; + } + $self->log->info('Got shadowserver.com result'); + my $ret; + eval { + my ($meta,$json) = split(/\n/, $response->decoded_content); + my @meta_cols = qw(md5 sha1 first_date last_date type ssdeep); + my %metas; + @metas{@meta_cols} = split(/\,/, $meta); + $ret = { meta => \%metas, results => decode_json($json) }; + }; + if ($@){ + $self->log->error($@); + return 0; + } + return $ret; + } + else { + $self->log->debug('Communications failure: ' . Dumper($response)); + return 0; + } +} + +1 diff --git a/contrib/file_processor/file_processor.conf b/contrib/file_processor/file_processor.conf index 51af45568f..a1170ab437 100644 --- a/contrib/file_processor/file_processor.conf +++ b/contrib/file_processor/file_processor.conf @@ -9,6 +9,7 @@ "Processor::Anubis": 1, "Processor::Malwr": 1, "Processor::ThreatExpert": 1, + "Processor::ShadowServer": 1 #"Processor::VirusTotal": 1 } }