Commit 939372eb authored by Håkon Harnes's avatar Håkon Harnes

added general info and mx-records

parent 9c530d96
#!/bin/sh
#!/bin/bash
# -- GENERAL INFO -- #
printf "\n[General Information]\n\n"
# gets ip-addresses
ADDRESSES=()
mapfile -t ADDRESSES < <( nslookup $1 | tail -n +5 | grep 'Address' | cut -d ' ' -f2 )
# gets host-names
NAMES=()
mapfile -t NAMES < <( nslookup $1 | tail -n +5 | grep 'Name' | cut -f2 )
# reverse lookup
for ((i=0; i<${#ADDRESSES[@]}; ++i))
do
REVERSE_ADR=$( nslookup ${ADDRESSES[i]} | grep 'name' | cut -f1)
REVERSE_NAM=$( nslookup ${ADDRESSES[i]} | grep 'name' | cut -d ' ' -f3)
if [ -z ${REVERSE_ADR} ]
then
REVERSE_ADR="-"
fi
printf "%-10s %s\n" "Name:" ${NAMES[i]} "Address:" ${ADDRESSES[i]} "Reverse:" ${REVERSE_ADR} " " ${REVERSE_NAM} " "
done
# -- MX-RECORDS -- #
printf "[MX-Records]\n"
# gets mx-records
MX_RECORDS=()
mapfile -t MX_RECORDS < <( nslookup -type=mx $1 | grep 'mail exchanger' | cut -d ' ' -f5 )
# lookup for each mx-record to get address
for i in "${MX_RECORDS[@]}"
do
printf "\n%-10s %s\n" "Name:" ${i}
MX_ADDRESSES=()
mapfile -t MX_ADDRESSES < <( nslookup $i | tail -n +5 | grep 'Address' | cut -d ' ' -f2 )
for j in "${MX_ADDRESSES[@]}"
do
printf "%-10s %s\n" "Address:" ${j}
done
done
# -- SPF LOOKUP -- #
printf "\n[SPF-Lookup]\n\n"
# MX-record lookup
echo "$(tput bold)MX-informasjon:$(tput sgr0)"
MX_RECORD=$(nslookup -type=mx $1 | grep 'mail exchanger' | cut -d " " -f5)
echo ${MX_RECORD}
# for i in ${MX_RECORD[@]}; do echo $i; done
bold=$(tput bold)
normal=$(tput sgr0)
#!/bin/bash
# program title
echo -e "$(tput bold)Email check for $1$(tput sgr0)\n"
ADDRESSES=()
mapfile -t ADDRESSES < <( nslookup $1 | tail -n +5 | grep 'Address' | cut -d " " -f2 )
NAMES=()
mapfile -t NAMES < <( nslookup $1 | tail -n +5 | grep 'Name' | cut -f2 )
for ((i=0;i<${#ADDRESSES[@]};++i))
do
printf "%-10s %s\n" "Name:" ${NAMES[i]} "Address:" ${ADDRESSES[i]}
done
# MX-record lookup
echo "MX-records:"
# reads MX-records into array
MX_RECORDS=()
mapfile -t MX_RECORDS < <( nslookup -type=mx $1 | grep 'mail exchanger' | cut -d " " -f 4-5 )
# loops through each MX-record and prints it
for i in "${MX_RECORDS[@]}"
do
echo "- $i"
done
ADDRESSES=()
mapfile -t ADDRESSES < <( nslookup $1 | tail -n +5 | grep 'Address' | cut -d " " -f2 )
NAMES=()
mapfile -t NAMES < <( nslookup $1 | tail -n +5 | grep 'Name' | cut -f2 )
for ((i=0;i<${#ADDRESSES[@]};++i))
do
printf "%-10s %s\n" "Name:" ${NAMES[i]} "Address:" ${ADDRESSES[i]}
done
echo "${bold}MX-informasjon$(tput bold)
<:${normal}"
nslookup -type=mx $1
echo ""
echo "hello"
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