iw-sec/mal-sandbox

GitHub: iw-sec/mal-sandbox

一个专为 Windows x86-64 恶意软件分析设计的本地沙箱环境,提供隔离网络与自动化配置。

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` 确定) - 工具通过 Chocolately 包安装,也可手动安装,详见下方的 [链接](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、篡改防护和 Windows 更新。
## 系统 - Windows 10 - 4 个 vCPU(1 个插槽,2 个核心,2 个线程) - 8 GB 内存 - 50 GB 存储 - 自定义主机专用网络接口: - 名称:mal-host-only - 模式:主机专用或隔离 - 子网: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) - [Suricata](https://suricata.io/download/) ### 其他 - [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: ``` ```
## 文件传输 ### 使用 Python [http.server](https://docs.python.org/3/library/http.server.html#) #### 强化措施 1. 专用用户(malstore) sudo useradd -r -s /usr/sbin/nologin malstore 2. 恶意软件存储 sudo mkdir -p /home/malstore/mal sudo chown malstore:malstore /home/malstore/mal sudo chmod 700 /home/malstore/mal 3. systemd 沙箱 ``` [Unit] Description=Malware Storage Service [Service] User=malstore ExecStart=/usr/bin/sleep infinity NoNewPrivileges=true PrivateTmp=true ProtectSystem=strict ProtectHome=true ReadWritePaths=/home/malstore/mal NoExecPaths=/home/malstore/mal MemoryDenyWriteExecute=true RestrictSUIDSGID=true LockPersonality=true RestrictNamespaces=true PrivateDevices=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true [Install] WantedBy=multi-user.target ``` 3. UFW 规则 iface="mal-ho-br" # 客户机主机专用桥接接口名称 br_ip="10.0.0.1" # 主机专用接口的网关 IP vm_ip="10.0.0.2" # 主机上分配给客户机的专用网络 IP port="8888" # python http.server 端口 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(端口 8888)。 5. 最小化 HTTPServer(malserver.py) 2. Windows 防火墙规则 - 独立用户;无登录、无权限 - 不可执行的文件夹 - 受限的 Python HTTP 服务器 #### 从主机上传至客户机 1. 在主机上运行以下命令以提供恶意软件给客户机: sudo -u malstore python3 -m http.server -d /home/malstore/mal --bind 10.0.0.1 8888 2. 在客户机浏览器中访问 `http://10.0.0.1:8888` #### 从客户机下载至主机 1. 在客户机上运行以下命令以下载文件到主机: python3 -m http.server --bind 10.0.0.2 8888 2. 在主机浏览器中访问 `http://10.0.0.2:8888` ### 替代方案 - 强化后的 SFTP - 用于上传/下载文件的独立轻量级客户机或容器 - 只读共享文件夹 - 从在线数据库(临时网络)下载恶意软件到客户机
## 提示 - 设置并微调后,请拍摄快照以便在分析恶意软件后恢复到干净状态。 - 执行恶意软件前,请确保所有虚拟化/仿真软件均已应用最新的安全补丁。 - 为 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/)。