相关疑难解决方法(0)

从 Windows 中的 PE 可执行文件中检索双重签名信息的修正代码?

我一直在努力修改来自 Microsoft 的此代码示例该示例显示(有些过时)如何从可执行文件中检索代码签名信息。它可以工作,但如果二进制文件是双重签名的,则它不会检索信息。

所以我做了一些研究并尝试重写它以使其识别 Windows 中许多现代可执行文件中存在的双重签名。不幸的是,很少有(模糊的)建议可用(1),(2),例如使用UnauthenticatedAttributesszOID_NESTED_SIGNATURE(无论这意味着什么)但仅用于检索时间戳的建议。

所以我试图重写那个微软代码,这是我得到的:

(要构建它,只需将其复制到 Visual Studio 控制台项目中并更改 .exe 文件路径。处理双重签名的代码在PrintDualSignatureInfo()函数中。)

#include "stdafx.h"

//SOURCE:
//      https://support.microsoft.com/en-us/help/323809/how-to-get-information-from-authenticode-signed-executables
//

#include <windows.h>
#include <wincrypt.h>
#include <wintrust.h>
#include <stdio.h>
#include <tchar.h>
#include <atlconv.h>

#pragma comment(lib, "crypt32.lib")

#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)

typedef struct {
    LPWSTR lpszProgramName;
    LPWSTR lpszPublisherLink;
    LPWSTR lpszMoreInfoLink;
} SPROG_PUBLISHERINFO, *PSPROG_PUBLISHERINFO;



BOOL GetProgAndPublisherInfo(PCMSG_SIGNER_INFO pSignerInfo,
                             PSPROG_PUBLISHERINFO Info);
BOOL GetDateOfTimeStamp(PCMSG_SIGNER_INFO pSignerInfo, SYSTEMTIME *st);
BOOL PrintCertificateInfo(PCCERT_CONTEXT pCertContext);
BOOL GetTimeStampSignerInfo(PCMSG_SIGNER_INFO …
Run Code Online (Sandbox Code Playgroud)

c++ winapi code-signing authenticode digital-signature

5
推荐指数
1
解决办法
1359
查看次数