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

rozsireni command-line-sender.pl o podporu dlouhych argumenty (#973)

parent 5ead95a9
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
use strict; use strict;
use DateTime; use DateTime;
use Getopt::Std; use Getopt::Long;
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Warden 2.2. Command-line Client, Sender # Warden 2.2. Command-line Client, Sender
...@@ -19,44 +19,57 @@ use Getopt::Std; ...@@ -19,44 +19,57 @@ use Getopt::Std;
# Preparation of event attributes. # Preparation of event attributes.
# Mandatory attributes # Mandatory attributes
our $opt_s; # service my $opt_s; # service
our $opt_d = "" . DateTime->from_epoch(epoch => time()) . ""; # time of detection my $opt_t = "" . DateTime->from_epoch(epoch => time()) . ""; # time of detection
our $opt_t; # type of detected event my $opt_e; # type of detected event
our $opt_o; # event source type my $opt_o; # event source type
# Optional attributes # Optional attributes
our $opt_v = ""; # event source value my $opt_v = ""; # event source value
our $opt_p = ""; # target protocol my $opt_p = ""; # target protocol
our $opt_r = ""; # target port my $opt_r = ""; # target port
our $opt_a = ""; # attack scale my $opt_a = ""; # attack scale
our $opt_n = ""; # note my $opt_n = ""; # note
# Other attributes # Other attributes
our $opt_w = "../../warden-client"; # path to warden directory my $opt_w = "../../warden-client"; # path to warden directory
our $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.
if (!getopts("s:d:t:o:v:p:r:a:n:w:h") || if (!GetOptions("service|s=s" => \$opt_s,
!defined($opt_s) || !defined($opt_t) || !defined($opt_o) || "timestamp|t=s" => \$opt_t,
"event-type|e=s" => \$opt_e,
"source-type|o=s" => \$opt_o,
"source-value|v=s" => \$opt_v,
"proto|p=s" => \$opt_p,
"port|r=i" => \$opt_r,
"attack-scale|a=i" => \$opt_a,
"note|n=s" => \$opt_n,
"warden-dir|w=s" => \$opt_w,
"help|h" => \$opt_h) ||
!defined($opt_s) || !defined($opt_e) || !defined($opt_o) ||
$opt_h) { $opt_h) {
print "\nUsage: ./command-line-sender.pl [-s <service>] [-d <timestamp_of_detection>] [-t <type>] [-o <source_type>] [-v <source>] [-p <protocol>] [-r <port>] [-a <attack_scale>] [-n <note>] [-w <warden_directory>] [-h]\n"; print "\nAbout command-line-sender.pl\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> - Name of detection service\n"; print " -s SERVICE, --service=SERVICE - Name of detection service\n\n";
print "-d <timestamp_of_detection> - Timestamp of detection. print " -e EVENT_TYPE, --event-type=EVENT_TYPE - Type of detected event\n\n";
Default is current system time (" . DateTime->from_epoch(epoch => time()) . ")\n"; print " -o SOURCE_TYPE, --source-type=SOURCE_TYPE - Type of detected event\'s source\n\n";
print "-t <type> - Type of detected event\n";
print "-o <source_type> - Type of detected event\'s source\n";
print "\n"; print "\n";
print "Optional (but important) arguments:\n\n"; print "Optional (but important) arguments:\n\n";
print "-v <source> - Source of detected event\n"; print " -t TIMESTAMP, --timestamp=TIMESTAMP - Timestamp of detection.\n";
print "-p <protocol> - Protocol\n"; print " Default is current system time (" . DateTime->from_epoch(epoch => time()) . ")\n\n";
print "-r <port> - Port\n"; print " -v SOURCE_VALUE, --source-value=SOURCE_VALUE - Source of detected event\n\n";
print "-a <attack_scale> - Scale of detected event\n"; print " -p PROTO, --proto=PROTO - Protocol\n\n";
print "-n <note> - Note, comment or other data\n"; print " -r PORT, --port=PORT - Port\n\n";
print "-w <warden_directory> - Path to warden-client directory. Default is \'../../warden-client\'\n"; print " -a ATTACK_SCALE, --attack-scale=ATTACK_SCALE - Scale of detected event\n\n";
print "-h - Print this help\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 "\nExample: ./command-line-sender.pl -s test -t webattack -o URL -v 123.123.098.098 -p TCP -r 443 -a 100 -n \"important notice\"\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 #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 "\nNOTE: For more information how to use particular values see warden-client/doc/README file.\n\n"; print "\nNOTE: For more information how to use particular values see warden-client/doc/README file.\n\n";
...@@ -64,7 +77,7 @@ if (!getopts("s:d:t:o:v:p:r:a:n:w:h") || ...@@ -64,7 +77,7 @@ if (!getopts("s:d:t:o:v:p:r:a:n:w:h") ||
} }
my @event = ($opt_s, $opt_d, $opt_t, $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);
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
......
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