没什么技术可言,作个标记!
#!/usr/bin/perl -w
#Description: check is_host_alive and is_host_port_open
#Author: donghao
#Date: 2008-05-15
use strict;
use IO::Socket::INET;
use Net::Ping;
# Global Variable
my $Start_pt = $ARGV[1];
my $End_pt = $ARGV[2];
my @ip_net;
#ReadMe
sub Usage(){
print "Note:\n";
print "perl scan_port.pl Ipaddr_File Start_Port End_Port\n";
print "For example: perl scan_port.pl Filename 1 10000\n";
print "Note:The file contains single ip address(192.168.1.2)";
print " or ip network(192.168.1.1-192.168.1.254)\n";
print "Good Luck!\n"
}
#Is_ip_network_or_single_ip
sub Is_ip_nk{
if($_[0] =~ /(^\d+)\.(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.(\d+)\.(\d+$)/){
for(my $var=$4;$var<=$8;$var++){
&Is_ip_correct($1,$2,$3,$var);
push @ip_net,"$1\.$2\.$3\.$var";
}
return 1;
}
return 0;
}
#Is_Host_Alive or Dead
sub Is_Host_Alive{
my $tmp_syn=Net::Ping->new("syn");
$tmp_syn->ping($_[0]);
if(!$tmp_syn->ack){
printf "The Host %-15s was dead!\n",$_[0];
$tmp_syn->close;
return 0;
}
$tmp_syn->close;
return 1;
}
