主题
注入DLL - Inject
函数简介
向指定窗口进程注入DLL文件,支持多种注入类型和绕过保护选项。
接口名称
InjectDLL调用
c
int32_t Inject(int64_t instance, int64_t hwnd, const char* dll_path, int32_t type, int32_t bypassGuard);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| hwnd | 长整数型 | 目标窗口句柄, 可以通过SetMemoryHwndAsProcessId接口设置成传入进程ID。 |
| dll_path | 字符串 | DLL文件的完整路径。 |
| type | 整数型 | 注入类型:1 标准注入(CreateRemoteThread),2 驱动注入模式1,3 驱动注入模式2,4 驱动注入模式3。 |
| bypassGuard | 整数型 | 是否绕过保护:0 不绕过,1 尝试绕过常见反注入保护。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.Inject(pid, "C:\\tools\\helper.dll");csharp
using OLAPlug;
var ola = new OLAPlugServer();
ola.Inject(pid, "C:\\tools\\helper.dll");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ola.Inject(pid, "C:\\tools\\helper.dll")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.Inject(pid, "C:\\tools\\helper.dll");cpp
var ola = com("OlaPlug.OlaSoft")
ola.Inject(pid, "C:\\tools\\helper.dll");vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.Inject(pid, "C:\\tools\\helper.dll");text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.Inject(pid, "C:\\tools\\helper.dll")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.Inject(pid, "C:\\tools\\helper.dll");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.Inject(pid, "C:\\tools\\helper.dll");cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.Inject(pid, "C:\\tools\\helper.dll");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
Inject(instance, pid, "C:\\tools\\helper.dll");csharp
long instance = CreateCOLAPlugInterFace();
Inject(instance, pid, "C:\\tools\\helper.dll");python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
Inject(instance, pid, "C:\\tools\\helper.dll")返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 路径 | DLL文件必须存在且路径正确。 |
| 权限 | 目标进程必须有足够的权限允许注入。 |
| 不同注入类型的成功率和兼容性可能不同 | 不同注入类型的成功率和兼容性可能不同。 |
| 标准注入(type=0)最稳定 | 标准注入(type=0)最稳定,但容易被检测。 |
| 手动映射注入(type=3)隐蔽性最好 | 手动映射注入(type=3)隐蔽性最好,但兼容性较差。 |
| 绕过保护选项可能无法对抗所有反注入机制 | 绕过保护选项可能无法对抗所有反注入机制。 |
| 管理员权限 | 注入系统进程或受保护进程需要管理员权限。 |
| 32位进程只能注入32位DLL | 32位进程只能注入32位DLL,64位进程只能注入64位DLL。 |
| 在注入前确认DLL的架构与目标进程匹配 | 建议在注入前确认DLL的架构与目标进程匹配。 |
| 注入失败可能导致目标进程崩溃 | 注入失败可能导致目标进程崩溃,请谨慎使用。 |
| 某些杀毒软件可能会拦截DLL注入操作 | 某些杀毒软件可能会拦截DLL注入操作。 |
