|
|
发表于 2014-1-10 11:39:01
|
显示全部楼层
问:如何知道某个文件是不是微软开发的?是不是被黑客程序替换了?
答:包括微软在内,全世界都用【签名】来识别,所以保证签名 1不过期 2没吊销 3文件状态为【验证成功】即可。
又问:那么如何用脚本具体验证呢? ---答:用powershell 2.0中的Get-AuthenticodeSignature指令即可。
如:
Get-AuthenticodeSignature 'c:\Program Files (x86)\Internet Explorer\iexplore.exe' |Format-List
-------------------------以下内容摘自 镇派葵花宝典,即powershell版内置顶的官方手册----------------------------------------
示例 1
C:\PS>get-AuthenticodeSignature -filepath C:\Test\NewScript.ps1
说明
-----------
此命令获取有关 NewScript.ps1 文件中 Authenticode 签名的信息。它使用 FilePath 参数来指定文件。
示例 2
C:\PS>get-authenticodesignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1
说明
-----------
此命令获取有关命令行中列出的四个文件中 Authenticode 签名的信息。在此命令中,省略了 FilePath 参数(该参数为可选项)的名称。
示例 3
C:\PS>get-childitem $pshome\*.* | foreach-object {Get-AuthenticodeSignature $_} | where {$_.status -eq "Valid"}
说明
-----------
此命令会列出 $pshome 目录中具有有效 Authenticode 签名的所有文件。$pshome 自动变量包含 Windows PowerShell 安装目录的路径。
此命令使用 Get-ChildItem cmdlet 获取 $pshome 目录中的文件。它采用 *.* 模式排除目录(尽管它也会排除文件名中不含点的文件)。
此命令使用管道运算符 (|) 将 $pshome 中的文件发送到 Foreach-Object cmdlet,其中将针对每个文件调用 Get-AuthenticodeSignature。
Get-AuthenticodeSignature 命令的结果将发送到 Where-Object 命令,该命令仅选择状态为“Valid”的签名对象。 |
|