Saturday 17 March 2012

Port scaner using perl

#!/usr/bin/perl
# Perl Port Scanner
# Sh3llc0d3
use IO::Socket;

if(@ARGV != 3){
    print "Sh3llc0d3\n";
    print "Learn how to use this!!!\n";
    print "$0 [start port] [end port] [host]\n";
        print "Example: $0 1 65535 127.0.0.1\n";
    exit 1;
}
if($ARGV[0] > $ARGV[1]){
    print "The Start port is higher then End port: Sort it out!\n";
    exit 1;
}
for($i = $ARGV[0]; $i <= $ARGV[1]; ++$i){
    $host = new IO::Socket::INET(
        PeerAddr => $ARGV[2],
        PeerPort => $i,
        Proto => 'tcp',
        Timeout => 1
    );
    if($host){
        print "Port $i is OPEN\n";
    } else {
        print "Port $i is CLOSED\n";
    }
}
exit;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.