-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpoofCheck.ps1
60 lines (52 loc) · 1.51 KB
/
SpoofCheck.ps1
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
param (
[string]$domain
)
if (-not $domain) {
Write-Host "Please provide a domain name using the -domain parameter."
exit
}
function CheckSPF {
param ($domain)
$txtRecords = (Resolve-DnsName -Name $domain -Type TXT -ErrorAction SilentlyContinue)
foreach ($record in $txtRecords) {
if ($record.Strings -match "^v=spf1") {
return $true
}
}
return $false
}
function CheckDKIM {
param ($domain)
$selector = "default"
$dkimDomain = "$selector._domainkey.$domain"
$txtRecords = (Resolve-DnsName -Name $dkimDomain -Type TXT -ErrorAction SilentlyContinue)
foreach ($record in $txtRecords) {
if ($record.Strings -match "^v=DKIM1") {
return $true
}
}
return $false
}
function CheckDMARC {
param ($domain)
$dmarcDomain = "_dmarc.$domain"
$txtRecords = (Resolve-DnsName -Name $dmarcDomain -Type TXT -ErrorAction SilentlyContinue)
foreach ($record in $txtRecords) {
if ($record.Strings -match "^v=DMARC1") {
return $true
}
}
return $false
}
$baseDomain = $domain
$spf = CheckSPF $baseDomain
$dkim = CheckDKIM $baseDomain
$dmarc = CheckDMARC $baseDomain
Write-Host "SPF record found for $baseDomain: $spf"
Write-Host "DKIM record found for $baseDomain: $dkim"
Write-Host "DMARC record found for $baseDomain: $dmarc"
if (-not $spf -or -not $dkim -or -not $dmarc) {
Write-Host "Spoofing is possible for this domain."
} else {
Write-Host "Spoofing is unlikely for this domain."
}