PDA

View Full Version : A Very Basic tool in Perl-- Port Scanner



prashant_uniyal
11-13-2010, 11:47 PM
I was bit confused between Perl and Python :D. Started with Perl, will also learn python soon. Lets have our first tool for this section, a very basic one. Its a very simple port scanner which scans open ports on a host.


#!/usr/bin/perl
# TCP Port scanner

print q{
=================================================
SIMPLE TCP PORT SCANNER

C0d3d by: t3rm!n4t0r

TeAm: LOXians

Greets to: Secfence Team and Garage 4 hackers
=================================================
};
use IO::Socket;
print "Target: ";
chop ($target = <stdin>);
print "Min Port: ";
chop ($port = <stdin>);
print "Max Port: ";
chop ($maxport = <stdin>);
my ( $daddr );

{

$daddr = inet_aton($target) || die("Failed to locate target host: $target");

print " ================================================== ==============\n";
print " Scanning $target on ports $port-$maxport\n";
print " This might take a while depending on how many ports you have\n";
print " ================================================== ==============\n";
foreach (; $port<=$maxport; $port++) {
print "\n == Scanning port $port ==";

if( IO::Socket::INET->new(PeerAddr=>"$target:$port",Proto=>'tcp',Timeout=>1))
{
print "\n==== Port $port is open ====\n" ;
}
else{
print "\nPort $port is NOT open\n";
}
}
}

print "\n\n\nFinished Scanning $target up to port $maxport\n\n";
print "\n Thanks for using my port scanner\n";

exit (0);

http://img163.imageshack.us/img163/1108/snapshot1l.jpg

D4rk357
11-14-2010, 12:49 PM
nice tool .. i would love if banner grabbing capability is added to it ;)

prashant_uniyal
11-14-2010, 01:05 PM
thanks bro..sure, will release a good info-gathering tool, once I complete the tutorials of this language

"vinnu"
11-15-2010, 09:20 AM
Nice tool.
Do only one correction,
Print the results in tabular format..."vinnu"

fb1h2s
11-15-2010, 01:43 PM
Its really cool tht every one has started to program cool great going buddies :D G4H rocks :D

41.w4r10r
11-15-2010, 03:23 PM
Nice going prashant. i will suggest instead of showing result for each port it will be good if only open ports are displayed.

also it exits after scanning complete so its very hard to get results. storing output in file will be good option for this.

b0nd
11-15-2010, 06:13 PM
Its really cool tht every one has started to program cool great going buddies :D G4H rocks :D

Thumbs-up!

prashant_uniyal
11-15-2010, 09:25 PM
Thanks a lot brothers for encouragements.. :) :) As I will move on with programming skills, I will try to code programs with more good features and bug free . Garage brothers are my inspirations ;) Hope the saga continues :)