Last active
February 9, 2020 22:09
-
-
Save echel0nn/34c5a632b22224a54bef943b7c37fe05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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