Re: Re: ntpscan.pl NTP server scanner
#!/usr/bin/perl
use strict;
use Net::IP;
use IO::Socket;
use Term::ANSIColor;
( $PROG = $0 ) =~ s/^.*[\/\\]//;
#Usage
if ( @ARGV == 0 ) {
print "Usage: ./$PROG [START-IP] [END-IP] [PORT] [THREADS] [TIMEOUT] [OUTPUT]\n";
}
my $threads = $ARGV[3];
my @ip_team = ();
$|= 1;
my $ip = new Net
::IP ("$ARGV[0] - $ARGV[1]") or die "Invaild IP Range.". Net
::IP::Error() ."\n";
#Start Forking :D
while ($ip) {
push @ip_team, $ip++ ->ip();
if ( $threads == @ip_team ) { Scan(@ip_team); @ip_team = () }
}
Scan(@ip_team);
#Scan
sub Scan
{
my @Pids;
foreach my $ip (@_)
{
if (0 == $pid)
{
#Open socket, save to list, print out open ports
my $socket = IO::Socket::INET->new(PeerAddr => $ip , PeerPort => $ARGV[2] , Proto => 'udp' , Timeout => $ARGV[4]);
my $payload = "\x97\x00\x00\x00\xAA\x00\x00\x00";
my $good = "\x97\x00\x00\x00";
$socket->send($payload) or die "Nothing got sent.";
my $data;
my $response = substr($data,0,8);
open (MYFILE
, ">>$ARGV[5]");
if ($response == $good) {
print MYFILE
"$ip\n" if $socket;
}
else
{
}
}
foreach my $pid (@Pids) { waitpid($pid, 0) }
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"text\/x-go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"mysql","xml":"xml","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","ecmascript":"javascript","groovy":"text\/x-groovy","haskell":"text\/x-haskell","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mysql":"mysql","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"plsql","properties":"text\/x-properties","scheme":"text\/x-scheme","vb":"text\/vbscript","vbnet":"text\/vbscript","verilog":"text\/x-verilog","yaml":"text\/x-yaml"}