如何使用PowerShell从签名的dll中提取摘要算法? [英] How to extract digest algorithm from signed dll using PowerShell?

查看:178
本文介绍了如何使用PowerShell从签名的dll中提取摘要算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个经过数字签名的dll文件.我需要编写一个PowerShell命令,该命令可以使我获得用于数字签名的摘要算法.

I have a dll file which is digitally signed. I need to write a PowerShell command which could get me the Digest Algorithm that is used for the Digital Signature.

我需要的摘要算法信息:

Digest Algorithm info I need:

我尝试使用Get-AuthenticodeSignature,但这并没有为我提供摘要算法信息.

I tried with Get-AuthenticodeSignature but this didn't get me the Digest Algorithm info.

运行以下命令后,我得到以下结果.

After running the following command I get the below result.

Get-AuthenticodeSignature "C:\Program Files\Application Verifier\vrfauto.dll" | Format-List

以上结果:

推荐答案

所以您正在寻找的是

Get-AuthenticodeSignature | %{
    $_.SignerCertificate.SignatureAlgorithm.FriendlyName
}

让我们回顾一下如何到达那里.首先,我找到一个具有数字签名的文件.在此示例中,我将使用 PowerShell-6.1.2-win-x64.msi .

Lets go over how we got to there. First i find a file that has a Digital Signature. I will use PowerShell-6.1.2-win-x64.msi for this example.

Get-AuthenticodeSignature -FilePath C:\test\PowerShell-6.1.2-win-x64.msi | get-member

我们看到 SignerCertificate

SignerCertificate      Property   System.Security.Cryptography.X509Certificates.X509Certificate2 SignerCertificate {get;}

所以让我们看看有什么

Get-AuthenticodeSignature -FilePath C:\test\PowerShell-6.1.2-win-x64.msi | %{
    $_.SignerCertificate | get-member
}

现在我们看到有一个 SignatureAlgorithm 属性

Now we see there is a SignatureAlgorithm property

SignatureAlgorithm              Property       System.Security.Cryptography.Oid SignatureAlgorithm {get;}

现在我们再深入一遍

Get-AuthenticodeSignature -FilePath C:\test\PowerShell-6.1.2-win-x64.msi | %{
    $_.SignerCertificate.SignatureAlgorithm | get-member
}

我们得到了:

FriendlyName Property   string FriendlyName {get;set;}
Value        Property   string Value {get;set;}

我们可以看到两个字符串,因此我们测试出哪个对我们更好...结果就是它的友好名称:

We can see there both strings so we test out which is better for us...turns out its friendly name :

Get-AuthenticodeSignature -FilePath C:\test\PowerShell-6.1.2-win-x64.msi | %{
    $_.SignerCertificate.SignatureAlgorithm.FriendlyName
}

返回

sha256RSA

这篇关于如何使用PowerShell从签名的dll中提取摘要算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