Skip to content

Commit 6bf5a98

Browse files
authored
Implement removal of ScreenConnect traces and domain blocking
Added functionality to remove ScreenConnect registry keys and block known malicious domains in the hosts file.
1 parent ae70cc7 commit 6bf5a98

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

fix.ps1

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,47 @@ Get-ScheduledTask -ErrorAction SilentlyContinue |
213213
Unregister-ScheduledTask -TaskName $_.TaskName -Confirm:$false -ErrorAction SilentlyContinue
214214
Log-Removed "Scheduled Task: $($_.TaskName)"
215215
}
216+
# ScreenConnect Event Log and Tracing registry keys
217+
Write-Log " [*] Removing ScreenConnect Event Log and Tracing registry keys..." "Yellow"
218+
$TracingPaths = @(
219+
"HKLM:\SYSTEM\ControlSet001\Services\EventLog\Application\ScreenConnect*",
220+
"HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Application\ScreenConnect*",
221+
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Tracing\ScreenConnect_RASAPI32",
222+
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Tracing\ScreenConnect_RASMANCS"
223+
)
224+
foreach ($path in $TracingPaths) {
225+
Get-ChildItem -Path $(Split-Path $path -Parent) -ErrorAction SilentlyContinue |
226+
Where-Object { $_.Name -match (Split-Path $path -Leaf).Replace("*",".*") } |
227+
ForEach-Object {
228+
try {
229+
Remove-Item -Path $_.PSPath -Recurse -Force -ErrorAction Stop
230+
Write-Log " [OK] Removed registry key: $($_.Name)" "Green"
231+
Log-Removed "Registry Tracing: $($_.Name)"
232+
} catch {
233+
Write-Log " [!] Failed to remove $($_.Name)" "Red"
234+
Log-Failed "Registry Tracing: $($_.Name)"
235+
}
236+
}
237+
}
238+
# SideBySide/ClickOnce deployment cache in Registry
239+
Write-Log " [*] Purging ScreenConnect from SideBySide registry cache..." "Yellow"
240+
$userHives = Get-ChildItem -Path "Registry::HKEY_USERS" -ErrorAction SilentlyContinue
241+
foreach ($userHive in $userHives) {
242+
$sxsPath = "$($userHive.PSPath)\SOFTWARE\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0"
243+
if (Test-Path $sxsPath) {
244+
Get-ChildItem -Path $sxsPath -Recurse -ErrorAction SilentlyContinue |
245+
Where-Object { $_.Name -match "ScreenConnect" -or $_.Name -match "scre\.\." } |
246+
ForEach-Object {
247+
try {
248+
Remove-Item -Path $_.PSPath -Recurse -Force -ErrorAction Stop
249+
Write-Log " [OK] Removed SideBySide key: $($_.Name)" "Green"
250+
Log-Removed "SideBySide Cache: $($_.Name)"
251+
} catch {
252+
# Keys might be locked or already deleted
253+
}
254+
}
255+
}
256+
}
216257

217258

218259
# ════════════════════════════════════════════════════════════
@@ -431,6 +472,29 @@ try {
431472
Write-Log " [!] DNS flush failed: $($_.Exception.Message)" "Red"
432473
Log-Failed "DNS Cache flush"
433474
}
475+
# Sinkhole known malicious ScreenConnect domains
476+
Write-Log " [*] Blocking known malicious ScreenConnect domains in hosts file..." "Yellow"
477+
$hostsFile = "$env:windir\System32\drivers\etc\hosts"
478+
$badDomains = @(
479+
"furnwiz.screenconnect.com",
480+
"furniturewizard.screenconnect.com",
481+
"instance-fc5xev-relay.screenconnect.com",
482+
"instance-sis2tc-relay.screenconnect.com"
483+
)
484+
foreach ($domain in $badDomains) {
485+
if (-not (Select-String -Path $hostsFile -Pattern $domain -Quiet -ErrorAction SilentlyContinue)) {
486+
try {
487+
Add-Content -Path $hostsFile -Value "0.0.0.0`t$domain"
488+
Write-Log " [OK] Added host file block: $domain" "Green"
489+
Log-Removed "Hosts File Block: $domain"
490+
} catch {
491+
Write-Log " [!] Failed to block $domain in hosts file" "Red"
492+
Log-Failed "Hosts File Block: $domain"
493+
}
494+
} else {
495+
Write-Log " [--] Host file block already exists: $domain" "DarkGray"
496+
}
497+
}
434498

435499

436500
# ════════════════════════════════════════════════════════════

0 commit comments

Comments
 (0)