我想從一些 Windows\System32 檔案中洗掉所有權限,例如 wuauclt.exe 和 wuaueng.dll。因此我找到了那個腳本:
takeown /F $file
$acl = get-acl $file
$acl.Access | % {$acl.purgeaccessrules($_.IdentityReference)}
Set-Acl -aclobject $acl -Path $file
這給了我所有權并洗掉了除所有應用程式包和所有受限應用程式包之外的所有權限。我如何能夠根據 PowerShell 腳本(不是手動且不使用 3rd 方工具)洗掉這些內容?
提前致謝!
uj5u.com熱心網友回復:
這些IdentityReference是具體的。事實上,它是一個實體[System.Security.Principal.NTAccount]并將它們轉換為[System.Security.Principal.SecurityIdentifier]輸出錯誤。但是仍然可以手動創建它們。SDDL 格式:
AC或S-1-15-2-1為ALL APPLICATION PACKAGESS-1-15-2-2為了ALL RESTRICTED APPLICATION PACKAGES
您可以添加以下代碼來洗掉它們。但我不確定洗掉系統檔案的這些權限是否是個好主意。
$acl.Access | % {
if ($_.IdentityReference.Value -imatch "APPLICATION PACKAGES") {
try {
$acl.PurgeAccessRules([System.Security.Principal.SecurityIdentifier]::new("S-1-15-2-2"))
$acl.PurgeAccessRules([System.Security.Principal.SecurityIdentifier]::new("AC"))
} catch { }
}
else {
$acl.purgeaccessrules($_.IdentityReference)
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/368906.html
