Skip to content

Commit 7e11752

Browse files
authored
Merge pull request #15 from JohnDuprey/dev
Dev to main
2 parents 152122c + 3c65520 commit 7e11752

File tree

6 files changed

+81
-25
lines changed

6 files changed

+81
-25
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Name": "Hornet Security",
3+
"MxMatch": "mx[0-9][0-9].hornetsecurity.com",
4+
"SpfInclude": "spf.hornetsecurity.com",
5+
"Selectors": [""],
6+
"_MxComment": "https://www.hornetsecurity.com/en/onboarding-information/",
7+
"_SpfComment": "https://www.hornetsecurity.com/en/onboarding-information/",
8+
"_DkimComment": "https://support.hornetsecurity.com/hc/en-us/articles/15123377800593-How-to-set-up-DKIM"
9+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"Name": "Microsoft 365",
3-
"MxMatch": "mail.protection.outlook.com",
4-
"SpfInclude": "spf.protection.outlook.com",
5-
"Selectors": ["selector1","selector2"],
6-
"MinimumSelectorPass": 1,
7-
"_MxComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
8-
"_SpfComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
9-
"_DkimComment": "https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/use-dkim-to-validate-outbound-email?view=o365-worldwide"
10-
}
2+
"Name": "Microsoft 365",
3+
"MxMatch": "mail.protection.outlook.com|mx.microsoft",
4+
"SpfInclude": "spf.protection.outlook.com",
5+
"Selectors": ["selector1", "selector2"],
6+
"MinimumSelectorPass": 1,
7+
"_MxComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
8+
"_SpfComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
9+
"_DkimComment": "https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/use-dkim-to-validate-outbound-email?view=o365-worldwide"
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Name": "Symantec Cloud",
3+
"MxMatch": "cluster[0-9].{3,4}.messagelabs.com",
4+
"SpfInclude": "spf.messagelabs.com",
5+
"Selectors": [""],
6+
"_MxComment": "https://knowledge.broadcom.com/external/article/161419/mail-exchanger-mx-record-setup-with-emai.html",
7+
"_SpfComment": "https://knowledge.broadcom.com/external/article/161394/implement-spf-records-for-email-security.html",
8+
"_DkimComment": "https://knowledge.broadcom.com/external/article/171225/configuring-dkim-signing-for-outbound-ma.html"
9+
}

DNSHealth/Public/Records/Read-WhoisRecord.ps1

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ function Read-WhoisRecord {
5050
$WhoisRegex = '^(?!(?:%|>>>|-+|#|[*]))[^\S\n]*(?<PropName>.+?):(?:[\r\n]+)?(:?(?!([0-9]|[/]{2}))[^\S\r\n]*(?<PropValue>.+))?$'
5151

5252
Write-Verbose "Querying WHOIS Server: $Server"
53-
# TCP Client for Whois
54-
$Client = New-Object System.Net.Sockets.TcpClient($Server, 43)
53+
5554
try {
55+
# TCP Client for Whois
56+
$Client = New-Object System.Net.Sockets.TcpClient($Server, 43)
57+
5658
# Open TCP connection and send query
5759
$Stream = $Client.GetStream()
5860
$ReferralServers = [System.Collections.Generic.List[string]]::new()
@@ -136,16 +138,18 @@ function Read-WhoisRecord {
136138
$Results = $LastResult
137139
}
138140
}
139-
}
140-
141-
else {
141+
} else {
142142
if ($Results._Raw -Match '(No match|Not Found|No Data)') {
143143
$first, $newquery = ($Query -split '\.')
144144
if (($newquery | Measure-Object).Count -gt 1) {
145145
$Query = $newquery -join '.'
146-
$Results = Read-WhoisRecord -Query $Query -Server $Server -Port $Port
147-
foreach ($s in $Results._ReferralServers) {
148-
$ReferralServers.Add($s) | Out-Null
146+
try {
147+
$Results = Read-WhoisRecord -Query $Query -Server $Server -Port $Port
148+
foreach ($s in $Results._ReferralServers) {
149+
$ReferralServers.Add($s) | Out-Null
150+
}
151+
} catch {
152+
$Results = $LastResult
149153
}
150154
}
151155
}
@@ -162,10 +166,10 @@ function Read-WhoisRecord {
162166
$Stream.Dispose()
163167
}
164168
}
165-
166-
# Collect referral server list
167-
$Results._ReferralServers = $ReferralServers
168-
169+
if ($ReferralServers) {
170+
# Collect referral server list
171+
$Results._ReferralServers = $ReferralServers
172+
}
169173
# Convert to json and back to preserve object order
170174
$WhoisResults = $Results | ConvertTo-Json | ConvertFrom-Json
171175

DNSHealth/Public/Resolver/Resolve-DnsHttpsQuery.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ function Resolve-DnsHttpsQuery {
5151
$Uri = $QueryTemplate -f $BaseUri, $Domain, $RecordType
5252

5353
$x = 0
54+
$Exception = $null
5455
do {
5556
$x++
5657
try {
5758
$Results = Invoke-RestMethod -Uri $Uri -Headers $Headers -ErrorAction Stop
58-
}
59-
60-
catch {
59+
} catch {
60+
$Exception = $_
6161
Start-Sleep -Milliseconds 300
6262
}
6363
}
6464
while (-not $Results -and $x -le 3)
65-
if (!$Results) { throw $_ }
65+
if (!$Results) { throw 'Exception querying resolver {0}: {1}' -f $Resolver.Resolver, $Exception.Exception.Message }
6666

6767
if ($RecordType -eq 'txt' -and $Results.Answer) {
6868
if ($Resolver -eq 'Cloudflare' -or $Resolver -eq 'Quad9') {

Tests/Test-Whois.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Param(
2+
$Count = 100
3+
)
4+
5+
$DomainList = (Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/opendns/public-domain-lists/master/opendns-top-domains.txt') -split "`n"
6+
$RandomDomains = $DomainList | Where-Object { $_ } | Get-Random -Count $Count
7+
8+
9+
$Jobs = $RandomDomains | ForEach-Object -Parallel {
10+
Import-Module '..\Output\DNSHealth\DNSHealth.psd1'
11+
$Start = Get-Date
12+
try {
13+
$Result = Read-WhoisRecord $_
14+
$Success = $true
15+
}
16+
17+
catch {
18+
$Result = $_.Exception
19+
$Success = $false
20+
}
21+
$End = Get-Date
22+
$TimeSpan = New-TimeSpan -Start $Start -End $End
23+
24+
[pscustomobject]@{
25+
Domain = $_
26+
Result = $Result
27+
Success = $Success
28+
TimeSpan = $TimeSpan
29+
}
30+
31+
} -ThrottleLimit 10 -AsJob
32+
33+
$Results = $Jobs | Wait-Job | Receive-Job
34+
$Results

0 commit comments

Comments
 (0)