How to implement a port scanner using some scripting language?
Below is a port scanner in PERL:-
Below is a small perl script to achieve the same #!/usr/bin/perl use IO::Socket; $port = 1; $ip = "192.168"; // should be the IP address prefix of the IPs in your network or localhost $sub1 = 0; $sub2 = 0; $limit = 255; $output = "/home/L098867/Desktop/OpenPorts.txt"; // output to be redirected to this txt file open (LIST, " >>$output"); while($sub1 <= $limit){ while($sub2 <= $limit){ // scan ports from 0 until 65535 while ($port <= 65535){ $fip = $ip.".$sub1".".$sub2"; $sock = new IO::Socket::INET (PeerAddr => $fip, PeerPort => $port, Proto => 'tcp'); if ($sock){ close $sock; print "$fip : " + "$port -open\n"; print LIST "$fip : " + "$port -open\n"; } else{ print "$fip : " + "$port -closed\n"; } $port = $port + 1; print "$fip\n\n"; } $sub2 = $sub2 + 1; $port = 0; print "\n\n"; } $sub1 = $sub1 + 1; $port = 0; print "\n\n"; } close(LIST);
goli202084 Answered question