diff --git a/src/warden-client/doc/example-sender-2.pl.txt b/src/warden-client/doc/example-sender-2.pl.txt new file mode 100755 index 0000000000000000000000000000000000000000..6e2a5fa87ad4d77ffd29b7dfeec9b83b0eee9df8 --- /dev/null +++ b/src/warden-client/doc/example-sender-2.pl.txt @@ -0,0 +1,119 @@ +#!/usr/bin/perl -w +# +# sender.pl +# +# Copyright (C) 2011-2012 Cesnet z.s.p.o +# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz> +# Jan SOUKAL <soukal@ics.muni.cz> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of the Cesnet z.s.p.o nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# This software is provided ``as is'', and any express or implied +# warranties, including, but not limited to, the implied warranties of +# merchantability and fitness for a particular purpose are disclaimed. +# In no event shall the Cesnet z.s.p.o or contributors be liable for +# any direct, indirect, incidental, special, exemplary, or consequential +# damages (including, but not limited to, procurement of substitute +# goods or services; loss of use, data, or profits; or business +# interruption) however caused and on any theory of liability, whether +# in contract, strict liability, or tort (including negligence or +# otherwise) arising in any way out of the use of this software, even +# if advised of the possibility of such damage. +# + +use Switch; +use strict; +use DateTime; + +my $warden_path = '/home/soukal/pokus/warden/warden-client'; +require $warden_path . '/lib/WardenClientSend.pm'; + +my $service = "test"; +# service is needed in authorization process of the client, +# therefore it can not be set randomly +#switch (int(rand(2) + 0.5)) { +# case 0 { $service = 'ScanDetector'; } +# case 1 { $service = 'PhiGaro'; } +# case 2 { $service = 'HoneyScan'; } +# } + +my $detected = DateTime->from_epoch(epoch => time()); + +my $type = ""; +switch (int(rand(9) + 0.5)) { + case 0 { $type = 'portscan'; } + case 1 { $type = 'bruteforce'; } + case 2 { $type = 'spam'; } + case 3 { $type = 'phishing'; } + case 4 { $type = 'botnet_c_c'; } + case 5 { $type = 'dos'; } + case 6 { $type = 'malware'; } + case 7 { $type = 'copyright'; } + case 8 { $type = 'webattack'; } + case 9 { $type = 'other'; } + } + +my $source_type = ""; +switch (int(rand(2) + 0.5)) { + case 0 { $source_type = 'IP'; } + case 1 { $source_type = 'URL'; } + case 2 { $source_type = 'Reply-To:'; } + } + +my $source = (int(rand(254) + 0.5) + 1) . "." . (int(rand(254) + 0.5) + 1) . "." . (int(rand(254) + 0.5) + 1) . "." . (int(rand(254) + 0.5) + 1); + +my $target_proto = ""; +switch (int(rand(1) + 0.5)) { + case 0 { $target_proto = 'TCP'; } + case 1 { $target_proto = 'UDP'; } + } + +my $target_port = ""; +switch (int(rand(5) + 0.5)) { + case 0 { $target_port = '22'; } + case 1 { $target_port = '23'; } + case 2 { $target_port = '25'; } + case 3 { $target_port = '443'; } + case 4 { $target_port = '3389'; } + case 5 { $target_port = 'null'; } + } + +my $attack_scale = (int(rand(100000) + 0.5) + 1000); + +my $note = "tohle je takova normalni jednoducha poznamka"; + +my $priority = int(rand(255) + 0.5); + +my $timeout = int(rand(255) + 0.5); + + +my @event = ( + $service, # $service + "$detected", # $detected + $type, # $type + $source_type, # $source_type + $source, # $source + $target_proto, # $target_proto + $target_port, # $target_port + $attack_scale, # $attack_scale + $note, # $note + $priority, # $priority + $timeout, # $timeout + ); + +WardenClientSend::saveNewEvent($warden_path, \@event); + +#foreach (@event) { +# print "$_\n"; +#}