#!/usr/bin/perl -w use IO::Socket; use Socket; use IO::Select; print "\nHost/IP you want to scan: "; my $end=5000; my $hostip="localhost"; my (@aberta, %portes); for ($x=0; $x <=$end; $x++) { my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $x, Proto => 'tcp', Timeout => 4); if ($scansock) { push (@aberta, $x); $scansock->close; } } if (@aberta) { foreach $z (@aberta) { print "$z\n" } } else { print "\nNo open ports found\n"; }