All pastes #2069752 Raw Edit

Miscellany

public text v1 · immutable
#2069752 ·published 2011-05-27 03:22 UTC
rendered paste body
#!/usr/bin/perl

if (($ARGV[0] eq "") || ($ARGV[1] eq "")) {
        print "scan hostname port [or port-range]\n";
        exit;
}

$hostname = $ARGV[0];
$port_specify = $ARGV[1];

if ($port_specify =~ m/\-/) {
        my @split_ports = split(/\-/,$port_specify);
        my $first_in_range = $split_ports[0];
        my $second_in_range = $split_ports[1];
        for ($first_in_range .. $second_in_range) {
                `nc -zv $hostname $_`;
        }
} else {
        `nc -zv $hostname $port_specify`;
}