-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmarc_checker.sh
executable file
·64 lines (52 loc) · 1.47 KB
/
dmarc_checker.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
#!/bin/bash
show_help() {
echo "Usage: $0 -f <domains_file>"
echo " -f Specifies the file containing the list of domains"
exit 1
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
if ! command_exists nslookup; then
echo -e "${red_color}Error: nslookup command not found. Please install dnsutils (Debian, Ubuntu).${reset_color}"
exit 1
fi
red_color='\033[0;31m'
green_color='\033[0;32m'
reset_color='\033[0m'
if [ $# -eq 0 ]; then
show_help
fi
while getopts "f:h" option; do
case $option in
f)
domains_file="$OPTARG"
;;
h)
show_help
;;
\?)
echo "Invalid option: -$OPTARG"
show_help
;;
esac
done
if [ -z "$domains_file" ]; then
echo -e "${red_color}Error: You need to provide the domains file.${reset_color}"
show_help
fi
if [ ! -f "$domains_file" ]; then
echo -e "${red_color}The file $domains_file does not exist.${reset_color}"
exit 1
fi
while IFS= read -r domain; do
result=$(nslookup -type=txt "_dmarc.$domain" 2>&1)
if echo "$result" | grep -q "server can't find _dmarc."; then
echo -e "${red_color}vulnerable [no DMARC record]${reset_color}: $domain"
elif echo "$result" | grep -q "v=DMARC1;.*p=none"; then
echo -e "${red_color}vulnerable [p=none]${reset_color}: $domain"
else
echo -e "${green_color}not vulnerable${reset_color}: $domain"
fi
done < "$domains_file"
echo -e ""