3

PowerShell のみを使用して、署名付きファイルの証明書チェーンを一覧表示する方法を探しています。具体的には、ルート証明書を取得します。

特定の実行可能ファイル (インストールされたソフトウェア上) が依存している Microsoft 以外のルート証明書のリストを取得する必要があるためです。これは、Microsoft KB293781 の PKI 手順を使用する OS ベースライン ガイドラインによるものです。特定のルート証明書のみを特定のコンピューターに配置する必要がある場合。たとえば、よく使用される「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

乾杯、テック

4

1 に答える 1

8

これは、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}

それはあなたが探していたものをあなたに与えますか?

于 2015-01-23T03:42:19.467 に答える