Skip to main content

Disable SmartScreen integrations

Overview

About this script

This script improves your privacy on Windows.

These changes use Windows system commands to update your settings.

This script disables COM SmartScreen integrations within Windows.

SmartScreen is a security feature that aims to protect your device from harmful applications, files, and websites by comparing items with a database of known threats 1.

COM (Component Object Model) objects are software components that let different programs communicate 2. These integrations allow SmartScreen to interact with various Windows components 2 3. Disabling these components disrupts SmartScreen's functionality.

This script improves privacy by:

  • Reducing data collection related to SmartScreen operations
  • Limiting the system's ability to scan and report on your activities

Disabling SmartScreen may improve system performance by:

  • Removing background processes associated with SmartScreen
  • Potentially speeding up application launches, especially if SmartScreen is partially disabled 4

If other SmartScreen components are already disabled, this script may help maintain system integrity 4.

However, disabling these integrations may reduce security by:

  • Limiting the system's ability to detect and prevent malware or phishing attempts 1
  • Disabling protective features that scan downloaded files and warn about unsafe websites 1
Caution

Disabling SmartScreen integrations may make your system more vulnerable to malware and phishing attacks. Consider your personal security needs before applying these changes.

Technical Details

This script disables several COM interfaces, classes, and applications associated with SmartScreen.

Key components affected include:

  • SmartScreen event logging and reporting interfaces
  • URI (Uniform Resource Identifier) and file reputation services
  • Application reputation services
  • SmartScreen-related Windows Runtime activatable classes

The components disabled by this script consist of:

TypeNameID
InterfaceIDeferredParametersHandler 3Interface ID: 741baa78-e96f-466c-9ffa-81af5ce4cd59 3
InterfaceIEventLogger 3Interface ID: a3104ea9-a816-4fdc-860c-75408a04b686 3
InterfaceIEventLoggerFactory 3Interface ID: 16ae6386-0aa2-45fc-aab2-f2ee3a0f3188 3
InterfaceIHtmlContentInfo 3Interface ID: 680d04e6-9661-4ac5-b962-58b112ffa5e6 3
InterfaceIButtonInfo 3Interface ID: 9ad9b845-b683-493e-8d39-45a56d54617d 3
InterfaceIVectorView<ButtonInfo> 3Interface ID: e9444d66-3ff9-5410-8984-f9063f825683 3
InterfaceIIterable<ButtonInfo> 3Interface ID: 69c26f3c-53aa-56cc-818f-4be79004cd02 3
InterfaceIIterator<ButtonInfo> 3Interface ID: 60f00258-24f8-5460-bb2d-853a614a50ec 3
InterfaceIPopupButtonInfo 3Interface ID: c729ad47-6f3a-46f4-af74-3b5c3311e6ed 3
InterfaceIUriReputationExperienceInfo 3Interface ID: 7fdde05c-d2db-495b-b06d-4a8d84f3ab99 3
InterfaceIAsyncOperation<UriReputationExperienceInfo> 3Interface ID: b2b6814f-02c2-5b0c-9e14-159eb77f4462 3
InterfaceIAsyncOperationCompletedHandler<UriReputationExperienceInfo> 3Interface ID: aad9a740-4131-5fe0-9888-c925750b8a99 3
InterfaceIUriReputationResult 3Interface ID: 1d5bc3a2-a3ff-4517-bb16-25bf18ef7378 3
InterfaceIAsyncOperation<IUriReputationResult> 3Interface ID: f84b2c99-2f3d-5877-bf78-4f40f6bd25c0 3
InterfaceIAsyncOperationCompletedHandle<IUriReputationResult> 3Interface ID: d164f201-3f19-588a-a21e-06c60651d335 3
InterfaceIUriReputationService 3Interface ID: a774d785-2808-4471-a254-ab93932b61ea 3
InterfaceIUriReputationServiceStatics 3Interface ID: 29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB 3
InterfaceIUriReputationSettings 3Interface ID: 3474d734-3408-4471-a344-a3439343634a 3
InterfaceIFileReputationResult 3Interface ID: 48748dc6-576c-47c0-8169-b99cc31a68fe 3
InterfaceIAsyncOperation<FileReputationResult> 3Interface ID: 0b3418c4-edbd-5275-a27d-c814665bd20b 3
InterfaceIAsyncOperationCompletedHandler<FileReputationResult> 3Interface ID: e406ebb7-b140-562f-bcbc-40f0ef479d38 3
InterfaceIFileReputationService 3Interface ID: 67e7f99b-1b65-4343-825d-eb17c9681805 3
InterfaceIAppxPackage 3Interface ID: 56ed2384-8491-4fbc-8f1d-141faf905d85 3
InterfaceIIterable<IAppxPackage> 3Interface ID: c4c9b336-6104-586e-b35c-9f9029afb178 3
InterfaceIIterator<IAppxPackage> 3Interface ID: 235e004e-c711-5d74-8895-25412ca30088
InterfaceIWindow 3Interface ID: ad6db2cf-0c8d-438b-b25d-9a9a82903b2b 3
InterfaceIAppReputationService 3Interface ID: d9dc3975-1062-470a-994c-409151ff8f54 3
InterfaceIAppReputationServiceStaticsInterface ID: 343baa78-e34f-466c-9ffa-81af5ce4cd34 3
InterfaceIAsyncOperation<AppReputationResult> 3Interface ID: 377f919e-1b1a-5ca1-9ac0-70f57dcf5f61 3
InterfaceIAsyncOperationCompletedHandler<AppReputationResult> 3Interface ID: 1b988c32-1bc7-52fa-83ba-0b97e79c878b 3
AppSmartScreen 5AppId: a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d 3 5
ClassSmartScreen 3 5CLSID: a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d 3 4 5
ActivatableClassEventLoggerActivatableClassId: Windows.Internal.Security.SmartScreen.EventLogger 3
ActivatableClassUriReputationServiceActivatableClassId: Windows.Internal.Security.SmartScreen.UriReputationService 3
ActivatableClassAppReputationServiceActivatableClassId: Windows.Internal.Security.SmartScreen.AppReputationService 3

