devzspy

nc top 20 udp port scanner

Feb 26th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.76 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. my @topPorts = (52, 67, 68, 69, 123, 135, 137, 138, 139, 161, 162, 445, 500, 514,520,631,1434,1900,4500,49152);
  6. my $nc = "/bin/nc";
  7. my $outFile;
  8. my $target;
  9.  
  10. if(@ARGV < 2) {
  11.     print("Usage: $0 <target> <output file> \n");
  12.     print("Example: perl $0 10.10.10.10 udp_scan.txt \n");
  13.         print("cat udp_scan.txt | grep -v \"?\" \n");
  14.     exit(1);
  15. }
  16.  
  17. ($target, $outFile) = @ARGV;
  18. print("Performing Top 20 UDP Port Scan against: $target \n");
  19. print("Output File: $outFile \n");
  20.  
  21. open(FILE, ">", $target) or die("$!");
  22. close(FILE);
  23. print("Running: ");
  24. foreach my $port (@topPorts) {
  25.     open(NETCAT, "-|", "$nc -nv -u -z -w 1 $target $port 2>>$outFile") or die("$!");
  26.     close(NETCAT);
  27.     print(".");
  28. }
  29. print(" DONE!\n");
Advertisement