Advertisement
paperline27

perl :: port scan tool

Jan 18th, 2024
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.63 KB | Cybersecurity | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use IO::Socket;
  5.  
  6. my $host = $ARGV[0];
  7. my $start_port = $ARGV[1];
  8. my $end_port = $ARGV[2];
  9.  
  10. for my $port ($start_port..$end_port) {
  11.     my $socket = IO::Socket::INET->new(
  12.         Proto    => "tcp",
  13.         PeerAddr => $host,
  14.         PeerPort => $port,
  15.         Timeout  => 1,
  16.     );
  17.  
  18.     if ($socket) {
  19.         print "  ⭕ Port $port is open ⭕\n";
  20.         close($socket);
  21.     }else{
  22.         print " ❌ Port $port is closed ❌\n";
  23.     }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. =begin comment
  30. apt update -y
  31. apt upgrade -y
  32. apt install perl -y
  33. cpan IO::Socket
  34. perl door-hinge.pl google.com 1 25565
  35. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement