使用 ConfuserEx 混淆 clickOnce 应用程序

Obfuscate a clickOnce Application with ConfuserEx

我实际上是在尝试混淆 ClickOnce 应用程序。

我的混淆器是 ConfuserEx。我遵循了这些步骤:

  1. Click the Publish Wizard..\Publish Now button on your project properties. This will automatically build your project on Debug/Release folder. I use it since it also creates the files used in ClickOnce. We will use those files later.
  2. Open Confuser and Drag-Drop files On the Debug/Release folder that you want confuser to work on.
  3. This will create a Confused folder (using the default output directory settings) with the obfuscated assemblies.
  4. Copy all dependencies/files (if any) required by your project to run to the just create "Confused" folder.
  5. You project should now work with the obfuscated assemblies. I ran the program just to make sure. :D
  6. Copy the .manifest file from your Debug/Release folder to the Confused folder and Edit it using MageUI.
  7. On the "Files" section of MageUI, locate the Confused folder(may already be selected) and check the option to put .deploy on your files and click "Populate".
  8. Your project files would be renamed to *.deploy
  9. Save the .manifest file and sign it with the *TemporaryKey.pfx created when you published your project (This should be on your project folder).
  10. Copy the .application file from your Debug/Release folder to the Confused folder and Edit it using MageUI.
  11. On the "Application Reference" section of MageUI Click "Select Manifest.." and select the .manifest file you saved on step 6.
  12. Save the .application file and sign it with the *TemporaryKey.pfx.
  13. Lastly, this maybe optional, just copy the setup.exe and the publish.html files on publish folder to the Confused folder.

关于这个主题:

https://confuser.codeplex.com/discussions/428378

不幸的是,当我之后尝试安装 ClickOnce 应用程序时出现以下错误:

Cannot handle redirect from HTTP/HTTPS protocols to other dissimilar ones.

堆栈跟踪如下:

System.Net.HttpWebRequest.GetResponse() System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)

我正在尝试下载的 URL 是 https,是这个问题吗?我应该把所有的都放在 http 中吗?

要获得经过混淆处理的 ClickOnce 应用程序,请执行以下步骤:

  1. 编译您的项目并使用 Visual Studio 发布它(右键单击项目 > 发布)

一个。混淆步骤

  1. 发布后,使用 ConfuserEx(GUI 或 CLI)然后混淆您的可执行文件 and/or 您在特定文件夹中的 DLL(即:MyProject\Confused)
  2. 一旦您的代码被充分混淆(您可以使用 ILSpy 等工具检查您的混淆),请使用代码签名证书或使用临时 PFX(通常在您首次发布 clickonce 应用程序时创建)。我目前正在使用 signtool.exe 这样做。

  3. 仍然在您的 "Confused" 文件夹中,将经过混淆和签名的文件从 .exe 重命名为 .exe.deploy,从 .dll 重命名为 .dll.deploy

  4. 转到您发布的文件夹(在我的例子中,它是一个网络文件夹,如下所示:

\network_disk\ClickOnceApp

  1. Copy/Paste 在最近的 Application Files 文件夹中找到的 .deploy 文件

\network_disk\ClickOnceApp\Application Files\ClickOnceApp_x_x_x_x

乙。重新签署清单和 .application 文件

  1. 使用 MageUI 打开您的应用程序清单。就我而言:

\network_disk\ClickOnceApp\Application Files\ClickOnceApp_1_0_0_42\ClickOnceApp.exe.manifest

仅供参考,MageUI 可以在这里找到:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mageui.exe

点击"Save"签署清单(使用代码签名证书或你的临时PFX像以前一样),它会自动看到.exe.deploy和.dll.deploy的变化文件并重新计算正确的文件哈希值。

  1. 还是用MageUI,打开文件

\network_disk\ClickOnceApp\Application Files\ClickOnceApp_1_0_0_42\ClickOnceApp.application

在“应用程序引用”菜单上,单击 'Select a manifest' 并选择最近修改的清单。通过保存对您的 .application 文件进行签名(如第 7 步)

  1. 对以下文件执行相同的操作:

\network_disk\ClickOnceApp\ClickOnceApp.application

现在您的 ClickOnce 应用程序包含混淆代码,可以使用 ClickOnce 进程下载。


备注:

  • 就个人而言,我不得不在命令行中使用 ConfuserEx (ConfuserEx.CLI.exe),因为我必须混淆我的代码的一部分。混淆所有这些会 return 关于 WinForms 的组装和加载的许多错误。
  • 在命令行中使用它允许开发人员使用 Declarative Obfuscation,因此,仅混淆代码的一些关键部分。
  • 我结束了创建一个自动执行这些步骤的脚本。我仍在使用 mageUI.exe 对两个清单和应用程序文件进行签名,但您可以使用 mage.exe 在命令行中对这些文件进行签名(我还没有尝试过)。

这已经很老了,但我想提一下 Visual Studio 中有一个扩展可以使用 ConfuserEx,它可以与 ClickOnce 一起使用:

ConfuserEx Tools for Visual Studio

ConfuserEx for Visual Studio integrates the free and open source ConfuserEx protector into Visual Studio for easy automatic obfuscation of release builds and ClickOnce applications.

按照 Thordax 说明@第 3 步,

Once your code is sufficiently obfuscated (you can check your obfuscation with tools like ILSpy), sign your executable and/or your DLL with a code signing certificate, or with a temporary PFX (usually created when you first published your clickonce application). I'm currently using signtool.exe to do so.

您需要像这样使用签名工具: cd C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool

然后像这样签署 exe

signtool.exe sign /td sha256 /fd sha256 /f pathtoyourcert.pfx /p password pathtoyourconfusedexe