I was looking at perl today and it looked like a nice and easy language to me. Then i saw it has some network abillities and i was apsolutly thrilled. Now i have a small port scanner with only a few features
I wan't to make it better but i saw perl first time today
so i need a little help, an idea.
Here is the source code:
Code:
#/usr/bin/perl -w
use IO::Socket;
print "Enter remote host adress: ";
chomp ($host=<STDIN>);
$hostip = inet_ntoa(inet_aton($host));
print "Enter port range\n";
print "From port: \n";
chomp ($fromport=<STDIN>);
print "To port: \n";
chomp ($toport=<STDIN>);
print "Host resolved to IP Address:'$hostip'\n";
while ($fromport<=$toport){
my $sock = IO::Socket::INET->new(proto=>'tcp', PeerAddr=>"$host", PeerPort=>$fromport) && print "Port '$fromport' found!\n";
$fromport++;
if ($fromport==$toport) {
close($sock);
}
}
This is what i want to add/make better:
1. Reduce scanning time. There is
timeout argument for IO::Socket::INET but i don't know how to use it. Tried, but didn't give any results. Also, couldn't find anything about it on the cpan, etc...
2. Description for every port. I wanted to create an array with descriptions (something like this):
Code:
@portdesc = ("","","","","","","","","","","","","","","","","","","","","ftp","","telnet","",
and it will take the $fromport-1 value to know for which one to write. But this looks like very boring job (there are 65535 ports!!!). So i was wondering anyone have a better idea?
3. Does anyone have an idea what should i add? I am just learning trough this example so this is nothing special remember.
Spasojevic Dimitrije