我可以从 DLL 中删除数字签名吗?

发布于 2024-07-09 15:22:25 字数 182 浏览 4 评论 0 原文

我的安装程序在构建过程中使用代码签名证书构建“签名”DLL。

我注意到,如果我尝试连续构建两次,第二次构建就会失败,因为 DLL 已经签名,因此符号代码会被阻塞。 显然,我可以通过在构建中签署 DLL 的副本来解决此问题,但这个问题引起了我的兴趣:

是否可以“取消签名”DLL,如果不能,为什么不......?

My installer build "signs" a DLL using a Code Signing certificate during the build process.

I've noticed that if I try to build twice in succession, the second build fails because the DLL is already signed so signcode chokes. Obviously I can fix this by signing a copy of the DLL in the build, but the problem intrigued me:

Is it possible to "unsign" a DLL, and if not, why not...?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

2024-07-16 15:22:25
signtool remove /s C:\path\to.exe.or.dll

signtool 可用于Windows SDK,并且必须至少来自 Windows 8 SDK 套件(版本 6.2.9200.20789)才能支持 remove 命令。

signtool remove /s C:\path\to.exe.or.dll

signtool is available in Windows SDK, and must be at least from Windows 8 SDK kit (version 6.2.9200.20789) to have the remove command supported.

朮生 2024-07-16 15:22:25

您可以使用 XDA 论坛帖子中的 delcert.exe。

这是一个剥离(删除)数字签名(Authenticode)的小工具
来自 PE 可执行文件,例如 *.exe、*.dll、*.mui 等

You can use delcert.exe from the this XDA Forum post.

here is a small tool that strips (removes) digital sign (Authenticode)
from PE executable files like *.exe, *.dll, *.mui, etc.

丢了幸福的猪 2024-07-16 15:22:25

使用 ImageRemoveCertificate API。

您的标签中没有指定任何语言,但本文介绍了如何在 C# 中实现它。 使用 C# 从文件中删除数字签名

除此之外,如果您正在寻找一个简单的工具来为您完成这项工作,您可以使用 FileUnsigner

It's fairly easy to remove the signature from a .dll file using the ImageRemoveCertificate API.

You don't have any language specified in your tags but this article shows how to implement it in C#. Remove digital signature from a file using C#

Other than that, if you are looking for a simple tool to do the work for you, you can use FileUnsigner.

燃情 2024-07-16 15:22:25

另一种可能的选择是切换到 SignTool。 exe。 它附带 Windows SDK 并对已签名的二进制文件进行签名不产生错误。 我在构建过程中使用了signtool.exe,即使某些内容已经签名,也没有任何困难。

另外,请查看问题 signcode 之间的主要区别是什么.exe 和signtool.exe?

Another possible option is to switch to the SignTool.exe. It comes with the Windows SDK and signing a binary that has already been signed does not generate an error. I use signtool.exe in my build process and haven't any difficulties with it, even when something is already signed.

Also, check out the question What's the main difference between signcode.exe and signtool.exe?

绝情姑娘 2024-07-16 15:22:25

当然这是可能的,但并非微不足道。

尽管保存预签名 DLL 的副本会更容易。

此数字签名只不过是附加到 PE 文件末尾的额外部分。 如果需要,您可以编写一个删除签名的程序。

这并不像截断文件那么简单; 您必须删除对文件头中签名的引用。 如果 DLL 有多个签名而您只想删除一个签名,那么情况可能会变得复杂。

PE 文件的格式在此处公开记录

Sure it's possible, but not trivial.

Although it would be easier to save a copy of the presigned DLL.

This digital signature is little more than an extra section appended to the end of a PE file. You could write a program that deleted the signature, if you want.

It's not quite as simple as truncating the file; you have to remove references to the signature in the file header. It could get complicated if the DLL has multiple signatures and you just want to remove one.

The format of a PE file is publicly documented here

握住你手 2024-07-16 15:22:25

检查您的构建工具是否支持“重新签名”。 这应该替换所有现有的签名。

如果没有,您可以使用 Stud_PE 删除签名块。
在 Stud_PE 中打开 DLL 或 EXE,转到“部分”选项卡,右键单击数字签名部分并选择“删除部分”。 然而,这需要用户交互。 该工具的旧版本可能会破坏该文件。

Check if your build tool supports "Re-signing". This should replace all existing signatures.

If not, you can use Stud_PE to remove the signature block.
Open the DLL or EXE in Stud_PE, go to the sections tab, right click the digital signature section and select "Delete section". However, this needs user interaction. Old versions of the tool could destroy the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文