totekuh/winbox

GitHub: totekuh/winbox

在Kali上透明运行Windows渗透测试工具的QEMU/KVM虚拟化方案,实现Windows可执行文件的原生CLI体验。

Stars: 0 | Forks: 0

# winbox 在 Kali 上透明地运行 Windows 渗透测试工具。 winbox 通过 QEMU/KVM 管理一个无界面的 Windows Server Core 2022 虚拟机。在你的 Kali 主机上输入 `winbox exec SharpHound.exe -c All -d corp.local`,一切即可正常运行 —— 虚拟机会自动启动、执行命令并打印输出。 ## 快速演示 ``` $ winbox setup -y # one-time: builds the VM (~20 min) $ winbox tools add Rubeus.exe SharpHound.exe # drop in your tools $ winbox exec Rubeus.exe kerberoast /domain:corp.local [*] VM is off, starting... [+] VM ready [*] Running: Rubeus.exe kerberoast /domain:corp.local ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ ... $ winbox exec --bg --log Seatbelt.exe -group=all # run in background [+] Job 1 started (PID 4532) $ winbox shell # SYSTEM shell with full PTY PS C:\Windows\system32> ``` ## 功能特性 - **透明执行** —— 像运行原生 Kali 命令一样运行 `.exe` 文件 - **自动启动** —— 虚拟机按需启动,使用 `winbox suspend` 保存状态 - **共享文件系统** —— `~/.winbox/shared/tools/` 通过 VirtIO-FS 映射到 Windows 的 `Z:\tools\` - **后台任务** —— 使用 `--bg` 运行长时间工具,使用 `--log` 获取持久化输出 - **交互式 Shell** —— 支持调整大小的 ConPTY SYSTEM Shell,或通过 SSH 连接 PowerShell - **网络集成** —— 虚拟机流量通过 Kali 进行 NAT;可推送 DNS、管理 hosts 文件、加入 AD 域 - **快照** —— 保存并恢复虚拟机状态 - **binfmt_misc** —— 注册 `.exe` 以便直接从 Kali 运行 `./SharpHound.exe` - **安装无需虚拟机联网** —— 所有工具和依赖均从主机端部署 ## 前置条件 在 Kali 上安装(大部分已预装): ``` sudo apt install qemu-system-x86 qemu-utils libvirt-daemon-system virtinst \ libguestfs-tools virtiofsd p7zip-full genisoimage sshpass wget ``` 必需项: - `qemu-system-x86_64`, `qemu-img`, `virsh`, `virt-install`, `virt-customize` - `7z` (p7zip-full) - `virtiofsd` (位于 `/usr/libexec/virtiofsd` 或 PATH 中) - `/dev/kvm` (必须启用硬件虚拟化) - `mkisofs` 或 `genisoimage` - `wget` - `default` libvirt 网络 (处于活动状态) 可选项: - `sshpass` —— 用于 `winbox ssh` 的自动认证 (若缺失则回退到手动输入密码) - `virt-manager` —— `winbox vnc` (虚拟机显示) 所需 ## 安装 ``` git clone https://github.com/totekuh/winbox.git cd winbox pip install -e . ``` 然后构建虚拟机 (下载 Windows Server 2022 评估版 ISO + VirtIO 驱动): ``` winbox iso download # ~4.7 GB, supports resume winbox setup -y # builds and provisions the VM ``` ## 用法 ### 执行命令 ``` winbox exec whoami winbox exec ipconfig /all winbox exec Rubeus.exe kerberoast /domain:corp.local winbox exec --timeout 300 SharpHound.exe -c All # --timeout must come BEFORE the command ``` 如果虚拟机未运行,它会自动启动。 ### 后台任务 长时间运行的工具可以在后台执行: ``` winbox exec --bg Seatbelt.exe -group=all # output buffered in guest agent memory winbox exec --bg --log Certify.exe find /vulnerable # output redirected to log files (tail -f) winbox jobs list # check status winbox jobs output # print output winbox jobs kill # kill a running job ``` 使用 `--log` 时,输出文件位于 `~/.winbox/shared/loot/.jobs/.stdout` 和 `.stderr`。 ### 交互式 Shell ``` winbox shell # ConPTY reverse shell — runs as SYSTEM, supports terminal resize winbox ssh # SSH into PowerShell (auto-auth via sshpass) ``` ### 管理工具 放置在共享目录中的工具可在虚拟机的 `Z:\tools\` 下访问,并自动添加到 PATH: ``` winbox tools add Rubeus.exe SharpHound.exe Certify.exe winbox tools list winbox tools remove Rubeus.exe ``` ### 网络 ``` # DNS winbox dns view # show DNS on Kali and VM winbox dns set 10.10.10.2 # set VM DNS nameserver winbox dns sync # push Kali's resolv.conf nameservers to VM # Hosts 文件 winbox hosts view winbox hosts add 10.10.10.5 dc01.corp.local winbox hosts set 10.10.10.5 dc01.corp.local # idempotent — replaces existing entry winbox hosts delete dc01.corp.local # Active Directory winbox domain join corp.local --ns 10.10.10.2 --user admin # 交互式提示输入密码 winbox domain leave ``` ### 虚拟机生命周期 ``` winbox up # start or resume winbox down # graceful shutdown winbox suspend # save state to disk (instant resume) winbox status # state, IP, disk usage, tool/loot counts winbox destroy -y # delete VM and all storage winbox provision # re-run provisioning script ``` ### 快照 ``` winbox snapshot pre-attack # ... 执行您的操作 ... winbox restore pre-attack # revert to clean state ``` ### 安装 Office 为了测试基于宏的 Payload,请在 Desktop Experience 版本的虚拟机上安装 Office: ``` winbox setup --desktop -y # build VM with Desktop Experience winbox office # install Word, Excel, PowerPoint with macros enabled ``` 需要 Microsoft 365 订阅。Word、Excel 和 PowerPoint 的宏功能已启用 (VBAWarnings=1)。 ### 透明执行 .exe (binfmt_misc) 注册一个 binfmt_misc 处理程序,以便 `.exe` 文件自动通过 winbox 运行: ``` sudo winbox binfmt enable ./SharpHound.exe -c All # runs via winbox exec sudo winbox binfmt disable winbox binfmt status ``` ## 架构 ``` Kali Linux ├── winbox CLI (Python/Click) │ ├── virtio-serial ──────> QEMU Guest Agent (command execution, VM management) │ ├── VirtIO-FS ──────────> ~/.winbox/shared/ <=> Z:\ in VM │ ├── SSH ────────────────> OpenSSH Server (interactive PowerShell) │ └── TCP listener ───────< ConPTY reverse shell (SYSTEM, resizable PTY) │ └── Windows Server Core 2022 (headless QEMU/KVM) ├── QEMU Guest Agent ← primary exec channel ├── VirtioFsSvc (WinFsp) ← auto-mounts Z:\ on boot ├── OpenSSH Server ← interactive sessions ├── Defender disabled ← no AV interference ├── Firewall disabled ← no port blocking └── NAT via libvirt ← reaches anything Kali can reach ``` **四个通道:** - **Guest Agent** (virtio-serial) —— 用于 `winbox exec` 的命令执行及虚拟机管理 - **VirtIO-FS** —— 共享文件系统,通过共享内存实现零拷贝 - **SSH** —— 交互式 PowerShell 会话 (`winbox ssh`) - **ConPTY** —— 具有完整 PTY 支持的 SYSTEM 级交互式 Shell (`winbox shell`) ## 配置 在 `~/.winbox/config` 中覆盖默认值 (Shell 风格的 `KEY=VALUE`): ``` # VM 资源 VM_NAME=winbox VM_RAM=4096 # MB VM_CPUS=4 VM_DISK=30 # GB # 网络 HOST_IP=192.168.122.1 # Credentials VM_USER=Administrator VM_PASSWORD=WinboxP@ss123 # 路径 WINBOX_DIR=~/.winbox VIRTIO_ISO_URL=https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso ``` ## 文件系统布局 ``` ~/.winbox/ ├── config # user config overrides (optional) ├── jobs.json # background job state ├── id_ed25519 / .pub # SSH keypair (generated during setup) ├── disk.qcow2 # VM disk image ├── iso/ │ ├── SERVER_EVAL_x64FRE_en-us.iso # Windows Server 2022 eval ISO │ ├── virtio-win.iso # VirtIO drivers │ ├── OpenSSH-Win64.zip # bundled OpenSSH │ ├── winfsp.msi # WinFsp installer │ ├── virtiofs.exe # VirtIO-FS service binary │ └── unattend.img # built during setup └── shared/ # VirtIO-FS share <=> Z:\ in VM ├── tools/ # your pentest tools └── loot/ # output directory └── .jobs/ # background job log files ``` ## 许可证 MIT
标签:Active Directory, binfmt_misc, BloodHound, Headless VM, OpenCanary, Plaso, QEMU/KVM, Rubeus, SharpHound, Web报告查看器, Windows 虚拟机, 内存分配, 域渗透, 攻击模拟, 数据展示, 模拟器, 电子数据取证, 红队, 网络安全, 自动化执行, 虚拟化, 跨平台执行, 身份验证强制, 逆向工具, 透明代理, 隐私保护, 驱动签名利用