isaacward1/mal-sandbox
GitHub: isaacward1/mal-sandbox
一个Windows恶意软件分析沙箱的配置模板,提供KVM/QEMU虚拟机定义、网络隔离规则和分析工具链参考。
Stars: 0 | Forks: 0
# mal-sandbox
我用于分析 Windows x86-64 恶意软件的沙箱
## 复制环境 ### 定义客户机 / 接口 这些是用于复制我的 KVM/QEMU 虚拟机和网络的 libvirt XML 文件: - [mal-host-only.xml](mal-host-only.xml) - [mal-NAT.xml](mal-NAT.xml) - [mal-win10.xml](mal-win10.xml) 要创建相同的客户机虚拟机: ``` sudo virsh net-define mal-host-only.xml sudo virsh net-define mal-NAT.xml sudo virsh nwfilter-define mal-isolate.xml sudo virsh nwfilter-define mal-root.xml sudo virsh define mal-win10.xml ``` ### 安装 VirtIO 1. 下载最新的 [virtio-win](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso) 驱动程序 2. 按照这些[说明](https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers#Using_the_ISO)操作 ### Setup.ps1 此[脚本](setup.ps1)自动配置多项系统/网络设置以及外观/性能调整 - `$hostonly_mac` 和 `$nat_mac` 的值应更改为虚拟机端的 MAC 地址(可通过 `virsh domiflist mal-win10` 确定) - 工具通过 Chocolatey 包安装,也可以通过[下方链接](https://github.com/isaacward1/mal-sandbox/blob/main/README.md#analysis-tools)手动安装 - 需要手动更改的项目列在底部,因为 powershell 比较难用 ### 移除干扰 虽然 [disable-defender.exe](https://github.com/pgkt04/defender-control/releases/tag/v1.5) 应该足够了,但如果需要零干扰,请按照这些[步骤](https://github.com/mandiant/flare-vm?tab=readme-ov-file#pre-installation)永久禁用 Defender、篡改保护 (Tamper Protection) 和 Windows 更新。
## 系统 - Windows 10 - 4 vCPUs(1 个插槽,2 个核心,2 个线程) - 8 GB 内存 - 50 GB 存储 - 自定义 host-only 网络接口: - 名称:mal-host-only - 模式:host-only 或 isolated - 子网:10.0.0.0/30 - 禁用 DHCP 和 IPv6 - 自定义 NAT 网络接口: - 名称:mal-NAT - 模式:NAT - 子网:172.16.20.0/30 - 禁用 DHCP 和 IPv6 - 3D 加速
## 分析工具 ### 静态 - [PEStudio](https://www.winitor.com/download) - [PE-bear](https://github.com/hasherezade/pe-bear) - [DIE](https://github.com/horsicq/DIE-engine/releases) - [dnSpyEx](https://github.com/dnSpyEx/dnSpy) - [ImHex](https://github.com/WerWolv/ImHex) - [Ghidra](https://github.com/NationalSecurityAgency/ghidra) - [CyberChef](https://github.com/gchq/CyberChef) - [FLOSS](https://github.com/mandiant/flare-floss) - [CAPA](https://github.com/mandiant/capa/releases) - [YARA](https://github.com/VirusTotal/yara) ### 动态 - [x64dbg](https://github.com/x64dbg/x64dbg) - [PE-sieve](https://github.com/hasherezade/pe-sieve) - [Wireshark](https://www.wireshark.org/download.html) - [mitmproxy](https://www.mitmproxy.org/) - [Sysinternals Suite](https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite) - [System Informer](https://github.com/winsiderss/systeminformer) ### 其他 - [disable-defender.exe](https://github.com/pgkt04/defender-control/releases/tag/v1.5) - [VS Code](https://code.visualstudio.com/) - [Python](https://www.python.org/downloads/) (v3.14) - [Volatility 3](https://github.com/volatilityfoundation/volatility3) - [Temurin JDK](https://adoptium.net/temurin/releases) (v21.0) - [UniExtract2](https://github.com/Bioruebe/UniExtract2) - [7-Zip](https://www.7-zip.org/)
## 网络隔离 隔离主要通过 libvirt [网络过滤器](https://libvirt.org/formatnwfilter.html)完成。 ### mal-isolate: ```
```
### mal-root:
```
```
### UFW
应用于主机的防火墙规则。它允许从虚拟机入站访问主机的 python http 服务器。
```
iface="mal-ho-br" # name of VM's host-only bridge
br_ip="10.0.0.1" # host-only interface's gateway IP
vm_ip="10.0.0.2" # host IP assigned to VM on host-only network
port="8888" # python http.server port
sudo ufw allow in on $iface from $vm_ip to $br_ip port $port proto tcp comment '(mal) allow to host python http.server'
```
## 文件传输 ### 使用 Python [http.server](https://docs.python.org/3/library/http.server.html#) #### 从主机上传 --> 虚拟机 1. 在主机上运行以向虚拟机提供恶意软件: python3 -m http.server -d /path/to/served/dir --bind
2. 在虚拟机的浏览器中,访问 `http://:`
#### 从虚拟机下载 --> 主机
1. 在虚拟机上运行以下载文件到主机:
python3 -m http.server --bind
2. 在主机的浏览器中,访问 `http://:`
### 替代方案
- 加固的 scp/OpenSSH
- 专用的轻量级虚拟机或容器,用于向虚拟机上传和从虚拟机下载文件
- 只读共享文件夹
- 从在线数据库下载恶意软件到虚拟机(临时互联网)
## 技巧 - 设置和调整完成后,创建一个快照,以便在引爆恶意软件后还原到干净的状态。 - 在执行恶意软件之前,确保所有虚拟机监控程序/仿真软件已是最新版本并应用了最新的安全补丁。 - 为 python 服务器使用 bash 别名
例如:`alias pyserver='python3 -m http.server -d ~/Downloads/mal-win10 --bind 10.0.0.1 8888'` - 忽略上面所有内容。直接使用 [FLARE-VM](https://github.com/mandiant/flare-vm) 或 [REMnux](https://remnux.org/)。
## 复制环境 ### 定义客户机 / 接口 这些是用于复制我的 KVM/QEMU 虚拟机和网络的 libvirt XML 文件: - [mal-host-only.xml](mal-host-only.xml) - [mal-NAT.xml](mal-NAT.xml) - [mal-win10.xml](mal-win10.xml) 要创建相同的客户机虚拟机: ``` sudo virsh net-define mal-host-only.xml sudo virsh net-define mal-NAT.xml sudo virsh nwfilter-define mal-isolate.xml sudo virsh nwfilter-define mal-root.xml sudo virsh define mal-win10.xml ``` ### 安装 VirtIO 1. 下载最新的 [virtio-win](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso) 驱动程序 2. 按照这些[说明](https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers#Using_the_ISO)操作 ### Setup.ps1 此[脚本](setup.ps1)自动配置多项系统/网络设置以及外观/性能调整 - `$hostonly_mac` 和 `$nat_mac` 的值应更改为虚拟机端的 MAC 地址(可通过 `virsh domiflist mal-win10` 确定) - 工具通过 Chocolatey 包安装,也可以通过[下方链接](https://github.com/isaacward1/mal-sandbox/blob/main/README.md#analysis-tools)手动安装 - 需要手动更改的项目列在底部,因为 powershell 比较难用 ### 移除干扰 虽然 [disable-defender.exe](https://github.com/pgkt04/defender-control/releases/tag/v1.5) 应该足够了,但如果需要零干扰,请按照这些[步骤](https://github.com/mandiant/flare-vm?tab=readme-ov-file#pre-installation)永久禁用 Defender、篡改保护 (Tamper Protection) 和 Windows 更新。
## 系统 - Windows 10 - 4 vCPUs(1 个插槽,2 个核心,2 个线程) - 8 GB 内存 - 50 GB 存储 - 自定义 host-only 网络接口: - 名称:mal-host-only - 模式:host-only 或 isolated - 子网:10.0.0.0/30 - 禁用 DHCP 和 IPv6 - 自定义 NAT 网络接口: - 名称:mal-NAT - 模式:NAT - 子网:172.16.20.0/30 - 禁用 DHCP 和 IPv6 - 3D 加速
## 分析工具 ### 静态 - [PEStudio](https://www.winitor.com/download) - [PE-bear](https://github.com/hasherezade/pe-bear) - [DIE](https://github.com/horsicq/DIE-engine/releases) - [dnSpyEx](https://github.com/dnSpyEx/dnSpy) - [ImHex](https://github.com/WerWolv/ImHex) - [Ghidra](https://github.com/NationalSecurityAgency/ghidra) - [CyberChef](https://github.com/gchq/CyberChef) - [FLOSS](https://github.com/mandiant/flare-floss) - [CAPA](https://github.com/mandiant/capa/releases) - [YARA](https://github.com/VirusTotal/yara) ### 动态 - [x64dbg](https://github.com/x64dbg/x64dbg) - [PE-sieve](https://github.com/hasherezade/pe-sieve) - [Wireshark](https://www.wireshark.org/download.html) - [mitmproxy](https://www.mitmproxy.org/) - [Sysinternals Suite](https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite) - [System Informer](https://github.com/winsiderss/systeminformer) ### 其他 - [disable-defender.exe](https://github.com/pgkt04/defender-control/releases/tag/v1.5) - [VS Code](https://code.visualstudio.com/) - [Python](https://www.python.org/downloads/) (v3.14) - [Volatility 3](https://github.com/volatilityfoundation/volatility3) - [Temurin JDK](https://adoptium.net/temurin/releases) (v21.0) - [UniExtract2](https://github.com/Bioruebe/UniExtract2) - [7-Zip](https://www.7-zip.org/)
## 网络隔离 隔离主要通过 libvirt [网络过滤器](https://libvirt.org/formatnwfilter.html)完成。 ### mal-isolate: ```
## 文件传输 ### 使用 Python [http.server](https://docs.python.org/3/library/http.server.html#) #### 从主机上传 --> 虚拟机 1. 在主机上运行以向虚拟机提供恶意软件: python3 -m http.server -d /path/to/served/dir --bind
## 技巧 - 设置和调整完成后,创建一个快照,以便在引爆恶意软件后还原到干净的状态。 - 在执行恶意软件之前,确保所有虚拟机监控程序/仿真软件已是最新版本并应用了最新的安全补丁。 - 为 python 服务器使用 bash 别名
例如:`alias pyserver='python3 -m http.server -d ~/Downloads/mal-win10 --bind 10.0.0.1 8888'` - 忽略上面所有内容。直接使用 [FLARE-VM](https://github.com/mandiant/flare-vm) 或 [REMnux](https://remnux.org/)。