Skip to content

A 32-bit process injects 64-bit shellcode into a 64-bit process, and a 64-bit process injects a 32-bit DLL into a 32-bit process.

Notifications You must be signed in to change notification settings

onedays12/CrossInject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

介绍

这是一个在研究跨位数注入时诞生的实验性demo。正常来说,Windows环境只允许同架构注入,特别是32位程序使用 CreateRemoteThreadRtlCreateUserThreadNtCreateThreadEx 注入到64位进程时,程序会直接崩溃(64位进程注入32位shellcode时到32位进程时例外),但只需要使用一些特殊的手段即可完成32进程注入64位shellcode到64位进程,64位进程注入32位dll到32位进程中。

对于32->64的特殊手段是:用到了两个特别的stub,第一个stub完成CPU短长模式切换,第二个stub完成GetProcAddressByHash的功能。

对于64->32的特殊手段是:一个程序使用 GetModuleHandleA+GetProcAddress 获取到的 LoadLibraryW 的地址是基于程序的架构的,比如说64位程序获取到的就是64位的 LoadLibraryW ,64位程序使用上述的方法是没办法获取到32位的LoadLibraryW,所以为了实现64->32 注入dll,需要自己实现类似 GetModuleHandleA+GetProcAddress 的功能。

使用说明

从Github下载本项目后,双击 CrossInject.sln(需要有VS环境)。

首先是测试 32InjectTo64 的程序。

PixPin_2025-12-01_18-26-31.png

接下来测试 64InjectTo32 的程序。在测试之前需要自备一个恶意dll,本项目中使用 Dll_32 的dll作为测试用例,该dll的功能是弹出一个对话框。

一切准备就绪后,运行

PixPin_2025-12-01_18-41-15.png

注意⚠:当你成功注入DLL后,想要再一次对同一个目标进程注入dll时没有出现弹窗,这是因为DLL已经加载到目标进程的内存空间了,所以不会触发DLL里 DLL_PROCESS_ATTACH 里的执行逻辑。

PixPin_2025-12-01_18-41-57.png

更多细节

如果你对跨位数注入的实现原理感兴趣或者想了解更多细节,请阅读我写的这篇文章:

我的博客:https://onedays12.github.io/

参考

  1. metasploit-framework/external/source/shellcode/windows/x86/src/migrate/executex64.asm at master · rapid7/metasploit-framework
  2. metasploit-framework/external/source/shellcode/windows/x64/src/migrate/remotethread.asm at master · rapid7/metasploit-framework
  3. wow64ext v1.0.0.8 – ReWolf 的博客
  4. NTAPI Undocumented Functions
  5. 关于64位进程注入32位进程的分析 | xia0ji233's blog

About

A 32-bit process injects 64-bit shellcode into a 64-bit process, and a 64-bit process injects a 32-bit DLL into a 32-bit process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages