Windows如何将pe文件链接到编目文件中的签名



运行signtool.exe verify /a /v C:Windowsnotepad.exe,可以看到notepad.exe的签名在C:Windowssystem32CatRoot{F750E6C3-38EE-11D1-85E5-00C04FC295EE}ntexe.cat中。signtool如何知道这个文件的签名存在于哪里?

我正在尝试在python中复制此signtool行为。一旦我有了目录文件,我就可以用下面的代码获得证书信息,但我看不到windows是如何将文件链接到目录的。

import win32com.client
catpath = "C:\Windows\system32\CatRoot\{F----E}\nt5.cat"
signedCode = win32com.client.Dispatch('capicom.signedcode')
signedCode.FileName=catpath
signedCode.Verify()
certs = signedCode.Certificates
for cert in certs:
    print cert.Archived
    print cert.IssuerName
    print cert.SerialNumber
    print cert.SubjectName
    print cert.Thumbprint
    print cert.ValidFromDate
    print cert.ValidToDate
    print cert.Version

但是我如何获得可执行文件所在的安全目录文件?

免责声明:以下是基于测试的粗略猜测,因为确切的过程没有文档记录。

Windows扫描System32CatRoot{F7—EE}中的每个cat文件,将它们添加到系统目录数据库中,并根据每个条目的文件散列/标记值对它们进行粗略排序。
(由CatRoot2dberr.txt显示,其中包含数据库进程的日志)
数据库是文件System32CatRoot2{F7—EE}catdb。
在catdb中,文件散列后跟CatRoot{F7—EE}中的cat文件名。
注意哈希不包括PE校验和和证书表项。
哈希值可以从SignTool verify/v或this获得。

最新更新