我尝试使用Dotpeek和ILSpy.Net进行反编译(我自己的代码),但失败了。
我是否需要对.Net Core 3 self-contained single executable的分布式二进制文件进行特殊的混淆?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
单文件exe实际上是非托管包装程序,ILSpy不支持对此进行反编译。但是,当您运行exe时,它会将其内容解包到temp文件夹中。因此,您可以在那里找到托管的dll并使用ILSpy对其进行反编译。
要查找临时文件夹,可以使用任何工具显示进程加载的程序集的位置。 SysInternals过程监视器(procmon)是一个很好的监视器。
您可以设置procmon以按您的exe名称进行过滤,并且在启动exe时,procmon应该显示一些有关从临时文件夹中加载的程序集的事件:
您可以浏览到该文件夹并在此处找到您的托管dll。您可以从该位置使用ILSpy进行反编译。
我写了一个博客文章:https://eersonmez.blogspot.com/2020/02/ilspy-decompiling-net-core-self.html