Skip to content

Commit

Permalink
Update run.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdwegen authored Aug 9, 2023
1 parent e55f75f commit ae53023
Showing 1 changed file with 36 additions and 41 deletions.
77 changes: 36 additions & 41 deletions domainDiscovery/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,69 +26,64 @@ $header = @{
}

try {
# Process data
$results = $domain | ForEach-Object {
try {
$tenantDetails = Invoke-RestMethod -Method GET -Uri "https://api.vdwegen.app/api/tenantDetails?tenant=$($_)"
} catch {
$tenantDetails = $null
}
try {
$tenantDetails = Invoke-RestMethod -Method GET -Uri "https://api.vdwegen.app/api/tenantDetails?tenant=$($domain)"
} catch {
$tenantDetails = $null
}

try {
$mailProvider = ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=$($_)&type=mx").Answer.data | ForEach-Object { $Priority, $Hostname = $_.Split(' '); @{ prio = $Priority; Host = $hostname } }).Host
$MailproviderData = switch -Wildcard ($mailProvider) {
"*.mail.protection.outlook.com." { "Microsoft 365" }
"*.google.com." { "Google" }
"*.sophos.com." { "Sophos" }
"*.googlemail.com." { "Google" }
"*.transip.email." { "TransIP" }
"*.premiumantispam.nl." { "TransIP" }
"*.basenet.nl." { "BaseNet" }
"*.ppe-hosted.com." { "ProofPoint" }
"*.pphosted.com." { "ProofPoint" }
"*.onlinespamfilter.com." { "Onlinespamfilter.nl" }
"*.onlinespamfilter.nl." { "Onlinespamfilter.nl" }
"*.fortimailcloud.com." { "FortiMail" }
"*.mailprotect.be." { "Combell" }
"*.mtaroutes.com." { "Mail Assure (N-Able)" }
"*.spamexperts.net." { "N-Able SpamExperts" }
"*.spamexperts.com." { "N-Able SpamExperts" }
"*.antispamcloud.com." { "N-Able SpamExperts" }
"*.spamexperts.eu." { "N-Able SpamExperts" }
"*.messagelabs.com." { "Symantec Messaging Security" }
Default { $_ }
}
} catch {
Write-Warning "Failed to get mailprovider"
try {
$mailProvider = ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=$($domain)&type=mx").Answer.data | ForEach-Object { $Priority, $Hostname = $_.Split(' '); @{ prio = $Priority; Host = $hostname } }).Host
$MailproviderData = switch -Wildcard ($mailProvider) {
"*.mail.protection.outlook.com." { "Microsoft 365" }
"*.google.com." { "Google" }
"*.sophos.com." { "Sophos" }
"*.googlemail.com." { "Google" }
"*.transip.email." { "TransIP" }
"*.premiumantispam.nl." { "TransIP" }
"*.basenet.nl." { "BaseNet" }
"*.ppe-hosted.com." { "ProofPoint" }
"*.pphosted.com." { "ProofPoint" }
"*.onlinespamfilter.com." { "Onlinespamfilter.nl" }
"*.onlinespamfilter.nl." { "Onlinespamfilter.nl" }
"*.fortimailcloud.com." { "FortiMail" }
"*.mailprotect.be." { "Combell" }
"*.mtaroutes.com." { "Mail Assure (N-Able)" }
"*.spamexperts.net." { "N-Able SpamExperts" }
"*.spamexperts.com." { "N-Able SpamExperts" }
"*.antispamcloud.com." { "N-Able SpamExperts" }
"*.spamexperts.eu." { "N-Able SpamExperts" }
"*.messagelabs.com." { "Symantec Messaging Security" }
Default { $_ }
}
} catch {
Write-Warning "Failed to get mailprovider"
}

try {
$exchangeOnline = if ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=autodiscover.$($_)&type=cname").Answer.data -eq "autodiscover.outlook.com.") { $true } else { $false }
$intune = if ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=enterpriseregistration.$($_)&type=cname").Answer.data -eq "enterpriseregistration.windows.net.") { $true } else { $false }
$exchangeOnline = if ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=autodiscover.$($domain)&type=cname").Answer.data -eq "autodiscover.outlook.com.") { $true } else { $false }
$intune = if ((Invoke-RestMethod -Method GET -Uri "https://dns.google/resolve?name=enterpriseregistration.$($domain)&type=cname").Answer.data -eq "enterpriseregistration.windows.net.") { $true } else { $false }
} catch {
Write-Warning "Failed to get exo or intune"
}

try {
$kitterman = Invoke-RestMethod -Method POST -Uri 'https://www.kitterman.com/spf/getspf3.py' -Body @{ "serial" = "fred12" ; "domain" = $_ } -ContentType "application/x-www-form-urlencoded"
$kitterman = Invoke-RestMethod -Method POST -Uri 'https://www.kitterman.com/spf/getspf3.py' -Body @{ "serial" = "fred12" ; "domain" = $domain } -ContentType "application/x-www-form-urlencoded"
} catch {
Write-Warning "Failed to get kitterman"
}

[pscustomobject]@{
domain = $_
domain = $domain
tenantDisplayName = if ($tenantDetails) {$tenantDetails.displayName} else { "N/A" }
tenantId = if ($tenantDetails) {$tenantDetails.tenantId} else { "N/A" }
MailProvider = ($mailProviderData | Select-Object -Unique) -join "|"
spfKitterman = if (($kitterman | select-string "SPF record passed validation test" | Select-Object -First 1)) { "PASS" } else { "FAIL" }
exchangeOnline = $exchangeOnline
intune = $intune
spfKittermanResults = "https://www.kitterman.com/spf/getspf3.py?serial=fred12&domain=$($_)"
spfKittermanResults = "https://www.kitterman.com/spf/getspf3.py?serial=fred12&domain=$($domain)"
tenantDomains = if ($tenantDetails) {$tenantDetails.tenantDomains -join "|"} else { "N/A" }
}

Write-Host "$($_) has been processed"
}
}
catch {
$ErrorMessage = $_.Exception.Message
Expand Down

0 comments on commit ae53023

Please sign in to comment.