Skip to content
Snippets Groups Projects
Commit 2fb1cb8a authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

pridano nacitani adresare lib a modulu WardenClient.pm pomoci promenne...

pridano nacitani adresare lib a modulu WardenClient.pm pomoci promenne __FILE__; nazev skriptu tisknut pomoci promenne ; smazana defaultni cesta k Warden client balicku ../../warden-client
parent 199fc4ed
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ use warnings; ...@@ -9,6 +9,8 @@ use warnings;
use DateTime; use DateTime;
use Getopt::Long; use Getopt::Long;
use File::Basename;
use FindBin qw($RealScript);
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Warden 2.2. Command-line Client, Sender # Warden 2.2. Command-line Client, Sender
...@@ -34,7 +36,7 @@ my $opt_a = ""; # attack scale ...@@ -34,7 +36,7 @@ my $opt_a = ""; # attack scale
my $opt_n = ""; # note my $opt_n = ""; # note
# Other attributes # Other attributes
my $opt_w = "../../warden-client"; # path to warden directory my $opt_w; # path to warden directory
my $opt_h; # display help my $opt_h; # display help
# Check whether mandatory fields are given. Otherwise print help and exit. # Check whether mandatory fields are given. Otherwise print help and exit.
...@@ -51,9 +53,7 @@ if (!GetOptions("service|s=s" => \$opt_s, ...@@ -51,9 +53,7 @@ if (!GetOptions("service|s=s" => \$opt_s,
"help|h" => \$opt_h) || "help|h" => \$opt_h) ||
!defined($opt_s) || !defined($opt_e) || !defined($opt_o) || !defined($opt_s) || !defined($opt_e) || !defined($opt_o) ||
$opt_h) { $opt_h) {
print "\nAbout command-line-sender.pl\n"; print "\nUsage: ./$RealScript -s <service> -e <event_type> -o <source_type> [-t <timestamp_of_detection>] [-v <source>] [-p <protocol>] [-r <port>] [-a <attack_scale>] [-n <note>] [-w <warden_directory>] [-h]\n";
print "\n Script is supposed to be used as a simple command-line warden client that can send one event to the warden server at a time. For more information about the Warden system and it's events' structure, please see warden-client/doc/README file.\n";
print "\nUsage:\n\n ./command-line-sender.pl -s <service> -e <event_type> -o <source_type> [-t <timestamp_of_detection>] [-v <source>] [-p <protocol>] [-r <port>] [-a <attack_scale>] [-n <note>] [-w <warden_directory>] [-h]\n";
print "\nArguments:\n\n"; print "\nArguments:\n\n";
print " -s SERVICE, --service=SERVICE - Name of detection service\n\n"; print " -s SERVICE, --service=SERVICE - Name of detection service\n\n";
print " -e EVENT_TYPE, --event-type=EVENT_TYPE - Type of detected event\n\n"; print " -e EVENT_TYPE, --event-type=EVENT_TYPE - Type of detected event\n\n";
...@@ -67,29 +67,27 @@ if (!GetOptions("service|s=s" => \$opt_s, ...@@ -67,29 +67,27 @@ if (!GetOptions("service|s=s" => \$opt_s,
print " -r PORT, --port=PORT - Port\n\n"; print " -r PORT, --port=PORT - Port\n\n";
print " -a ATTACK_SCALE, --attack-scale=ATTACK_SCALE - Scale of detected event\n\n"; print " -a ATTACK_SCALE, --attack-scale=ATTACK_SCALE - Scale of detected event\n\n";
print " -n NOTE, --note=NOTE - Note, comment or other data\n\n"; print " -n NOTE, --note=NOTE - Note, comment or other data\n\n";
print " -w WARDEN_DIR, --warden-dir=WARDEN_DIR - Path to the warden-client directory. Default is \'../../warden-client\'\n\n"; print " -w WARDEN_DIR, --warden-dir=WARDEN_DIR - Path to the warden-client directory.\n\n";
print " -h, --help - Print help\n\n"; print " -h, --help - Print help\n\n";
print "\nExample #1: ./command-line-sender.pl -s PhishTracker -e webattack -o URL -v 123.123.098.098 -p TCP -r 443 -a 100 -n \"important notice\"\n"; print "\nExample #1: ./$RealScript -s PhishTracker -e webattack -o URL -v 123.123.098.098 -p TCP -r 443 -a 100 -n \"important notice\"\n";
print "\nExample #2: ./command-line-sender.pl --service=ScanGuardian --event-type=portscan --source-type=IP --timestamp=\"2013-04-25T13:36:31\" --source-value=\"123.123.1.23\" --proto=TCP --port=25 --attack-scale=1234 --note=\"The very first run of ScanGuardian :)\" --warden-dir \"/opt/warden/warden-client\"\n"; print "\nExample #2: ./$RealScript --service=ScanGuardian --event-type=portscan --source-type=IP --timestamp=\"2013-04-25T13:36:31\" --source-value=\"123.123.1.23\" --proto=TCP --port=25 --attack-scale=1234 --note=\"The very first run of ScanGuardian :)\" --warden-dir \"/opt/warden/warden-client\"\n";
print "\nNOTE: For more information how to use particular values see warden-client/doc/README file.\n\n"; print "\nNOTE: For more information see <warden-client_path>/doc/README file.\n\n";
exit 0; exit 0;
} }
my @event = ($opt_s, $opt_t, $opt_e, $opt_o, $opt_v, my @event = ($opt_s, $opt_t, $opt_e, $opt_o, $opt_v, $opt_p, $opt_r, $opt_a, $opt_n);
$opt_p, $opt_r, $opt_a, $opt_n);
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Use of warden-client sender. # Use of warden-client sender.
# Path to warden-client folder # Load Warden client library and use main module
my $warden_path = $opt_w; my $bin = File::Basename::dirname(__FILE__);
use lib "$bin/../lib";
# Inclusion of warden-client sender module use WardenClient;
require $warden_path . '/lib/WardenClient.pm';
# Sending event to Warden server # Sending event to Warden server
WardenClient::saveNewEvent(\@event); WardenClient::saveNewEvent(\@event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment