Skip to content
Snippets Groups Projects
Commit 3f9dc03c authored by Jan Soukal's avatar Jan Soukal
Browse files

task #519, kod klienta uzavren do eval bloku

parent 4a2fbcab
Branches
Tags
No related merge requests found
...@@ -18,17 +18,14 @@ use strict; ...@@ -18,17 +18,14 @@ use strict;
# This code should developer add into his/her application. # This code should developer add into his/her application.
# Path to warden-client directory # Path to warden-client directory
my $warden_path = '/opt/warden-client'; my $warden_path = '/home/soukal/client-test/2.0.0_beta/warden-client/';
# Inclusion of warden-client receiving functionality # Inclusion of warden-client receiving functionality
require $warden_path . '/lib/WardenClientReceive.pm'; require $warden_path . '/lib/WardenClientReceive.pm';
# Definition of requested event type. This attributes is also set on server # Definition of requested event type. This attributes is also set on server
# and must not change. # and must not change.
my $requested_type = "botnet_c_c"; my $requested_type = "portscan";
# Download of new evetns from Warden server
my @new_events = WardenClientReceive::getNewEvents($warden_path, $requested_type);
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Simple code that prints out new events obtained from Warden server. # Simple code that prints out new events obtained from Warden server.
...@@ -37,9 +34,15 @@ print "+------------------------------------------------------------------------ ...@@ -37,9 +34,15 @@ print "+------------------------------------------------------------------------
print "| id | hostname | service | detected | type | source_type | source | target_proto | target_port | attack_scale | note | priority | timeout |\n"; print "| id | hostname | service | detected | type | source_type | source | target_proto | target_port | attack_scale | note | priority | timeout |\n";
print "+------------------------------------------------------------------------------------------------------------------------------------------+\n"; print "+------------------------------------------------------------------------------------------------------------------------------------------+\n";
foreach (@new_events) { # Download of new evetns from Warden server
print "| " . join(' | ', @$_) . " |" . "\n"; while (my @new_events = WardenClientReceive::getNewEvents($warden_path, $requested_type)) {
foreach my $event_ref (@new_events) {
my @event = @$event_ref;
print "| " . join(' | ', @event) . " |" . "\n";
} }
print "+------------------------------------------------------------------------------------------------------------------------------------------+\n";
}
print "+------------------------------------------------------------------------------------------------------------------------------------------+"; print "+------------------------------------------------------------------------------------------------------------------------------------------+";
print "\n"; print "\n";
print "Last events in: " . scalar(localtime(time)) . "\n"; print "Last events in: " . scalar(localtime(time)) . "\n";
......
...@@ -81,6 +81,10 @@ sub c2s ...@@ -81,6 +81,10 @@ sub c2s
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
sub getNewEvents sub getNewEvents
{ {
my @events;
eval {
my $warden_path = shift; my $warden_path = shift;
my $requested_type = shift; my $requested_type = shift;
...@@ -132,7 +136,7 @@ sub getNewEvents ...@@ -132,7 +136,7 @@ sub getNewEvents
# parse returned SOAP data object # parse returned SOAP data object
my ($id, $hostname, $service, $detected, $type, $source_type, $source, $target_proto, $target_port, $attack_scale, $note, $priority, $timeout); my ($id, $hostname, $service, $detected, $type, $source_type, $source, $target_proto, $target_port, $attack_scale, $note, $priority, $timeout);
my @events; # my @events;
my @response_list = $response->valueof('/Envelope/Body/getNewEventsResponse/event/'); my @response_list = $response->valueof('/Envelope/Body/getNewEventsResponse/event/');
while (scalar @response_list) { while (scalar @response_list) {
my $response_data = shift(@response_list); my $response_data = shift(@response_list);
...@@ -169,6 +173,10 @@ sub getNewEvents ...@@ -169,6 +173,10 @@ sub getNewEvents
print ID $last_id; print ID $last_id;
close ID; close ID;
} }
} # End of eval block
or do {
return;
};
return @events; return @events;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment