Skip to content

Instantly share code, notes, and snippets.

@echel0nn
Last active February 9, 2020 22:09
Show Gist options
  • Save echel0nn/34c5a632b22224a54bef943b7c37fe05 to your computer and use it in GitHub Desktop.
Save echel0nn/34c5a632b22224a54bef943b7c37fe05 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use IO::Socket;
$| = 1;
$target = "172.18.0.2";
$start_port = "1";
$end_port = "10000";
foreach ($port = $start_port ; $port <= $end_port ; $port++)
{
#\r will refresh the line
print "\rScanning port $port";
#Connect to port number
$socket = IO::Socket::INET->new(PeerAddr => $target , PeerPort => $port , Proto => 'tcp' , Timeout => 1);
#Check connection
if( $socket )
{
print "\r = Port $port is open.\n" ;
}
else
{
#Port is closed, nothing to print
}
}
print "\n\nFinished Scanning $target\n";
exit (0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment