Loading digx.sh +98 −52 Original line number Diff line number Diff line Loading @@ -3,50 +3,80 @@ ## Author: Dimitri Enns function digx(){ ## Author: Dimitri Enns red="\e[31;1m" green="\e[32;1m" empt="\e[0m" yel="\e[33;1m" bld="\033[1m" local ARES local AAAARES local REV local MXS local MX local IMX local RP local NSX local NS if [[ ! -z ${1} ]]; then if [[ $(echo ${1} | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") == ${1} ]]; then local REV=$(dig -x ${1} +short) if [[ $(echo ${1} | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") == "${1}" ]]; then REV=$(dig -x "${1}" +short) echo -e "${yel}PTR:${empt} $([[ ! -z ${REV} ]] && echo "${REV}" || echo "No PTR")" return 0 fi local DO=$1 local ARES=$(dig A ${DO} +short | xargs) local AAAARES=$(dig AAAA ${DO} +short | xargs) if [[ ! -z ${ARES} ]]; then DO="$(echo "${1}" | idn2)" if [[ $(echo ${DO} | grep -P '((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}' ) != "${DO}" ]]; then echo -e "Sorry, but your input: ${red}${DO}${empt} does not seem to be a domain name." return 0 fi if [[ ${DO} =~ ^www ]]; then DO=$(echo "${DO}" | sed 's/www.//g') fi echo -e " === ${bld}${green}${DO}${empt} === " ## A Records ARES=$(dig A "${DO}" +short | xargs) if [[ ! -z ${ARES} ]]; then for i in ${ARES}; do REV=$(dig -x "${i}" +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi ARES="" ## Variable reset ## AAAA Records AAAARES=$(dig AAAA ${DO} +short | xargs) if [[ ! -z ${AAAARES} ]]; then for i in ${AAAARES}; do local REV=$(dig -x ${i} +short) REV=$(dig -x "${i}" +short) echo -e " ${yel}IPv6:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi for i in ${ARES}; do local REV=$(dig -x ${i} +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo "No PTR")" done AAAARES="" ## Variable reset local MXS=$(dig MX ${DO} +short | wc -l) local MX=$(dig MX ${DO} +short | awk '{print$2}' | xargs) ## MX Records MXS=$(dig MX "${DO}" +short | wc -l) MX=$(dig MX "${DO}" +short | awk '{print$2}' | xargs) if [[ ! -z ${MX} ]]; then if [[ ${MXS} -ge 2 ]]; then echo -e " ---" fi for i in ${MX}; do echo -e " ${yel}MX:${empt} ${i}" local IMX=$(dig A ${i} +short| xargs) IMX=$(dig A ${i} +short| xargs) for p in ${IMX}; do local rp="$(dig -x ${p} +short)" echo -e " ${yel}IP:${empt} ${p}\n ${yel}PTR:${empt} $([[ ! -z ${rp} ]] && echo "${rp}" || echo "No PTR")" RP="$(dig -x ${p} +short)" echo -e " ${yel}IP:${empt} ${p}\n ${yel}PTR:${empt} $([[ ! -z ${RP} ]] && echo "${RP}" || echo "No PTR")" done done fi ## TXT Records if [[ $(dig TXT ${DO} +short | wc -l) -ge 1 ]]; then echo -e " ---" echo -e "$(dig TXT ${DO} +short)" | while IFS= read -r line; do Loading @@ -56,23 +86,39 @@ function digx(){ done fi local NSX=$(dig NS ${DO} +short | wc -l) local NS=$(dig NS ${DO} +short | xargs) ## NS Records NSX=$(dig NS "${DO}" +short | wc -l) NS=$(dig NS "${DO}" +short | xargs) if [[ ${NSX} -ge 2 ]]; then echo -e " ---" fi for i in ${NS}; do echo -e "${yel} NS:${empt} ${i}" done echo -e "\n" ## Check www Variant .. echo -e " === ${bld}${green}www.${DO}${empt} === " ## A Records ARES=$(dig A "www.${DO}" +short | grep -v "${DO}" | xargs) if [[ ! -z ${ARES} ]]; then for i in ${ARES}; do REV=$(dig -x ${i} +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi else echo -e "NO Record found for Domain: ${red}${DO}${empt}" echo -e "$(whois ${DO})" ## AAAA Records AAAARES=$(dig AAAA "www.${DO}" +short | grep -v "${DO}" | xargs) if [[ ! -z ${AAAARES} ]]; then for i in ${AAAARES}; do REV=$(dig -x ${i} +short) echo -e " ${yel}IPv6:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi echo -e "\n" else echo "No args no results. Provide domain as first arg!"; return 1 echo "No args, no results. Provide domain /IP as first arg!"; return 1 fi } Loading Loading
digx.sh +98 −52 Original line number Diff line number Diff line Loading @@ -3,50 +3,80 @@ ## Author: Dimitri Enns function digx(){ ## Author: Dimitri Enns red="\e[31;1m" green="\e[32;1m" empt="\e[0m" yel="\e[33;1m" bld="\033[1m" local ARES local AAAARES local REV local MXS local MX local IMX local RP local NSX local NS if [[ ! -z ${1} ]]; then if [[ $(echo ${1} | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") == ${1} ]]; then local REV=$(dig -x ${1} +short) if [[ $(echo ${1} | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") == "${1}" ]]; then REV=$(dig -x "${1}" +short) echo -e "${yel}PTR:${empt} $([[ ! -z ${REV} ]] && echo "${REV}" || echo "No PTR")" return 0 fi local DO=$1 local ARES=$(dig A ${DO} +short | xargs) local AAAARES=$(dig AAAA ${DO} +short | xargs) if [[ ! -z ${ARES} ]]; then DO="$(echo "${1}" | idn2)" if [[ $(echo ${DO} | grep -P '((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}' ) != "${DO}" ]]; then echo -e "Sorry, but your input: ${red}${DO}${empt} does not seem to be a domain name." return 0 fi if [[ ${DO} =~ ^www ]]; then DO=$(echo "${DO}" | sed 's/www.//g') fi echo -e " === ${bld}${green}${DO}${empt} === " ## A Records ARES=$(dig A "${DO}" +short | xargs) if [[ ! -z ${ARES} ]]; then for i in ${ARES}; do REV=$(dig -x "${i}" +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi ARES="" ## Variable reset ## AAAA Records AAAARES=$(dig AAAA ${DO} +short | xargs) if [[ ! -z ${AAAARES} ]]; then for i in ${AAAARES}; do local REV=$(dig -x ${i} +short) REV=$(dig -x "${i}" +short) echo -e " ${yel}IPv6:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi for i in ${ARES}; do local REV=$(dig -x ${i} +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo "No PTR")" done AAAARES="" ## Variable reset local MXS=$(dig MX ${DO} +short | wc -l) local MX=$(dig MX ${DO} +short | awk '{print$2}' | xargs) ## MX Records MXS=$(dig MX "${DO}" +short | wc -l) MX=$(dig MX "${DO}" +short | awk '{print$2}' | xargs) if [[ ! -z ${MX} ]]; then if [[ ${MXS} -ge 2 ]]; then echo -e " ---" fi for i in ${MX}; do echo -e " ${yel}MX:${empt} ${i}" local IMX=$(dig A ${i} +short| xargs) IMX=$(dig A ${i} +short| xargs) for p in ${IMX}; do local rp="$(dig -x ${p} +short)" echo -e " ${yel}IP:${empt} ${p}\n ${yel}PTR:${empt} $([[ ! -z ${rp} ]] && echo "${rp}" || echo "No PTR")" RP="$(dig -x ${p} +short)" echo -e " ${yel}IP:${empt} ${p}\n ${yel}PTR:${empt} $([[ ! -z ${RP} ]] && echo "${RP}" || echo "No PTR")" done done fi ## TXT Records if [[ $(dig TXT ${DO} +short | wc -l) -ge 1 ]]; then echo -e " ---" echo -e "$(dig TXT ${DO} +short)" | while IFS= read -r line; do Loading @@ -56,23 +86,39 @@ function digx(){ done fi local NSX=$(dig NS ${DO} +short | wc -l) local NS=$(dig NS ${DO} +short | xargs) ## NS Records NSX=$(dig NS "${DO}" +short | wc -l) NS=$(dig NS "${DO}" +short | xargs) if [[ ${NSX} -ge 2 ]]; then echo -e " ---" fi for i in ${NS}; do echo -e "${yel} NS:${empt} ${i}" done echo -e "\n" ## Check www Variant .. echo -e " === ${bld}${green}www.${DO}${empt} === " ## A Records ARES=$(dig A "www.${DO}" +short | grep -v "${DO}" | xargs) if [[ ! -z ${ARES} ]]; then for i in ${ARES}; do REV=$(dig -x ${i} +short) echo -e " ${yel}IPv4:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi else echo -e "NO Record found for Domain: ${red}${DO}${empt}" echo -e "$(whois ${DO})" ## AAAA Records AAAARES=$(dig AAAA "www.${DO}" +short | grep -v "${DO}" | xargs) if [[ ! -z ${AAAARES} ]]; then for i in ${AAAARES}; do REV=$(dig -x ${i} +short) echo -e " ${yel}IPv6:${empt} ${i}\n$([[ ! -z ${REV} ]] && for n in ${REV}; do echo " ${yel}PTR:${empt} ${n}"; done || echo " No PTR")" done fi echo -e "\n" else echo "No args no results. Provide domain as first arg!"; return 1 echo "No args, no results. Provide domain /IP as first arg!"; return 1 fi } Loading