百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

DInvoke

> 编程语言
开源

在不使用 PInvoke 的情况下,从托管代码中动态调用任意未管理的代码。

791 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在不使用 PInvoke 的情况下,从托管代码中动态调用任意未管理的代码。

DInvoke

Dynamic replacement for PInvoke on Windows. DInvoke contains powerful primitives that may be combined intelligently to dynamically invoke unmanaged code from disk or from memory with careful precision. This may be used for many purposes such as PE parsing, intelligent dynamic API resolution, dynamically loading PE plugins at runtime, process injection, and avoiding API hooks.

Features:

  • Dynamically invoke unmanaged APIs without PInvoke
  • Primitives allowing for strategic API hook evasion
  • Manually map unmanaged PE modules from managed code
  • Map PE modules into sections backed by arbitrary modules on disk
  • Modular process injection API
  • Growing library of data structures, delegates, and function wrappers (please share :-)
  • .NET v3.5+ support

Conference talk (Staying # & Bringing Covert Injection Tradecraft to .NET): https://www.youtube.com/watch?v=FuxpMXTgV9s

Blog posts:

  1. Emulating Covert Operations - Dynamic Invocation (Avoiding PInvoke & API Hooks): https://thewover.github.io/Dynamic-Invoke/
  2. Coming soon.

This project was originally created for SharpSploit (https://github.com/cobbr/SharpSploit). With permission from the author(s), it is now hosted here as a standalone library and NuGet.

NuGet: https://www.nuget.org/packages/DInvoke/

Example 1 - Resolving Exported Unmanaged APIs

The example below demonstrates how to use DInvoke to dynamically find and call exports of a DLL.

  1. Get the base address of ntdll.dll. It is loaded into every Windows process when it is initialized, so we know that it will already be loaded. As such, we can safely search the PEB’s list of loaded modules to find a reference to it. Once we’ve found its base address from the PEB, we print the address.
  2. Use GetLibraryAddress to find an export within ntdll.dll by name.
  3. Use GetLibraryAddress to find an export within ntdll.dll by ordinal.
  4. Use GetLibraryAddress to find an export within ntdll.dll by keyed hash.
  5. Given the base address of ntdll.dll that we found earlier, use GetExportAddress to find an export within the module in memory by name.
…

Example 2 - Invoking Unmanaged Code

In the example below, we first call OpenProcess normally using PInvoke. Then, we will call it in several ways using DInvoke to demonstrate that each mechanism successfully executes the unmanaged code and evades API hooks.

…

To test that this evaded hooks, we will use the tool API Monitor v2 to hook kernel32.dll!OpenProcess. Then we will run the demo through API Monitor. You may observe which of our calls to OpenProcess were caught in hooks by watching for those that are called with the PROCESS_ALL_ACCESS flag. As you will see, API Monitor successfully catches the API call when it is performed with PInvoke. However, it does NOT succeed when we use DInvoke or Manual Mapping. You may watch the video on Vimeo to see this in action.

SharpSploit: Bypassing API Hooks via DInvoke and Manual Mapping

Credit

  • The Wover
  • FuzzySec (b33f)
  • cobbr

Issues· 18 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言