如何使用Peverify.exe(PEVerify工具)?

huangapple go评论53阅读模式
英文:

How to use Peverify.exe (PEVerify tool)?

问题

我看到了一些帖子(尤其是这个帖子),讨论了如何使用 peverify.exe 来检查 .net exe(或 dll)是否包含不安全的代码。但无论我怎么做,我都一直收到“文件未找到或具有错误的标头”错误。

以下是我的步骤 -

  1. 打开 2022 年的开发者 PowerShell - 请注意,我没有更改 exe 所在的路径。
  2. peverify <dll 或 exe 的完整路径>
  3. 输入

我一直收到“文件未找到或具有错误的标头”错误。这应该很简单,但我似乎漏掉了什么?


其他尝试 使用不同的命令,但结果相同,如下所示

  1. peverify.exe <exe/dll 的完整路径> /md /il
  2. 尝试在 Visual Studio 2022 的开发者命令提示符中运行相同命令
英文:

I saw a couple of post(this post specifically) talking about using peverify.exe to check whether the .net exe(or dll) contains unsafe code. But no matter what I do I keep getting File not found or has bad headers error.

Here are my steps -

  1. Open developer power shell for 2022 - Note I did not change the path
    to where the exe is.
  2. peverify &lt;complete path of the dll or exe&gt;
  3. Enter

I keep getting File not found or has bad headers error. This should be simple yet there is something I am missing?


Other attempts with different command with same result is as follows

  1. peverify.exe <complete path of the exe/dll> /md /il
  2. Tried running the same in Developer Command Prompt for visual studio
    2022

答案1

得分: 1

PEVerify适用于“旧版”Windows特定的.NET Framework。针对.NET 5+和.NET Core创建了一个更新的工具(尽管它也适用于旧的.NET Framework),ILVerify

要安装和运行(从README中复制,以便此信息在此处而不容易失效):

ILVerify被发布为全局工具包。通过运行以下命令来安装它:

dotnet tool install --global dotnet-ilverify

使用示例:

C:\test>dotnet ilverify hello.dll -r "c:\Program Files\dotnet\shared\Microsoft.NETCore.App.1.12\*.dll"
C:\test\hello.dll中的所有类和方法已经验证。

请注意,ILVerify要求明确在命令行上指定要验证的程序集的所有依赖项。

包本身位于NuGet.org上的dotnet-ilverify链接)。

英文:

PEVerify is for the "old" Windows-specific .NET Framework. A newer tool was created for .NET 5+ and .NET Core (although it also works with the old .NET Framework), ILVerify.

To install and run (copying from the README, so this information is here instead of susceptible to link rot):

> ILVerify is published as a global tool package. Install it by running:
>
>
&gt; dotnet tool install --global dotnet-ilverify
&gt;

>
> Example of use:
>
>
&gt; C:\test&gt;dotnet ilverify hello.dll -r &quot;c:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.12\*.dll&quot;
&gt; All Classes and Methods in C:\test\hello.dll Verified.
&gt;

>
> Note that ILVerify requires all dependencies of assembly that is being verified to be explicitly specified on the command line.

The package itself is dotnet-ilverify on NuGet.org (here).

huangapple
  • 本文由 发表于 2023年7月14日 05:21:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683312.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定