From 07d78ef5f254527537cf8b90a5090ce7cfa5fdcc Mon Sep 17 00:00:00 2001 From: Rob Noeth Date: Fri, 12 Apr 2024 17:25:31 -0500 Subject: [PATCH] use FQDN and new file download test to verify huntress domains --- Powershell/InstallHuntress.powershellv2.ps1 | 30 ++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Powershell/InstallHuntress.powershellv2.ps1 b/Powershell/InstallHuntress.powershellv2.ps1 index 7e4497e..12f0047 100644 --- a/Powershell/InstallHuntress.powershellv2.ps1 +++ b/Powershell/InstallHuntress.powershellv2.ps1 @@ -757,16 +757,34 @@ function testNetworkConnectivity { # number of URL's that can fail the connectivity before the agent refuses to install (the test fails incorrectly sometimes, so 1 failure is acceptable) $connectivityTolerance = 1 - $URLs = @("huntress.io", "huntresscdn.com", "update.huntress.io", "eetee.huntress.io", "huntress-installers.s3.amazonaws.com", "huntress-updates.s3.amazonaws.com", "huntress-uploads.s3.us-west-2.amazonaws.com", - "huntress-user-uploads.s3.amazonaws.com", "huntress-rio.s3.amazonaws.com", "huntress-survey-results.s3.amazonaws.com") + $URLs = @("https://bugsnag.com", + "https://eetee.huntress.io/96bca0cef10f45a8f7cf68c4485f23a4", + "https://huntress-installers.s3.us-east-1.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress-rio.s3.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress-survey-results.s3.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress-updates.s3.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress-uploads.s3.us-west-2.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress-user-uploads.s3.amazonaws.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://huntress.io", + "https://huntresscdn.com/agent/connectivity/96bca0cef10f45a8f7cf68c4485f23a4.txt", + "https://update.huntress.io") + foreach ($URL in $URLs) { - if (! (Test-NetConnection $URL -Port 443).TcpTestSucceeded) { + try + { + $Response = Invoke-WebRequest -Uri $URL -TimeoutSec 5 -ErrorAction Stop + # This will only execute if the Invoke-WebRequest is successful. + $StatusCode = $Response.StatusCode + } catch { + $StatusCode = $_.Exception.Response.StatusCode.value__ + } + + if ($StatusCode -ne 200) { $err = "WARNING, connectivity to Huntress URL's is being interrupted. You MUST open port 443 for $($URL) in order for the Huntress agent to function." - Write-Output $err -ForegroundColor white -BackgroundColor red - LogMessage $err + Write-Output $err -ForegroundColor white -BackgroundColor red $connectivityTolerance -- } else { - LogMessage "Connection succeeded to $($URL) on port 443!" + Write-Output "Connection succeeded to $($URL)" } } if ($connectivityTolerance -lt 0) {