Last active
August 25, 2016 07:31
-
-
Save jandahl/68f6e33c0bac1e980ca91797d58533c0 to your computer and use it in GitHub Desktop.
Use zone transfer to search for subdomains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function aboutMe() { | |
echo -e "\n\t${scriptName}, v ${scriptVersion}" | |
echo -e "\n\tLooks through the ${lookupDomain} domain for what you want" | |
echo -e "\n\tTreats spaces as '.*'" | |
echo -e "\n\tExamples:" | |
echo -e "\n\t${scriptFile}${Emphasize} rt vrdb${ColorOff} will match rt01.vrdb" | |
echo -e "\t${scriptFile}${Emphasize} wireshark${ColorOff}\n" | |
# echo -e "(behind the scenes, it's a fancy ${Emphasize} dig -t AXFR tekdom.local | grep${ColorOff})\n" | |
} | |
function colorInit() { | |
ColorOff=$'\e[0m' # Text Reset | |
BWhite=$'\e[1;37m' # Bold White | |
BRed=$'\e[1;31m' # Bold Red | |
LGray=$'\e[0;37m' # Light Gray | |
if [ -z "$Diminish" ]; then | |
Diminish=${LGray}; | |
fi | |
if [ -z "$Emphasize" ]; then | |
Emphasize=${BRed}; | |
fi | |
} | |
scriptFile=$(basename "${0}") | |
scriptName="DNS-looker-upper" | |
scriptVersion="2016-08-25 JAGR" | |
lookupDomain="tekdom.local." | |
undilutedSearch="$*" | |
searchTerms=${undilutedSearch/ /.*} | |
colorInit | |
if [ "$#" -lt 1 ]; then | |
aboutMe; | |
exit | |
fi | |
dig -t AXFR ${lookupDomain} |\ | |
sort |\ | |
awk '{ print $5 "\t" $1 }' |\ | |
tr '[:upper:]' '[:lower:]' |\ | |
grep -i "${searchTerms}" |\ | |
sed "s/\(${lookupDomain}\)/${Diminish}\1${ColorOff}/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment