#!/usr/bin/perl
# Author: gendou
# Disclaimer: This script is meant for educational use only. Obey the law in your country!
# Usage: portscan.pl [victim=localhost] [start=1] [end=1024]
# v 1.0.2

use IO::Socket;
$| = 1;

$target = shift || 'localhost';
$first  = shift || 1;
$last   = shift || 1024;

$last = $first if($last < $first);
print "Port scan on $target from $first to $last...\n";

foreach ($port = $first; $port <= $last; $port++) {
        print "\rTrying $target:$port ... ";
        print "open!\n" if(IO::Socket::INET->new(PeerAddr=>"$target:$port",Proto=>'tcp',Timeout=>1));
}
print "\n";
