epixoip
By: a guest | Aug 9th, 2009 | Syntax:
Perl | Size: 1.50 KB | Hits: 61 | Expires: Never
#!/usr/bin/perl
# Tue Apr 3 16:42:08 PDT 2007 by epixoip <epixoip@hush.com>
# synping - a tcp syn ping utility
use Net::Ping;
use Time::HiRes;
use Getopt::Std;
my %options = ();
getopts("c:i:t:T",\%options);
our $host = $ARGV[0];
our $port = $ARGV[1];
our $seq = 0;
sub usage {
print "SYN Ping Utility - by epixoip <epixoip\@hush.com>\n";
print "Usage:\t$0 [-citT] <host> <port>\n";
print "\t-c\tStop after \$foo iterations\n";
print "\t-i\tWait \$foo seconds between iterations\n";
print "\t-t\tSet TTL to \$foo\n";
print "\t-T\tTimestamp output\n\n";
}
$p = Net::Ping->new("syn", $options{t});
$p->hires();
$p->{port_num} = $port;
while (1) {
$p->ping($host);
if (($hostn,$rtt,$ip) = $p->ack) {
printf("ack from $host ($ip) port=$port seq=$seq time=%.2f ms\n", $rtt * 1000
);
} else {
my $reason = $p->nack($host);
print "seq $seq: no reply from $host: $reason\n";
}
if ($seq == $options{c} - 1) {
}
}
$seq++;
} else {
}
}