Created
August 2, 2023 23:06
-
-
Save rhee-elten/365024539b6dd576a919a9abc34212df to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
set -e; set -u | |
COMMON_SUBDOMAINS="www mail mx a.mx smtp pop imap blog en ftp ssh login" | |
EXTENDED="" | |
while :; do case "$1" in | |
--) shift; break ;; | |
-x) EXTENDED=y; shift ;; | |
-s) NS="$2"; shift 2 ;; | |
*) break ;; | |
esac; done | |
DOM="$1"; shift | |
TYPE="${1:-any}" | |
test "${NS:-}" || NS=$(dig +short SOA "$DOM" | awk '{print $1}') | |
test "$NS" && NS="@$NS" | |
if test "$EXTENDED"; then | |
dig +nocmd $NS "$DOM" +noall +answer "$TYPE" | |
wild_ips=$(dig +short "$NS" "*.$DOM" "$TYPE" | tr '\n' '|') | |
wild_ips="${wild_ips%|}" | |
for sub in $COMMON_SUBDOMAINS; do | |
dig +nocmd $NS "$sub.$DOM" +noall +answer "$TYPE" | |
done | cat #grep -vE "${wild_ips}" | |
dig +nocmd $NS "*.$DOM" +noall +answer "$TYPE" | |
else | |
dig +nocmd $NS "$DOM" +noall +answer "$TYPE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment