Created
October 16, 2018 22:19
-
-
Save chrishol/1c6f6c40b0c376dcc5db62b8327f071a to your computer and use it in GitHub Desktop.
Find G Suite users for a given list of domains
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
# Step 1: Create list of domains in url-list.txt | |
# Step 2: Run dig to output a list of MX records | |
while read url; do | |
dig $url mx | grep MX | head -n 2 | tail -n 1 | |
done <url-list.txt > mx-results.txt | |
# Step 3: Grep to isolate and count the Google users | |
while read mxrecord; do | |
echo $mxrecord | grep -i google | |
done <mx-results.txt > google-users.txt | |
# Step 4 (optional): Grep to isolate the others | |
while read mxrecord; do | |
echo $mxrecord | grep -i -v google | |
done <mx-results.txt > other-users.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment