Skip to content

Commit

Permalink
Create SpoofCheck.ps1
Browse files Browse the repository at this point in the history
Powershell version of SpoofCheck
  • Loading branch information
DcodeZero authored Jul 14, 2024
1 parent f97a714 commit de586d9
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions SpoofCheck.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,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."
}

0 comments on commit de586d9

Please sign in to comment.