This script uses Batch (batchfile) scripting language.

Not Advised

This script should only be used by advanced users. This script is not recommended for daily use as it breaks important functionality. Do not run it without having backups and system snapshots.

Implementation Details
  • Language: batch

  • Required Privileges: Administrator rights

  • Compatibility: Windows only

  • Reversibility: Can be undone using provided revert script

Explore Categories

This action belongs to Disable SmartScreen system components category. This category includes scripts that disable SmartScreen system components. SmartScreen is a security feature in Windows that helps protect your device from potentially harmful applications, files, and websites. Its components run in the background as part of the operating system. Disabling these... Read more on category page ▶

Apply now

Choose one of three ways to apply:

  1. Automatically via privacy.sexy: The easiest and safest option.
  2. Manually by downloading: Requires downloading a file.
  3. Manually by copying: Advanced flexibility.

Alternative 1. Apply with Privacy.sexy

privacy.sexy is free and open-source application that lets securely apply this action easily.

Open privacy.sexy

You can fully restore this action (revert back to the original behavior) using the application.

privacy.sexy instructions
  1. Open or download the desktop application
  2. Search for the script name: Disable SmartScreen integrations.
  3. Check the script by clicking on the checkbox.
  4. Click on Run button at the bottom of the page.

Alternative 2. Download

Irreversible Changes

This script is irreversible, meaning there is no straightforward method to restore changes once applied. Exercise caution before running, restoring it may not be possible.

  1. Download the script file by clicking on the button below:

    Download script

  2. Run the script file by clicking on it.

Download revert script

This file restores your system to its original state, before this script is applied.

Download restore script

Alternative 3. Copy

This is for advanced users. Consider automatically applying or downloading the script for simpler way.

  1. Open Command Prompt as administrator.
HELP: Step-by-step guide
  1. Click on Start menu

  2. Type cmd

  3. Right click on Command Prompt select Run as administrator

  4. Click on Yes to run Command Prompt


Animation showing how to open terminal as administrator on Windows 11

  1. Copy the following code:
Code to apply changes
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{e9444d66-3ff9-5410-8984-f9063f825683} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{e9444d66-3ff9-5410-8984-f9063f825683}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e9444d66-3ff9-5410-8984-f9063f825683} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e9444d66-3ff9-5410-8984-f9063f825683}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{d164f201-3f19-588a-a21e-06c60651d335} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{d164f201-3f19-588a-a21e-06c60651d335}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d164f201-3f19-588a-a21e-06c60651d335} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d164f201-3f19-588a-a21e-06c60651d335}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{a774d785-2808-4471-a254-ab93932b61ea} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{a774d785-2808-4471-a254-ab93932b61ea}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a774d785-2808-4471-a254-ab93932b61ea} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a774d785-2808-4471-a254-ab93932b61ea}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{3474d734-3408-4471-a344-a3439343634a} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{3474d734-3408-4471-a344-a3439343634a}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{3474d734-3408-4471-a344-a3439343634a} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{3474d734-3408-4471-a344-a3439343634a}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{235e004e-c711-5d74-8895-25412ca30088} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{235e004e-c711-5d74-8895-25412ca30088}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{235e004e-c711-5d74-8895-25412ca30088} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{235e004e-c711-5d74-8895-25412ca30088}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{d9dc3975-1062-470a-994c-409151ff8f54} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{d9dc3975-1062-470a-994c-409151ff8f54}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d9dc3975-1062-470a-994c-409151ff8f54} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d9dc3975-1062-470a-994c-409151ff8f54}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.EventLogger as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.EventLogger'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.UriReputationService as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.UriReputationService'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Soft-delete the registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.AppReputationService as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.AppReputationService'''+"^""`r`n"^""+'$suffix=''.OLD'''+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'$global:skip = 0'+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'function Rename-KeyTree($Path) {'+"^""`r`n"^""+' Write-Host "^""Processing key: $Path"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property)'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Renaming ''$value''"^""'+"^""`r`n"^""+' if ($value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $backupName = $value + $suffix'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupName''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename value: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $subkeys) {'+"^""`r`n"^""+' Rename-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming key ''$Path''."^""'+"^""`r`n"^""+' if ($Path.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Has suffix.'''+"^""`r`n"^""+' $global:skip++'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' $backupPath = $Path + $suffix'+"^""`r`n"^""+' while (Test-Path -LiteralPath $backupPath) {'+"^""`r`n"^""+' $backupPath += $suffix'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$backupPath''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully renamed.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to rename: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Soft deleting registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Rename-KeyTree $path'+"^""`r`n"^""+'$totalItems = $global:ok + $global:skip + $global:fail'+"^""`r`n"^""+'Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""'+"^""`r`n"^""+'if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) {'+"^""`r`n"^""+' Write-Host ''No items were processed. The operation had no effect.'''+"^""`r`n"^""+'} elseif ($global:fail -eq $totalItems) {'+"^""`r`n"^""+' throw "^""Operation failed. All $global:fail items could not be processed."^""'+"^""`r`n"^""+'} elseif ($global:ok) {'+"^""`r`n"^""+' Write-Host "^""Successfully processed $global:ok item(s)."^""'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
  1. Right click on command prompt to paste it.
  2. Press Enter to apply remaining code.

Copy restore code

Copy and run the following code to restore changes:

Revert code
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{741baa78-e96f-466c-9ffa-81af5ce4cd59}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a3104ea9-a816-4fdc-860c-75408a04b686}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{16ae6386-0aa2-45fc-aab2-f2ee3a0f3188}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{680d04e6-9661-4ac5-b962-58b112ffa5e6}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{9ad9b845-b683-493e-8d39-45a56d54617d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{e9444d66-3ff9-5410-8984-f9063f825683} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{e9444d66-3ff9-5410-8984-f9063f825683}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e9444d66-3ff9-5410-8984-f9063f825683} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e9444d66-3ff9-5410-8984-f9063f825683}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{69c26f3c-53aa-56cc-818f-4be79004cd02}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{60f00258-24f8-5460-bb2d-853a614a50ec}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c729ad47-6f3a-46f4-af74-3b5c3311e6ed}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{7fdde05c-d2db-495b-b06d-4a8d84f3ab99}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{b2b6814f-02c2-5b0c-9e14-159eb77f4462}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{aad9a740-4131-5fe0-9888-c925750b8a99}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1d5bc3a2-a3ff-4517-bb16-25bf18ef7378}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{f84b2c99-2f3d-5877-bf78-4f40f6bd25c0}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{d164f201-3f19-588a-a21e-06c60651d335} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{d164f201-3f19-588a-a21e-06c60651d335}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d164f201-3f19-588a-a21e-06c60651d335} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d164f201-3f19-588a-a21e-06c60651d335}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{a774d785-2808-4471-a254-ab93932b61ea} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{a774d785-2808-4471-a254-ab93932b61ea}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a774d785-2808-4471-a254-ab93932b61ea} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{a774d785-2808-4471-a254-ab93932b61ea}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{29A3AB33-0FD7-44F5-9BFF-C0B6C081FBFB}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{3474d734-3408-4471-a344-a3439343634a} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{3474d734-3408-4471-a344-a3439343634a}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{3474d734-3408-4471-a344-a3439343634a} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{3474d734-3408-4471-a344-a3439343634a}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{48748dc6-576c-47c0-8169-b99cc31a68fe}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{0b3418c4-edbd-5275-a27d-c814665bd20b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{e406ebb7-b140-562f-bcbc-40f0ef479d38}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{67e7f99b-1b65-4343-825d-eb17c9681805}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{56ed2384-8491-4fbc-8f1d-141faf905d85}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{c4c9b336-6104-586e-b35c-9f9029afb178}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{235e004e-c711-5d74-8895-25412ca30088} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{235e004e-c711-5d74-8895-25412ca30088}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{235e004e-c711-5d74-8895-25412ca30088} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{235e004e-c711-5d74-8895-25412ca30088}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{ad6db2cf-0c8d-438b-b25d-9a9a82903b2b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{d9dc3975-1062-470a-994c-409151ff8f54} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{d9dc3975-1062-470a-994c-409151ff8f54}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d9dc3975-1062-470a-994c-409151ff8f54} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{d9dc3975-1062-470a-994c-409151ff8f54}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{343baa78-e34f-466c-9ffa-81af5ce4cd34}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{377f919e-1b1a-5ca1-9ac0-70f57dcf5f61}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\Interface\{1b988c32-1bc7-52fa-83ba-0b97e79c878b}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\AppId\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d} as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{a463fcb9-6b1c-4e0d-a80b-a2ca7999e25d}'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.EventLogger as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.EventLogger'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.UriReputationService as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.UriReputationService'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Restore registry key: HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.AppReputationService as TrustedInstaller
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = 'function Copy-Acl($Src, $Dst) {'+"^""`r`n"^""+' $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $srcKeys) {'+"^""`r`n"^""+' $dstKey = Join-Path $Dst $key.PSChildName'+"^""`r`n"^""+' Copy-Acl -Src $key.PSPath -Dst $dstKey'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $acl = Get-Acl -Path $Src -ErrorAction Stop'+"^""`r`n"^""+' $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner)'+"^""`r`n"^""+' $sddl = $acl.GetSecurityDescriptorSddlForm($sections)'+"^""`r`n"^""+' $acl.SetSecurityDescriptorSddlForm($sddl, $sections)'+"^""`r`n"^""+' Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Rename-KeyWithAcl($Old, $New) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to copy: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Copy-Acl -Src $Old -Dst $New'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to copy ACL: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed to clean up: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' throw "^""Failed to remove: $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$rawPath=''HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.Internal.Security.SmartScreen.AppReputationService'''+"^""`r`n"^""+'$suffix =''.OLD'''+"^""`r`n"^""+'$global:fail = 0'+"^""`r`n"^""+'$global:ok = 0'+"^""`r`n"^""+'function Get-Real($s) {'+"^""`r`n"^""+' while ($s.EndsWith($suffix)) {'+"^""`r`n"^""+' $s = $s.Substring(0, $s.Length - $suffix.Length)'+"^""`r`n"^""+' }'+"^""`r`n"^""+' return $s'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-KeyTree($Path) {'+"^""`r`n"^""+' $dest = Get-Real $Path'+"^""`r`n"^""+' $src = $Path'+"^""`r`n"^""+' Write-Host "^""Restoring key: ''$dest'' from ''$src''"^""'+"^""`r`n"^""+' if (-Not $src.EndsWith($suffix)) {'+"^""`r`n"^""+' $src += $suffix'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $src)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No data.'''+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (Test-Path -LiteralPath $dest) {'+"^""`r`n"^""+' Write-Host ''Skipping to avoid data loss. Key already exists.'''+"^""`r`n"^""+' Write-Warning "^""Manual intervention may be required to fully restore from ''$src''."^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Restore-Children $dest'+"^""`r`n"^""+'}'+"^""`r`n"^""+'function Restore-Children($Path) {'+"^""`r`n"^""+' Write-Host "^""Restoring values in ''$Path''"^""'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $Path)) {'+"^""`r`n"^""+' Write-Host ''Skipping: Key does not exist. No action needed.'''+"^""`r`n"^""+' return'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $values = ( `'+"^""`r`n"^""+' Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property `'+"^""`r`n"^""+' )'+"^""`r`n"^""+' foreach ($value in $values) {'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value''"^""'+"^""`r`n"^""+' if (-Not $value.EndsWith($suffix)) {'+"^""`r`n"^""+' Write-Host ''Skipping: No action needed.'''+"^""`r`n"^""+' continue'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $real = Get-Real $value'+"^""`r`n"^""+' Write-Host "^""Renaming to ''$real''."^""'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored.'''+"^""`r`n"^""+' $global:ok++'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' Write-Warning "^""Failed: $_"^""'+"^""`r`n"^""+' $global:fail++'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue)'+"^""`r`n"^""+' foreach ($key in $keys) {'+"^""`r`n"^""+' Restore-KeyTree $key.PSPath'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'Write-Host "^""Restoring registry key ''$rawPath'' recursively."^""'+"^""`r`n"^""+'$hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+'$path = $hive + '':'' + $rawPath.Substring($hive.Length)'+"^""`r`n"^""+'Restore-KeyTree $path'+"^""`r`n"^""+'if ($global:fail) {'+"^""`r`n"^""+' Write-Error ''Failed to restore'''+"^""`r`n"^""+' Exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"

Support

This website relies on your support.

Support now

Your donation helps keep the project alive and improves its content ❤️.

Share this page: