Skip to content

Commit

Permalink
Improved privacy related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 committed May 25, 2024
1 parent bcfbd51 commit a3006f2
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 140 deletions.
4 changes: 2 additions & 2 deletions Wrapper/Localizations/de-DE/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -1839,11 +1839,11 @@
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Aktivieren Sie einen zusätzlichen Schutz für den LSA-Prozess (Local Security Authority), um die Einspeisung von Code zu verhindern, der Anmeldeinformationen gefährden könnte."
"ToolTip": "Aktivieren Sie den Schutz der lokalen Sicherheitsbehörde, um Code-Injektion ohne UEFI-Sperre zu verhindern."
},
"One": {
"Tag": "Disable",
"ToolTip": "Deaktivieren Sie den Schutz der lokalen Sicherheitsbehörde (Standardeinstellung)."
"ToolTip": "Deaktivieren Sie den Schutz der lokalen Sicherheitsbehörde ohne UEFI-Sperre (Standardeinstellung)."
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions Wrapper/Localizations/en-US/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -1839,11 +1839,11 @@
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Enable Local Security Authority protection to prevent code injection."
"ToolTip": "Enable Local Security Authority protection to prevent code injection without UEFI lock."
},
"One": {
"Tag": "Disable",
"ToolTip": "Disable Local Security Authority protection (default value)."
"ToolTip": "Disable Local Security Authority protection without UEFI lock (default value)."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода."
"ToolTip": "Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода, без блокировки UEFI."
},
"One": {
"Tag": "Disable",
Expand Down
74 changes: 51 additions & 23 deletions src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# https://www.youtube.com/GHOSTSPECTRE
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://github.com/hellzerg/optimizer
Optimizer = "$(Get-ItemPropertyValue -Path `"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders`" -Name `"{374DE290-123F-4565-9164-39C4925E467B}`")\OptimizerDownloads"
Optimizer = "$(Get-ItemPropertyValue -Path `"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders`" -Name `"{374DE290-123F-4565-9164-39C4925E467B}`")\OptimizerDownloads"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
Expand Down Expand Up @@ -1310,6 +1310,10 @@ function ErrorReporting
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Disable"
Expand Down Expand Up @@ -1372,6 +1376,10 @@ function FeedbackFrequency
$Automatically
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DoNotShowFeedbackNotifications -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DoNotShowFeedbackNotifications -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Never"
Expand All @@ -1381,10 +1389,12 @@ function FeedbackFrequency
New-Item -Path HKCU:\Software\Microsoft\Siuf\Rules -Force
}
New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force

Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore
}
"Automatically"
{
Remove-Item -Path HKCU:\Software\Microsoft\Siuf\Rules -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore
}
}
}
Expand Down Expand Up @@ -1736,6 +1746,10 @@ function SigninInfo
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableAutomaticRestartSignOn -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableAutomaticRestartSignOn -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Disable"
Expand Down Expand Up @@ -1844,6 +1858,10 @@ function AdvertisingID
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Disable"
Expand Down Expand Up @@ -1954,6 +1972,10 @@ function WindowsTips
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent -Name DisableSoftLanding -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\CloudContent -Name DisableSoftLanding -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Enable"
Expand Down Expand Up @@ -2060,6 +2082,10 @@ function AppsSilentInstalling
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\CloudContent -Name DisableWindowsConsumerFeatures -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\CloudContent -Name DisableWindowsConsumerFeatures -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Disable"
Expand Down Expand Up @@ -2170,6 +2196,10 @@ function TailoredExperiences
$Enable
)

# Remove all policies in order to make changes visible in UI only if it's possible
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CloudContent -Name DisableTailoredExperiencesWithDiagnosticData -Force -ErrorAction Ignore
Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\CloudContent -Name DisableTailoredExperiencesWithDiagnosticData -Type CLEAR

switch ($PSCmdlet.ParameterSetName)
{
"Disable"
Expand Down Expand Up @@ -4616,7 +4646,7 @@ function Cursors
return
}

$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/raw/master/Misc/dark.zip"
OutFile = "$DownloadsFolder\dark.zip"
Expand All @@ -4630,7 +4660,7 @@ function Cursors
New-Item -Path "$env:SystemRoot\Cursors\W11_dark_v2.2" -ItemType Directory -Force
}

