当我运行这个脚本时:
$SaveExecutionPolicy = Get-ExecutionPolicy
#
Set-ExecutionPolicy RemoteSigned -Scope Currentuser
Import-Module .\SpeculationControl.psd1
Get-SpeculationControlSettings
Set-ExecutionPolicy $SaveExecutionPolicy -Scope Currentuser它将提供以下输出:
有关以下输出的更多信息,请参见https://support.microsoft.com/en-in/help/4074629 CVE-2017-5715分支目标注入的投机控制设置 提供了对分支目标注入缓解的硬件支持:提供了对分支目标注入缓解的假Windows OS支持:启用了对分支目标注入缓解的真正Windows OS支持:通过系统策略禁用了对分支目标注入缓解的假Windows OS支持:由于缺乏硬件支持而禁用了对分支目标注入缓解的假Windows操作系统支持: CVE-2017-5754恶意数据缓存加载的投机控制设置 硬件需要内核VA阴影:出现了对内核VA阴影的真正Windows OS支持:启用了对内核VA阴影的真正Windows操作系统支持:启用了对PCID性能优化的真正Windows OS支持:为安全性所需的是True CVE-2018-3639投机商店旁路的投机控制设置 Windows支持投机存储旁路禁用: False CVE-2018-3620 L1终端故障的猜测控制设置 硬件易受L1终端故障的影响:存在对L1终端故障缓解的真正Windows支持:启用了对L1终端故障缓解的假Windows支持: 建议的行动
BTIHardwarePresent :假BTIWindowsSupportPresent
:True BTIWindowsSupportEnabled : False BTIDisabledBySystemPolicy : False BTIDisabledByNoHardwareSupport : True KVAShadowRequired
:真KVAShadowWindowsSupportPresent :真KVAShadowWindowsSupportEnabled :真KVAShadowPcidEnabled
:True SSBDWindowsSupportPresent : False SSBDHardwareVulnerable : SSBDHardwarePresent
:False SSBDWindowsSupportEnabledSystemWide : False L1TFHardwareVulnerable : True L1TFWindowsSupportPresent
假L1TFWindowsSupportEnabled : False L1TFInvalidPteBit :0 L1DFlushSupported : False
我想通过这一点来实现自动化:
if ($string -like '*L1TFHardwareVulnerable : True*') { }
{
write-output "1" (stderr)
}
else
{
Write-Output "0" (stdout)
}总的来说,脚本如下所示:
$SaveExecutionPolicy = Get-ExecutionPolicy
#
Set-ExecutionPolicy RemoteSigned -Scope Currentuser
Import-Module .\SpeculationControl.psd1
Get-SpeculationControlSettings
Set-ExecutionPolicy $SaveExecutionPolicy -Scope Currentuser
if ($string -like '*L1TFHardwareVulnerable : True*') { }
{
write-output "1"
}
else
{
Write-Output "0"
}有人能帮我吗?提前感谢
发布于 2018-08-21 13:07:44
将Get-SpeculationControlSettings的输出分配给变量并检查该对象的属性:
$Settings = Get-SpeculationControlSettings
if($Settings.L1TFHardwareVulnerable -and -not($Settings.L1TFWindowsSupportEnabled))
{
return 1
}
else
{
return 0
}有关逻辑运算符(如-and和-not)的更多信息,请参见 help file
https://stackoverflow.com/questions/51949129
复制相似问题