#Portscanner use IO::Socket; $info = "\t* Simple Portscanner by GloBoX\n\n"; sub start { if ($#ARGV != 2) { die "Use: $0 host startport stopport\n" } else { $host = $ARGV[0]; $startport = $ARGV[1]; $stopport = $ARGV[2]; if ($startport >= $stopport) { die "Use: $0 host startport stopport\n" } print $info; &scanstart(); } } sub socket { $cport = $_[0]; $bool = "True"; $socket = IO::Socket::INET->new ( PeerAddr => $host, PeerPort => $cport, Proto => "tcp", Timeout => 1, Type => SOCK_STREAM ) || { $bool = "False" }; return($bool); } sub scanstart { my $a = -1; print "\t** Scanning **\n"; for ($i = $startport; $i <= $stopport; $i++) { if (&socket($i) eq "True") { print "\t* Port $i; Open!\n"; @OPorts[$a] = $i; $a++; } else { print "\t* Port $i; Closed!\n" } } print "\n** Open Ports: "; foreach $pp (@OPorts) { print "$pp, " } } &start();