led*_*kst 3 powershell scripting certificate pki authenticode
我正在寻找一种方法,仅使用PowerShell,列出签名文件的证书链.专门获取Root证书.
因为我需要获取某些非Microsoft根证书的列表,某些可执行文件(在已安装的软件上)依赖于.这是由于操作系统基准指南,它使用Microsoft KB293781中的PKI过程.只有特定的Root证书才能放在特定的计算机上.例如,经常使用的"VeriSign Class 3 Primary CA-G5"仅在必要时使用.
Get-AuthenticodeSignature仅列出颁发者.例如:Get-AuthenticodeSignature C:\windows\system32\MRT.exe
像"SysInternals SigCheck"这样的工具能够做到这一点sigcheck.exe -i C:\windows\System32\mrt.exe,并且可以进一步解析此信息.此外SignTool.exe,Windows SDK和AnalyzePESigDidier Stevens 等其他工具也可以获取此信息.
但是这可以仅使用PowerShell来完成吗?也许在Windows中使用WinVerifyTrust API. https://msdn.microsoft.com/en-us/library/windows/desktop/aa382384(v=vs.85).aspx http://support2.microsoft.com/kb/323809/en-us
干杯,Tekk
这应该可以通过直接在PowerShell中访问.NET来实现.这是我使用您在问题中引用的示例文件掀起的一个片段:
# Get a X590Certificate2 certificate object for a file
$cert = (Get-AuthenticodeSignature -FilePath C:\windows\system32\MRT.exe).SignerCertificate
# Create a new chain to store the certificate chain
$chain = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Chain
# Build the certificate chain from the file certificate
$chain.Build($cert)
# Return the list of certificates in the chain (the root will be the last one)
$chain.ChainElements | ForEach-Object {$_.Certificate}
Run Code Online (Sandbox Code Playgroud)
这会给你你想要的东西吗?
| 归档时间: |
|
| 查看次数: |
3001 次 |
| 最近记录: |