# Extract archive. We cannot call tar.exe due to it fails to extract files if username has cyrillic first letter in lowercase
# Extract archive. We cannot call tar.exe due to it fails to extract files if username has cyrillic first letter in lowercase ###
# Start-Process -FilePath "$env:SystemRoot\System32\tar.exe" -ArgumentList "-xf `"$DownloadsFolder\dark.zip`" -C `"$env:SystemRoot\Cursors\W11_dark_v2.2`" -v"
# https://github.com/PowerShell/PowerShell/issues/21070
Add-Type -Assembly System.IO.Compression.FileSystem
Expand All @@ -4652,10 +4682,8 @@ function Cursors
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name IBeam -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\beam.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name No -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\unavailable.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name NWPen -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\handwriting.cur" -Force
# This is not a typo
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name Person -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\pin.cur" -Force
# This is not a typo
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name Pin -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\person.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name Person -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\person.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name Pin -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\pin.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name precisionhair -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\precision.cur" -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name "Scheme Source" -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Control Panel\Cursors" -Name SizeAll -PropertyType ExpandString -Value "%SystemRoot%\Cursors\W11_dark_v2.2\move.cur" -Force
Expand Down Expand Up @@ -4744,7 +4772,7 @@ function Cursors
return
}

$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/raw/master/Misc/light.zip"
OutFile = "$DownloadsFolder\light.zip"
Expand Down Expand Up @@ -9600,9 +9628,9 @@ public static int UnloadHive(RegistryHives hive, string subKey)
Clear-Variable -Name UserRegisteredProgIDs -Force -ErrorAction Ignore
[array]$UserRegisteredProgIDs = @()

foreach ($Item in (Get-Item -Path "HKCU:\SOFTWARE\RegisteredApplications").Property)
foreach ($Item in (Get-Item -Path "HKCU:\Software\RegisteredApplications").Property)
{
$Subkey = (Get-ItemProperty -Path "HKCU:\SOFTWARE\RegisteredApplications" -Name $Item -ErrorAction Ignore).$Item
$Subkey = (Get-ItemProperty -Path "HKCU:\Software\RegisteredApplications" -Name $Item -ErrorAction Ignore).$Item
if ($Subkey)
{
if (Test-Path -Path "HKCU:\$Subkey\$Associations")
Expand Down Expand Up @@ -9873,7 +9901,7 @@ public static long MakeLong(uint left, uint right)
New-ItemProperty -Path "HKCU:\Software\Classes\$ProgId\DefaultIcon" -Name "(default)" -PropertyType String -Value $Icon -Force
}

New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -Type DWord -Value 0 -Force
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($ProgID)_$($Extension)" -Type DWord -Value 0 -Force

if ($Extension.Contains("."))
{
Expand Down Expand Up @@ -9968,7 +9996,7 @@ function Export-Associations
# ProgrammPath
if ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Classes\$($_.ProgId)\shell\open\command", "", $null))
{
$PartProgramPath = (Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Classes\$($_.ProgId)\Shell\Open\Command" -Name "(default)").Trim()
$PartProgramPath = (Get-ItemPropertyValue -Path "HKCU:\Software\Classes\$($_.ProgId)\Shell\Open\Command" -Name "(default)").Trim()
$Program = $PartProgramPath.Substring(0, ($PartProgramPath.IndexOf(".exe") + 4)).Trim('"')

if ($Program)
Expand Down Expand Up @@ -12185,7 +12213,7 @@ function HEVC

Write-Verbose -Message $Localization.HEVCDownloading -Verbose

$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Expand Down Expand Up @@ -14005,7 +14033,7 @@ function EventViewerCustomView
}

# Save ProcessCreation.xml in the UTF-8 without BOM encoding
Set-Content -Path "$env:ProgramData\Microsoft\Event Viewer\Views\ProcessCreation.xml" -Value $XML -Encoding Default -NoNewline -Force
Set-Content -Path "$env:ProgramData\Microsoft\Event Viewer\Views\ProcessCreation.xml" -Value $XML -Encoding UTF8 -NoNewline -Force
}
"Disable"
{
Expand Down Expand Up @@ -14560,15 +14588,15 @@ function CastToDeviceContext
{
"Hide"
{
if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
{
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
}
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force
}
"Show"
{
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore
}
}
}
Expand Down Expand Up @@ -14617,15 +14645,15 @@ function ShareContext
{
"Hide"
{
if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
{
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
}
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force
}
"Show"
{
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore
}
}
}
Expand Down
Loading

0 comments on commit a3006f2

Please sign in to comment.