我同样需要获取 pe_file(Windows 二进制)签名的时间。
我花了一段时间才弄清楚如何使用
signify
和 python 来获取此信息。他们的关键是弄清楚如何遵循和使用此处 signify
文档中的图表:https://signify.readthedocs.io/en/latest/authenticode.html#pkcs7-objects
看这个例子:
from signify.authenticode.signed_pe import SignedPEFile
pathname = r"SoftwareUpdate.exe"
with open(pathname, "rb") as f:
pefile = SignedPEFile(f)
print(list(pefile.signed_datas)[0].signer_infos[0].countersigner.signing_time)
我在 Ubuntu 上针对 signify
项目中的
SoftwareUpdate.exe测试文件进行了测试:
tools/Python$ curl -O https://raw.githubusercontent.com/ralphje/signify/master/tests/test_data/SoftwareUpdate.exe
tools/Python$ python3 get_pefile_signify_time.py
2008-07-25 22:21:53+00:00
Windows 的屏幕截图:
上面的代码片段在这里:https://github.com/jgstew/tools/blob/master/Python/get_pefile_signify_time.py
这是我用来解决这个问题的脚本:https://github.com/jgstew/tools/blob/master/Python/get_pefile_signify.py
文件夹中还有其他与 pefile 相关的示例。
相关: