Skip to content

Instantly share code, notes, and snippets.

@sasasin
Last active January 11, 2024 04:05
Show Gist options
  • Save sasasin/cf961bb5208e33c392d68da79eb97407 to your computer and use it in GitHub Desktop.
Save sasasin/cf961bb5208e33c392d68da79eb97407 to your computer and use it in GitHub Desktop.
指定したドメインの DMARC のポリシーだけ取ってくるやつ
#!/bin/bash
## how to use;
## get 1 domein;
# $ get_dmarc_policy.sh sasasin.net
# "_dmarc.sasasin.net.","reject"
## bulk get;
# $ cat domain_list.txt | xargs -L1 get_dmarc_policy.sh
# "_dmarc.example.com."
# "_dmarc.example.net.","none"
# "_dmarc.example.org.","reject"
# "_dmarc.example.jp.","quarantine"
DOMAIN_NAME="_dmarc.$1"
# requre; https://github.com/ogham/dog
timeout 2s dog --json "${DOMAIN_NAME}" TXT @1.1.1.1 \
| jq -r '.responses[].answers[].message
|= (
gsub(" "; "")
| split(";")
| map(select(length > 0))
| map(split("=")
| {key: .[0], value: .[1]})
| from_entries
)' \
| jq -r '.responses[]
| [.queries[].name, .answers[].message.p, .answers[].message.sp]
| @csv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment