Advertisement
Guest User

NTP Scanner - BitchGotRaped Release

a guest
Feb 9th, 2014
6,559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use Net::IP;
  4. use IO::Socket;
  5. use Term::ANSIColor;
  6. use vars qw( $PROG );
  7. ( $PROG = $0 ) =~ s/^.*[\/\\]//;
  8. #Usage
  9. if ( @ARGV == 0 ) {
  10. print "Usage: ./$PROG [START-IP] [END-IP] [PORT] [THREADS] [TIMEOUT] [OUTPUT]\n";
  11. exit;
  12. }
  13. my $threads = $ARGV[3];
  14. my @ip_team = ();
  15. $|= 1;
  16. my $ip = new Net::IP ("$ARGV[0] - $ARGV[1]") or die "Invaild IP Range.". Net::IP::Error() ."\n";
  17.  
  18.  
  19. #Start Forking :D
  20. while ($ip) {
  21. push @ip_team, $ip++ ->ip();
  22. if ( $threads == @ip_team ) { Scan(@ip_team); @ip_team = () }
  23. }
  24. Scan(@ip_team);
  25.  
  26. #Scan
  27. sub Scan
  28. {
  29. my @Pids;
  30.  
  31. foreach my $ip (@_)
  32. {
  33. my $pid = fork();
  34. die "Could not fork! $!\n" unless defined $pid;
  35.  
  36. if (0 == $pid)
  37. {
  38. alarm 1;
  39. #Open socket, save to list, print out open ports
  40. my $socket = IO::Socket::INET->new(PeerAddr => $ip , PeerPort => $ARGV[2] , Proto => 'udp' , Timeout => $ARGV[4]);
  41.  
  42.  
  43. my $payload = "\x97\x00\x00\x00\xAA\x00\x00\x00";
  44. my $good = "\x97\x00\x00\x00";
  45.  
  46. $socket->send($payload) or die "Nothing got sent.";
  47.  
  48. my $data;
  49. $socket->recv($data,4);
  50. my $response = substr($data,0,8);
  51. $response = reverse($response);
  52. open (MYFILE, ">>$ARGV[5]");
  53. if ($response == $good) {
  54. print MYFILE "$ip\n" if $socket;
  55. print "Found $ip\n";
  56. close (MYFILE);}
  57. exit
  58. }
  59. else
  60. {
  61. push @Pids, $pid
  62. }
  63. }
  64.  
  65. foreach my $pid (@Pids) { waitpid($pid, 0) }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement