#!/bin/bash
#
#                    nschecker.sh  NS Security Scanner 
#                   By axess ( axess@mail.com ) Feb-2000
#                   Buffer0verflow Security www.b0f.com
# 
#             This is an iplist Nameserver version scanner.
#         Just load it up with an iplist and choose an out file.
#               
#                       ./nschecker.sh in out 
#  
#       Right now it logs all versions and just put it in outfile.
#
#    This is just for EDUCATIONAL PURPOSES to check so your network 
#               dont run vulnerable versions of named :P
#
#
#
#
#
clear

echo
echo "    Nameserver Version Scanner "
echo "    By axess ( axess@mail.com )"
echo  Buffer0verflow Security www.b0f.com
echo

IN=$1
OUT=$2

if [ $# != 2 ] 
then
  echo " $0 <iplist> <outfile>"
  echo
  exit 0
fi

echo "   [+] Checking dependencies:"
sleep 1

if [ -f /usr/bin/dig ]
then 
  echo "      [*] Found dig"
  sleep 1
else
  echo "     [-] Didn't found dig"
  echo 
  sleep 1
  exit 1
fi

if [ -f $IN ]
then
  echo "      [*] Found the iplist file"
  sleep 1
else
  echo "    [-] Didn't found iplist file"
  echo
  sleep 1
  exit 1
fi

if [ -r $IN ]
then
echo "        [*] Its readable"
sleep 1
else
echo "      [-] its not readable"
sleep 1
exit 1
fi

> $OUT
if [ -w $OUT ]
then
echo "      [*] Outfile is writable"
sleep 1
else
echo "      [-] Outfile is not writable"
sleep 1
exit 0
fi

echo "   [+] Starting Scanning"

echo                                          >> $OUT
echo "This File was Created by nschecker.sh"  >> $OUT
echo "By axess ( axess@mail.com ) Feb -2000"  >> $OUT
echo "--------------------------------------" >> $OUT

echo -n "   [+] Tick."
ILE=0
while [ $ILE -lt 15 ]; do
  let ILE=ILE+1
  echo -n '.'
done

echo
for LIST in `cat $IN`
do
  echo "Checking Server : $LIST" >> $OUT
  dig @$LIST version.bind chaos txt | grep VERSION.BIND | cut -f4 >> $OUT
done



echo "   [+] Scan Finished"
echo "   [+] Check $OUT out for results of the scan"
echo
exit 0
