Files
2025-09-25 03:56:33 +08:00

12 lines
1019 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### DLL 劫持原理
Windows 系统在加载一个程序所需的 DLL 文件时,会遵循一个固定的搜索路径。这个路径通常包括:
1. **程序所在目录**:这是优先级最高的。系统会首先在可执行文件所在的文件夹内查找所需的 DLL。
2. **系统目录**:如 `C:\Windows\System32`
3. **16 位系统目录**`C:\Windows\System`
4. **Windows 目录**`C:\Windows`
5. **当前工作目录**:程序启动时所在的目录。
6. **环境变量 `PATH` 中指定的目录**
**DLL 劫持**正是利用了第一条规则。很多软件在编程时,并没有指定所需 DLL 的绝对路径,而是依赖于系统的默认搜索顺序。如果攻击者知道某个程序需要加载一个名为 `abc.dll` 的文件,他们就可以制作一个同名的恶意 DLL,并将其放置在程序所在的文件夹中。当用户双击运行这个程序时,系统会优先加载这个恶意的 `abc.dll`,而不是位于系统目录中的合法 DLL