-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmarccheck.sh
71 lines (60 loc) · 1.08 KB
/
dmarccheck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
usage()
{
echo "Pour vérifier le Dmarc d'un domaine ou un ensemble de domaine regroupé dans un fichier"
echo ""
echo "$0"
echo " -h ou --help pour afficher ce message"
echo " -d ou --domain domain.bj"
echo " -f ou --file /chemin/du/fichier"
echo ""
}
checkd() {
dig _dmarc.$1 +short TXT
}
printhead(){
echo
printf '\e[1;34m%-30s\e[m \e[1;32m%-30s\e[m' "Domain" "Dmarc"
echo
}
printDmarc(){
SPF=`checkd $1 | grep "v="`
# echo "$1\t\t\t\t$SPF"
printf "%-30s %-60s\n" "$1" "$SPF"
}
printFileDmarc(){
while IFS= read -r line
do
printDmarc $line
done < "$1"
}
if [ "$1" = "" ]
then
usage
exit
else
#while [ "$1" != "" ]; do
# echo "1 est $1 et 2 est $2"
# exit
printhead
case $1 in
-h | --help)
usage
exit
;;
-f | --file)
printFileDmarc $2
;;
-d | --domain)
printDmarc $2
exit 0
;;
*)
echo "Option \"$PARAM\" inconnu"
usage
exit 1
;;
esac
shift
fi
#done