fortra/No-Consolation
GitHub: fortra/No-Consolation
一个 Cobalt Strike BOF,可在 Beacon 内存中内联执行非托管 PE 文件并捕获输出,无需创建新进程或控制台。
Stars: 682 | Forks: 84
# 无慰藉
这是一个 Beacon Object File (BOF),它以内联方式执行非托管 PE 文件,并在不分配控制台(即不生成 `conhost.exe`)的情况下获取其输出。

## 功能特性
- 支持 64 位和 32 位
- 支持 EXE 和 DLL
- 不创建新进程
- 不创建新线程
- 将模块链接到 PEB
- 将二进制文件保存在内存中
- 支持 C++ 异常(仅限 x64)
- 自定义加载所有依赖项
## 用法
```
Summary: Run an unmanaged EXE/DLL inside Beacon's memory.
Usage: noconsolation [--local] [--inthread] [--link-to-peb] [--dont-unload] [--timeout 60] [-k] [--method funcname] [-w] [--no-output] [--alloc-console] [--close-handles] [--free-libraries wininet.dll,winhttp.dll] [--dont-save] [--list-pes] [--unload-pe pename] [--load-all-dependencies] [--load-all-dependencies-but advapi32.dll] [--load-dependencies wininet.dll] [--search-paths C:\Windows\Temp\] /path/to/binary.exe arg1 arg2
--local, -l Optional. The binary should be loaded from the target Windows machine
--inthread, -it Optional. Run the PE with the main thread. This might hang your beacon depending on the PE and its arguments.
--link-to-peb, -ltp Optional. Load the PE into the PEB
--dont-unload, -du Optional. If set, the DLL won't be unloaded.
--timeout NUM_SECONDS, -t NUM_SECONDS Optional. The number of seconds you wish to wait for the PE to complete running. Default 60 seconds. Set to 0 to disable
-k Optional. Overwrite the PE headers
--method EXPORT_NAME, -m EXPORT_NAME Optional. Method or function name to execute in case of DLL. If not provided, DllMain will be executed
-w Optional. Command line is passed to unmanaged DLL function in UNICODE format. (default is ANSI)
--no-output, -no Optional. Do not try to obtain the output
--alloc-console, -ac Optional. Allocate a console. This will spawn a new process
--close-handles, -ch Optional. Close Pipe handles once finished. If PowerShell was already ran, this will break the output for PowerShell in the future
--free-libraries, -fl DLL_A,DLL_B Optional. List of DLLs (previously loaded with --dont-unload) to be offloaded
--dont-save, -ds Optional. Do not save this binary in memory
--list-pes, -lpe Optional. List all PEs that have been loaded in memory
--unload-pe PE_NAME, -upe PE_NAME Optional. Unload from memory a PE
--load-all-dependencies, -lad Optional. Custom load all the PE's dependencies
--load-all-dependencies-but, -ladb DLL_A,DLL_B Optional. Custom load all the PE's dependencies except these
--load-dependencies, -ld DLL_A,DLL_B Optional. Custom load these PE's dependencies
--search-paths, -sp PATH_A,PATH_B Optional. Look for DLLs on these paths (system32 is the default)
/path/to/binary.exe Required. Full path to the windows EXE/DLL you wish you run inside Beacon. If already loaded, you can simply specify the binary name.
ARG1 ARG2 Optional. Parameters for the PE. Must be provided after the path
Example: noconsolation --local C:\windows\system32\windowspowershell\v1.0\powershell.exe $ExecutionContext.SessionState.LanguageMode
Example: noconsolation /tmp/mimikatz.exe privilege::debug token::elevate exit
Example: noconsolation --local C:\windows\system32\cmd.exe /c ipconfig
Example: noconsolation --list-pes
Example: noconsolation LoadedBinary.exe args
```
## 将二进制文件加载到内存
二进制文件在首次运行后会自动加密并存储在内存中。这意味着您不需要通过网络不断发送二进制文件。
要执行已保存在内存中的二进制文件,只需指定其名称而非完整路径。因此,与其运行:
```
beacon> noconsolation --local C:\windows\system32\cmd.exe /c ipconfig
```
不如运行:
```
beacon> noconsolation cmd.exe /c ipconfig
```
要列出内存中加载的所有二进制文件,请运行 `--list-pes`。
如果您不再需要某个二进制文件并希望将其卸载,请运行 `--unload-pe mimikatz.exe`。
最后,如果您想运行一个二进制文件但不希望其自动加载到内存中,请使用 `--dont-save` 参数运行。
## 加载 PE 的依赖项
您可以通过自定义加载 PE 的所有依赖项来避免所有镜像加载事件:
```
beacon> noconsolation --load-dependencies --link-to-peb /tmp/malware.exe
```
执行完成后,PE 及其依赖项将被自动卸载。
不支持使用线程本地存储 (Thread Local Storage) 的 DLL。
## 致谢
- [Octoberfest7](https://twitter.com/octoberfest73) 的 [Inline-Execute-PE](https://github.com/Octoberfest7/Inline-Execute-PE) 是本项目的灵感来源
- [modexp](https://twitter.com/modexpblog) 和 [TheWover](https://twitter.com/TheRealWover) 提供了来自 [donut](https://github.com/TheWover/donut) 的 PE 加载逻辑
- [rad9800](https://twitter.com/rad9800) 的 [HWBP engine](https://github.com/rad9800/hwbp4mw)
- [batsec](https://twitter.com/_batsec_) 的 [DarkLoadLibrary](https://github.com/bats3c/DarkLoadLibrary)
- [aidankhoury](https://twitter.com/aidankhoury) 的 [ApiSet](https://github.com/ajkhoury/ApiSet)
- [bb107](https://github.com/bb107) 的 [MemoryModulePP](https://github.com/bb107/MemoryModulePP)
标签:BOF, Cobalt Strike, Cowrie, Debian模拟, DLL 劫持, DNS 反向解析, EDR 绕过, LLM, OpenAI, QEMU, Raspberry Pi, RFI远程文件包含, SCP, SFTP, Shell模拟, SSH蜜罐, Telnet蜜罐, UML, Unmanaged PE, Windows 安全, 中高交互蜜罐, 代理, 免杀技术, 内存执行, 内存规避, 内联执行, 反射式注入, 大语言模型, 客户端加密, 客户端加密, 恶意文件捕获, 恶意软件开发, 攻击诱捕, 文件系统模拟, 无控制台执行, 无文件攻击, 暴力破解检测, 欺骗防御, 端点可见性, 行为分析, 进程注入