1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#!/usr/bin/perl if(@ARGV<2){print "Usage: $0 <start IP> <port>\n";exit;} else{ use IO::Socket; $sIP="@ARGV[0]"; $port="@ARGV[1]"; ($ip1,$ip2,$ip3,$ip4)=split(/\./,$sIP); while($ip4<254){ $ipaddr="$ip1.$ip2.$ip3.$ip4"; IP_connect(); $ip4++; } } sub IP_connect { $z=IO::Socket::INET->new( PeerAddr=>"$ipaddr",PeerPort=>"$port",Proto=>"tcp",Timeout=>"5") or warn "Cannot connect to $ipaddr\n"; if($z){print "Connect! - $ipaddr:$port\n";} close($z); }
|