在根据内核签名策略进行验证时,如何使用signtool.exe列出所有签名

0xC*_*22L 6 windows code-signing authenticode signtool

因此,我正在使用Windows SDK 8.1中的signtool对二进制文件进行签名:

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /a /i Symantec /ac C:\utils\MSCV-VSClass3.cer /ph /t "http://timestamp.verisign.com/scripts/timstamp.dll" "foo.exe"
Done Adding Additional Store
Successfully signed: foo.exe
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /a /i Symantec /ac C:\utils\MSCV-VSClass3.cer /ph /fd sha256 /tr "http://timestamp.geotrust.com/tsa" /td sha256 /as "foo.exe"
Done Adding Additional Store
Successfully signed: foo.exe
Run Code Online (Sandbox Code Playgroud)

当我在文件属性中查看它时,可以看到正确的结果。

但是,当我使用它时verifysigntool我会根据传递的参数获得:

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" verify /all "foo.exe"
File: foo.exe
Index  Algorithm  Timestamp
========================================
SignTool Error: A certificate chain processed, but terminated in a root
        certificate which is not trusted by the trust provider.
SignTool Error: A certificate chain processed, but terminated in a root
        certificate which is not trusted by the trust provider.
Run Code Online (Sandbox Code Playgroud)

使用/pa/pa /all我可以看到两个时间戳:

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" verify /pa "foo.exe"
File: foo.exe
Index  Algorithm  Timestamp
========================================
0      sha1       Authenticode

Successfully verified: foo.exe
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" verify /pa /all "foo.exe"
File: foo.exe
Index  Algorithm  Timestamp
========================================
0      sha1       Authenticode
1      sha256     RFC3161
Run Code Online (Sandbox Code Playgroud)

但是,当尝试使用它/kp来验证内核签名策略时,signtool拒绝与/all以下命令一起运行:

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" verify /kp /all "foo.exe"
SignTool Error: The /all option is incompatible with the /kp option.
Run Code Online (Sandbox Code Playgroud)

所以我有两个问题:

  1. 这是一个缺陷(即/kp/all不一起工作)?
  2. 有没有比signtool verify两次调用一次更好的方法,一次调用一次,一次调用/pa /all一次/kp查看所有时间戳根据内核签名策略进行验证?

Kon*_*sov 3

我最近偶然发现了与/kp和相同的问题/all,并且完全偶然地发现参数的顺序很重要。如果我指定/kp /all,我就会得到The /all option is incompatible with the /kp option。但如果我通过了/all /kp,验证就会顺利进行:它会枚举文件中的所有签名并检查它们。