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

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.

# TCP Port scanner

print q{

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" ;
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);


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

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

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

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

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.

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


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 :)