reveng007/DarkWidow

GitHub: reveng007/DarkWidow

一款集成了多种 EDR 规避技术的可定制 Windows 木马加载器,通过间接动态系统调用和进程注入等方式实现终端防护绕过。

Stars: 794 | Forks: 105

# DarkWidow 一款针对 Windows 的可定制木马加载器工具。 ### 特别致谢: 1. [BlackHat Asia, 2024 - Call For Tools](https://www.blackhat.com/asia-24/arsenal/schedule/presenters.html#soumyanil-biswas-47163) 2. [BlackHat USA, 2024 - Call For Tools](https://www.blackhat.com/us-24/arsenal/schedule/presenters.html#soumyanil-biswas-47163) 3. [BlackHat SecTor, 2024 - Call For Tools](https://www.blackhat.com/sector/2024/arsenal/schedule/presenters.html#soumyanil-biswas-47163) 4. [BlackHat Europe, 2024 - Call For Tools](https://www.blackhat.com/eu-24/arsenal/schedule/index.html#darkwidow-customizable-dropper-tool-targeting-windows-41187) 5. [Wild West Hacking Fest 2024 - Arsenal](https://wildwesthackinfest.com/agenda-for-wwhf-2024-deadwood/) - 非常感谢 Soumyadeep Da aka [@SoumyadeepBas12](https://twitter.com/SoumyadeepBas12) 鼓励我申请这些会议,否则我是不会去做的 :) - 非常感谢 Faran aka [@Chrollo_l33t]() 帮助我为这个工具的演示制作了幻灯片和 PPT :) ### 功能特性: 1. 间接动态系统调用 (Indirect Dynamic Syscall)。(MITRE ATT&CK TTP: [T1106](https://attack.mitre.org/techniques/T1106/)) 2. 通过改进的 TartarusGate 方法进行 SSN + 系统调用地址排序 3. 通过 APC Early Bird 进行远程进程注入,以切断 EDR 的遥测捕获。((**MITRE ATT&CK TTP: [T1055.004](https://attack.mitre.org/techniques/T1055/004/)**) 4. 生成一个牺牲进程作为目标进程,不会中断环境中已打开的进程。 5. 在生成的牺牲进程上应用 ACG(Arbitrary Code Guard)/BlockDll 缓解策略。 6. PPID 欺骗 (**MITRE ATT&CK TTP: [T1134.004](https://attack.mitre.org/techniques/T1134/004/)**) 7. 通过 TIB 解析 Api 和 Dll (直接通过偏移量 (从 TIB) -> TEB -> PEB -> 解析 Nt Api) (**MITRE ATT&CK TTP: [T1106](https://attack.mitre.org/techniques/T1106/)**) 8. 诅咒 Nt API 哈希 (MITRE ATT&CK ID: [S0574](https://attack.mitre.org/software/S0574/)) ### 附加功能:如果幸运地拥有了管理员权限 => 1. 通过_杀死_ EventLog 服务线程来禁用事件日志 (**MITRE ATT&CK TTP: [T1562.002](https://attack.mitre.org/techniques/T1562/002/)**) **因此,想到了直接杀掉它们!** #### 在间接系统调用植入物中仅仅杀掉那些线程时,遇到了一个错误。我无法获取 "**eventlog**" 的 _SubProcessTag 值_。因此想到了杀掉所有线程,即杀掉整个进程(负责的 **svchost.exe**)。没错,这就是在制造 ***IOC***!。 ### = ### 1. EDR/Ring-3/UserLand Hook 绕过 ### 2. 系统调用和返回语句从 ntdll.dll 的内存中执行 ### 3. 基于检查调用堆栈中的返回地址的 EDR 检测可以被绕过。 ### 编译: 1. ``` Directly via VS compiler: ``` ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/80f9d84b15183811.png) #### 同时添加 **/MT** 编译器标志!=> 将 CRT 函数静态链接到二进制文件中(是的,你猜对了,这会使植入物变得臃肿) ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/a171923f79183824.png) 2. 也可以通过 compile.bat 编译(首选选项 1.) ``` ./compile.bat ``` ### 用法: ``` PS C:> .\x64\Release\indirect.exe [!] Wrong! [->] Syntax: .\x64\Release\indirect.exe ``` ### 实战演示: https://github.com/reveng007/DarkWidow/assets/61424547/62a90c5b-84af-4389-8ddc-9f7926debdcf ### 在 Sophos XDR 终端上成功执行且未触发警报: ![SofosXDREvade](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/d4a1a7159b183856.png) ### 进一步改进: 1. PPID 欺骗(**Emotet 方法**) 2. ***更隐蔽的*** 禁用事件日志的用例! ### 代码片段及参考链接: 1. TIB: - https://en.wikipedia.org/wiki/Win32_Thread_Information_Block - https://www.wikiwand.com/en/Win32_Thread_Information_Block 2. GS 和 FS 寄存器: - https://stackoverflow.com/questions/39137043/what-is-the-gs-register-used-for-on-windows - https://stackoverflow.com/questions/10810203/what-is-the-fs-gs-register-intended-for#:~:text=The%20registers%20FS%20and%20GS,to%20access%20thread%2Dspecific%20memory. 3. PEB LDR 结构: - [BlackHat - What Malware Authors Don't Want You to Know - Evasive Hollow Process Injection](https://www.youtube.com/watch?v=9L9I1T5QDg4&t=205s) 作者:[@monnappa22](https://twitter.com/monnappa22) - 来自上述链接的进程内存图片:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/1.png) - 来自 [labs.cognisys.group](https://labs.cognisys.group/posts/Combining-Indirect-Dynamic-Syscalls-and-API-Hashing/#retrieving-apis-base-address),[@D1rkMtr ](https://twitter.com/D1rkMtr) 的博客:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/2.png) 4. TIB -> TEB -> PEB -> 解析 Nt API 和 API 哈希 - https://stackoverflow.com/questions/41277888/iterating-over-peb-dllname-shows-only-exe-name - https://doxygen.reactos.org/d7/d55/ldrapi_8c_source.html#l01124 - [labs.cognisys.group](https://labs.cognisys.group/posts/Combining-Indirect-Dynamic-Syscalls-and-API-Hashing/#retrieving-apis-base-address),[@D1rkMtr ](https://twitter.com/D1rkMtr) 的博客 - 来自上述链接的代码片段图片,我在这里用它来动态解析 API 而无需硬编码偏移量:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/3.png) - 我应用的 Api 哈希代码: ``` #include #include #include DWORD64 djb2(const char* str) { DWORD64 dwHash = 0x7734773477347734; int c; while (c = *str++) dwHash = ((dwHash << 0x5) + dwHash) + c; return dwHash; } int main(int argc, char** argv) { if (argc < 2) { printf("[!] Wrong!\n"); printf("[->] Syntax: .\\%s \n\n", argv[0]); return 1; } const char* string = argv[1]; DWORD64 hashvalue = djb2(string); printf("Hash Value: 0x%llX\n", hashvalue); return 0; } ``` 5. ACG(Arbitrary Code Guard)/BlockDll 缓解策略: - 链接: - [Protecting Your Malware](https://blog.xpnsec.com/protecting-your-malware/) 作者:[@_xpn_](https://twitter.com/_xpn_) - [Wraith](https://github.com/reveng007/AQUARMOURY/blob/1923e65190875f7c61c76fb430d526e5deaa062a/Wraith/Src/Injector.h) 作者:[@winterknife](https://twitter.com/_winterknife_) - [spawn](https://github.com/boku7/spawn) 和 [HOLLOW](https://github.com/boku7/HOLLOW) 作者:[@0xBoku](https://twitter.com/0xBoku) ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/4.png) 6. PPID 欺骗检测: - [PPID Spoofing Detect](https://www.ired.team/offensive-security/defense-evasion/parent-process-id-ppid-spoofing) 作者:[@spotheplanet](https://twitter.com/spotheplanet) - 如果有时间,我会在这个部分添加一个检测部分! -> _[待完成..............................................!]_ 7. Moneta 检测和 PESieve 检测:\ - **Moneta**:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/5.png) - **PESieve**:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/6.png) 8. Capa 扫描:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/7.png) 9. 植入物进程的线程堆栈外观: | 植入物进程 | 合法的 Cmd 进程 | | ---------------- | ---------------- | | ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/8.png) | ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/9.png) | 10. Instrumentation CallBack 规避:使用了 [winternl_t](https://twitter.com/winternl_t) 的这个 [POC - syscall-detect](https://github.com/jackullrich/syscall-detect) ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/7e65304891184015.png) 11. 我使用的 EventLogger 配置: ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/10.png) ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/11.jpg) 13. 设置 SeDebugPrivilege:\ **从** 这里: ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/11.png) **到** 这里: ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/12.png) 14. 杀死事件日志线程: - [rto-win-evasion](https://institute.sektor7.net/rto-win-evasion) 作者:[@SEKTOR7net](https://twitter.com/Sektor7Net) - [Phant0m](https://github.com/hlldz/Phant0m) 作者:[@hlldz](https://twitter.com/hlldz) - [Goblin](https://github.com/reveng007/AQUARMOURY/blob/master/Goblin/Src/EventLog.h) 作者:[@winterknife](https://twitter.com/_winterknife_) - [disabling-windows-event-logs-by-suspending-eventlog-service-threads](https://www.ired.team/offensive-security/defense-evasion/disabling-windows-event-logs-by-suspending-eventlog-service-threads) 作者:[@spotheplanet](https://twitter.com/spotheplanet)\ **从** 这里:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/13.png)\ **到** 这里:\ ![alt text](https://github.com/reveng007/DarkWidow/blob/main/img/14.png) - **此方法在间接系统调用实现中最终导致了错误。因此,我最终杀死了负责的 svchost.exe 中存在的所有线程**(原因:[往上翻](https://github.com/reveng007/DarkWidow/edit/main/README.md#bonus-if-blessed-with-admin-privilege-))。 ### Sophos XDR 事件日志场景: 1. 情况 1:当 Darkwidow 在普通权限下执行时 ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/728b84f1a8184104.png) 2. 情况 2:当 Darkwidow 在管理员权限下执行时 ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/74de2a0de3184117.png) ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/26434f8b42184131.png) ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/58a80d38fd184144.png) # DarkWidow V2: #### 为了规避这种事件日志检测,我在其中加入了 `合成帧线程堆栈欺骗 (Synthetic Frame Thread Stack Spoofing)` 的概念。 这是应用合成帧线程堆栈欺骗后的堆栈外观。 ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/bcbc0838bd184158.png) ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/a25c253dc5184212.png) 为了 shellcode 的开发,我使用了 havoc 以及以下配置: ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/b77a49e8de184224.png) ### 注意: 在这个项目中,新创建的线程起始地址欺骗其实并不是必需的,因为在 APC 注入技术中,APC 会劫持已经合法运行的线程的执行。感谢 [@C5pider](https://twitter.com/C5pider)! ### 演示执行截图: ![1708744707672](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/4fb280b316184241.jpg) ### 针对 Sophos XDR 的演示视频: [![演示视频 Youtube 链接](https://raw.githubusercontent.com/reveng007/DarkWidow/main/_URL_40/>)](https://www.youtube.com/watch?v=HqtXD3CJg9k) 现在事件日志的状态如何? ![image](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/720cb4963f184300.png) ### 我的 BlackHat Arsenal 演示视频可以在这里找到: [![演示视频 Youtube 链接](https://img.youtube.com/vi/1mserrlZHEE/0.jpg)](https://www.youtube.com/watch?v=1mserrlZHEE) ### 我的 WildWestHackinFest 演示幻灯片和视频链接可以在这里找到: 1. [Google 幻灯片链接](https://docs.google.com/presentation/d/1Qel94kLSzSctwe8BeYCCo5yZAijtjZqzg7uC2HIbkFQ/edit?usp=sharing) 2. https://www.youtube.com/watch?v=xsibDZ6BpyA&t=1295s ### 未来的更新计划: 1. 将此版本移植到 C++ Clang 编译器,这将有助于我们执行 LLVM 混淆。 2. 升级至 NtCreateUserProcess() 以执行间接系统调用和堆栈欺骗。 3. 应用手动加载库 功能以绕过映像加载内核回调。 4. 应用模块踩踏 功能。 5. 加密的 shellcode 注入,以避免内核触发的内存扫描 ([Caro-Kann](https://github.com/S3cur3Th1sSh1t/Caro-Kann))。 ### 堆栈欺骗技术的检测(正如在我的其中一场研讨会/演讲中提到的): image ### 特别感谢(直接/间接(双关语无意 :)))帮助过我的人: 1. [@SEKTOR7net](https://twitter.com/Sektor7Net) 2. [@peterwintrsmith](https://twitter.com/peterwintrsmith) 3. [@Jean_Maes_1994](https://twitter.com/Jean_Maes_1994) 4. [@D1rkMtr](https://twitter.com/D1rkMtr) 5. [@spotheplanet](https://twitter.com/spotheplanet) 6. [@0xBoku](https://twitter.com/0xBoku) 7. [@Sh0ckFR](https://twitter.com/Sh0ckFR) 8. [@winterknife](https://twitter.com/_winterknife_) 9. [@monnappa22](https://twitter.com/monnappa22) 10. [@_xpn_](https://twitter.com/_xpn_) 11. [@hlldz](https://twitter.com/hlldz) 12. [@d_tranman ](https://twitter.com/d_tranman) 13. [@SoumyadeepBas12](https://twitter.com/SoumyadeepBas12) 14. [@jack_halon](https://twitter.com/jack_halon) 15. [@KlezVirus](https://twitter.com/KlezVirus) 16. [@C5pider](https://twitter.com/C5pider) 希望我没有遗漏任何人! ### 这个项目是我学习 EDR 世界的旅程的一部分!=> [Learning-EDR-and-EDR_Evasion](https://github.com/reveng007/Learning-EDR-and-EDR_Evasion)
标签:ACG, APC注入, API Hashing, API解析, Arbitrary Code Guard, BlackHat, BlockDll, C++, Dropper, Early Bird APC注入, Loader, PEB, SSH蜜罐, SSN解析, TartarusGate, TIB解析, UML, 动态系统调用, 协议分析, 客户端加密, 恶意软件, 数据展示, 数据擦除, 权限提升, 父进程ID欺骗, 牺牲进程, 私有化部署, 端点可见性, 红队, 绕过EDR, 进程 mitigations, 进程注入, 遥测绕过, 间接系统调用, 防御规避