【问题标题】:How does Windows link a pe file to its signature in a catalog file?Windows 如何将 pe 文件链接到其在目录文件中的签名?
【发布时间】:2013-05-24 23:20:41
【问题描述】:

运行signtool.exe verify /a /v C:\Windows\notepad.exe 我可以看到notepad.exe 的签名在C:\Windows\system32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\ntexe.cat。 signtool 如何知道此 pe 文件的签名所在的位置?

我正在尝试在 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

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

【问题讨论】:

    标签: python windows security certificate signtool


    【解决方案1】:
    免责声明:以下是基于测试的粗略猜测,因为没有记录确切的过程。

    Windows 扫描 System32\CatRoot\{F7--EE} 中的每个 cat 文件,将它们添加到 system catalog database 并按每个条目的文件哈希/标记值粗略地对它们进行排序。
    (由包含数据库进程日志的 CatRoot2\dberr.txt 揭示)
    数据库是文件 System32\CatRoot2\{F7--EE}\catdb。
    在 catdb 中,文件哈希后跟其在 CatRoot\{F7--EE} 中的 cat 文件名。
    请注意,哈希不包括 PE 校验和和证书表条目。
    哈希可以从SignTool verify /v 或this 获取。

    【讨论】:

    • 有什么方法可以读取/解析 catdb 文件吗?它是一个ese db吗?一旦我停止加密服务,我就可以打开它。
    • @vfxGer 嘿,你说得对,它是一个ESE Database,因为它有一个匹配的文件签名。除此之外,我对文件一无所知。我不知道有什么开放的代码库可供阅读。
    • 找到了一个开放的库,也许你已经知道了:Libesedb
    • 有什么办法可以禁用这个cat文件读取吗?来自任务管理器的资源监视器似乎做了很多。这真的很烦人,因为它会多次减慢系统/硬盘的速度?!?!?
    猜你喜欢
    • 1970-01-01
    • 2013-11-05
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    • 2018-01-18
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多