Commit bf1cf546 authored by Håkon Harnes's avatar Håkon Harnes

bug fix for multiple reverse lookup addresses

parent cddc5dc2
#!/bin/bash
# -- A RECORDS -- #
printf "$(tput bold)\n[A-records]\n\n$(tput sgr0)"
printf "$(tput bold)\n[A-records]\n$(tput sgr0)"
# gets host names and ip-adresses
NAMES=( $(nslookup $1 | tail -n +5 | grep 'Name' | cut -f2) )
......@@ -10,16 +10,20 @@ ADDRESSES=( $(nslookup $1 | tail -n +5 | grep 'Address' | cut -d ' ' -f2) )
# performs reverse lookup
for ((i=0; i<${#ADDRESSES[@]}; ++i))
do
REVERSE_NAME=$( nslookup ${ADDRESSES[i]} | grep 'name' | cut -d ' ' -f3)
REVERSE_ADRS=$( nslookup ${ADDRESSES[i]} | grep 'name' | cut -f1)
printf "%-11s %s\n" $'\nName:' ${NAMES[i]}
printf "%-10s %s\n" 'Address:' ${ADDRESSES[i]}
if [ -z $REVERSE_NAME ];then REVERSE_NAME="-";fi
REVERSE_NAME=( $(nslookup ${ADDRESSES[i]} | grep 'name' | cut -d ' ' -f3 | cut -d$'\n' -f1-) )
REVERSE_ADRS=( $(nslookup ${ADDRESSES[i]} | grep 'name' | cut -f1) )
printf "%-10s %s\n" "Name:" ${NAMES[i]} "Address:" ${ADDRESSES[i]} "Reverse:" $REVERSE_NAME " " $REVERSE_ADRS " "
for ((j=0; j<${#REVERSE_ADRS[@]}; ++j))
do
printf "%-10s %s\n" "Reverse:" ${REVERSE_NAME[j]} " " ${REVERSE_ADRS[j]}
done
done
# -- MX RECORDS -- #
printf "$(tput bold)[MX-records]\n$(tput sgr0)"
printf "$(tput bold)\n[MX-records]\n$(tput sgr0)"
# gets mx-records
MX_RECORDS=( $(nslookup -type=mx $1 | grep 'mail exchanger' | cut -d ' ' -f5) )
......@@ -44,6 +48,8 @@ printf "$(tput bold)\n[SPF]\n\n$(tput sgr0)"
A_INCLUDED=false
MX_INCLUDED=false
ALL=""
# list of IPv4 and IPv6 addresses
IPv4=()
IPv6=()
......@@ -64,6 +70,9 @@ function spf_lookup {
VALUE=${i#*=}
fi
# checks if type is all (-all or ~all)
if [[ $TYPE == *"all"* ]]; then ALL=$TYPE; fi
case $TYPE in
mx)
MX_INCLUDED=true
......@@ -108,4 +117,4 @@ do
printf " %s\n" $i
done
printf "\n"
printf "\n%s\n\n" $ALL
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment