0xpivot/Empire-AD
GitHub: 0xpivot/Empire-AD
一个通过自动化部署构建多林 Windows AD 刻意漏洞实验环境的项目,专为攻击性安全训练、红队演练和 CTF 提供真实可复现的攻击靶场。
Stars: 8 | Forks: 0
# EMPIRE — 存在漏洞的多林 Active Directory 实验环境
一个可复现、**刻意配置错误**的多林 Windows Active Directory 实验环境,专为攻击性安全训练、CTF 和红队演练设计。只需一条命令 (`python3 deploy.py`) 即可下载 Windows 安装镜像、使用 Packer 构建基础镜像、配置网络、启动 VM,并执行完整的 Ansible 攻击面注入(遵循 `PLAN.md`):Kerberoasting、AS-REP roasting、ADCS ESC1–ESC16、ACL 滥用、委派链、RBCD、ZeroLogon/noPac/Certifried 前置条件、Golden/Silver/Diamond ticket、SID-history 注入、跨林信任滥用等。
## 构建内容
在单个 Linux 网桥上构建三个林、最多九个 VM:
- **`empire.local`** (根) + **`eu.empire.local`** (子) — 银河帝国林
- **`rebel.local`** — 外部信任 (义军同盟)
- **`trade.corp`** — 林信任 (贸易联盟)
八台 Windows Server VM (2019/2022) + 一台 Ubuntu 22.04 Linux 成员机。所有机器共享 `10.10.0.0/16` 上的 `empire-ctf` 网桥;各林位于不同的 /24 网段 (`10.10.0.x`, `10.10.20.x`, `10.10.30.x`),因此跨林流量通过 AD/DNS 层而非网络层进行路由。
### 网络 (L2 / IP)
```
graph TD
classDef host fill:#000,stroke:#0f0,stroke-width:2px,color:#0f0;
classDef bridge fill:#333,stroke:#fff,stroke-width:1px,color:#fff;
classDef vm fill:#1d2b38,stroke:#00d2ff,stroke-width:2px,color:#fff;
Host["Linux Host
python3 deploy.py
QEMU/KVM · Packer · Ansible · dnsmasq"]:::host CTF{"empire-ctf
10.10.0.1/16
(ALL forests)"}:::bridge Host --> CTF CTF --- coruscant["coruscant.empire.local
10.10.0.10"]:::vm CTF --- deathstar["deathstar.eu.empire.local
10.10.0.11"]:::vm CTF --- endor["endor.empire.local
10.10.0.12"]:::vm CTF --- scarif["scarif.empire.local
10.10.0.13"]:::vm CTF --- kamino["kamino.empire.local
10.10.0.14"]:::vm CTF --- mandalore["mandalore.empire.local
10.10.0.15"]:::vm CTF --- tatooine["tatooine.empire.local
10.10.0.100"]:::vm CTF --- yavin4["yavin4.rebel.local
10.10.20.10"]:::vm CTF --- neimoidia["neimoidia.trade.corp
10.10.30.10"]:::vm ``` ### Active Directory (林 + 信任) ``` graph TD classDef domain fill:#1d2b38,stroke:#00d2ff,stroke-width:2px,color:#fff; subgraph EMPIRE Forest EMPIRE["empire.local
(root domain)"]:::domain EU["eu.empire.local
(child domain)"]:::domain EMPIRE -- "Parent / Child" --> EU end subgraph REBEL Forest FIN["rebel.local"]:::domain end subgraph TRADE Forest TRADE["trade.corp"]:::domain end EMPIRE <-->|External Trust · BiDirectional · SID filter OFF| FIN EMPIRE <-->|Forest Trust · BiDirectional · SID filter OFF| TRADE ``` 信任关系由 `ad_trust` 角色创建 (对 empire↔rebel 使用 `TrustType=External`,对 empire↔trade 使用 `Forest`,均为双向) 并通过 .NET `CreateTrustRelationship` API 实现,同时禁用了 SID 过滤 (DF-008),以便 SID-history 注入能够跨边界工作。跨林名称解析通过 `coruscant.empire.local` 上的条件转发器实现 (`dns` 角色)。 | 域 | 林 | IP 范围 | DC (清单名称) | 到 empire.local 的信任 | |---|---|---|---|---| | `empire.local` | EMPIRE (根) | `10.10.0.x` | `coruscant.empire.local` | — | | `eu.empire.local` | EMPIRE (子) | `10.10.0.x` | `deathstar.eu.empire.local` | 父/子,同林 | | `rebel.local` | REBEL (根) | `10.10.20.x` | `yavin4.rebel.local` | 外部,双向 | | `trade.corp` | TRADE (根) | `10.10.30.x` | `neimoidia.trade.corp` | 林,双向 | ### VM 清单 规格硬编码在 `providers/qemu/vm-create.sh` (`VM_DEFS`) 中,静态 dnsmasq 租约在 `providers/qemu/network-setup.sh` 中。当您添加或重命名 VM 时,`vm-create.sh`、`network-setup.sh`、`ansible/inventory.yml` 以及任何引用该主机名的角色/任务,这**四项**必须保持同步。 | 主机 | IP | 内存 | vCPU | VNC | 基础镜像 | 角色 | |---|---|---|---|---|---|---| | `coruscant.empire.local` | 10.10.0.10 | 1792 MB | 2 | :5901 | server2022 | 根 DC | | `deathstar.eu.empire.local` | 10.10.0.11 | 1280 MB | 2 | :5902 | server2022 | 子 DC | | `endor.empire.local` | 10.10.0.12 | 1536 MB | 2 | :5903 | server2022 | ADCS / 企业 CA | | `scarif.empire.local` | 10.10.0.13 | 1280 MB | 2 | :5904 | server2019 | 文件服务器 (SMB) | | `kamino.empire.local` | 10.10.0.14 | 1792 MB | 2 | :5905 | server2022 | SQL Server | | `tatooine.empire.local` | 10.10.0.100 | 1024 MB | 2 | :5906 | server2022 (Core) | 受害者“工作站” | | `mandalore.empire.local` | 10.10.0.15 | 1280 MB | 2 | :5909 | ubuntu 22.04 | Linux 成员 | | `yavin4.rebel.local` | 10.10.20.10 | 1280 MB | 2 | :5907 | server2022 | rebel.local DC | | `neimoidia.trade.corp` | 10.10.30.10 | 1280 MB | 2 | :5908 | server2022 | trade.corp DC | 配置文件:**`full`** = 全部 9 个 VM / 3 个林 (分配约 12.25 GB)。**`minimal`** = 7 个 VM (empire.local + mandalore,无 rebel/trade DC,约 9.75 GB)。**`single-dc`** = 仅 `coruscant` (约 1.5 GB 冒烟测试)。 ### 实验环境凭据 (非机密 — 刻意设置为弱口令) | 用途 | 值 | |---|---| | 域管理员 (每个域) | `SithLord123!` | | DSRM / 安全模式密码 | `SithLord123!` | | `krbtgt` (empire.local) | `KrbtgtEMPIRE2024!` | | `krbtgt` (eu.empire.local) | `KrbtgtEU2024!` | | 跨林信任密钥 | `TrustKey2024!` | ## 环境要求 - 带有 **KVM** 的 Linux 主机 (在 BIOS 中启用 Intel VT-x / AMD-V) - 约 **16 GB 空闲内存** (full) / 约 10 GB (minimal) / 约 2 GB (single-dc) - 约 **100 GB 空闲磁盘空间**,用于 qcow2 镜像 + Windows ISO + virtio-win - `sudo` (网桥创建、dnsmasq、nftables 需要 root 权限) - 首次运行需要联网 (下载 Windows ISO + virtio + Ubuntu 云镜像 + 软件包) - 主机软件包:`qemu`/KVM, `libvirt`, `swtpm`, `ovmf`, `packer`, `ansible`, `dnsmasq` `scripts/setup-deps.sh` 会根据不同发行版安装主机软件包:Debian/Ubuntu (`apt`)、Fedora/RHEL/Rocky/Alma (`dnf`)、Arch/Manjaro (`pacman`)、openSUSE (`zypper`)。在将您添加到 `kvm`/`libvirt` 组之后,您必须**注销并重新登录**,然后才能在不使用 sudo 的情况下启动 VM。 ## 快速开始 ``` git clone https://github.com/sanchitsahni/Damn-Vunerable-Active-Directory.git EMPIRE cd EMPIRE sudo bash scripts/setup-deps.sh # one-time host dependency install # ... 注销 / 重新登录 (kvm + libvirt group 成员资格) ... python3 deploy.py # interactive wizard (recommended first run) # 非交互式: python3 deploy.py --profile full --provider qemu --yes python3 deploy.py --profile minimal --provider qemu --yes # empire.local + mandalore python3 deploy.py --profile single-dc --yes # 1-VM smoke test python3 deploy.py --ram 24 --disk-path /mnt/vms --yes # resource caps ``` 您**无需**提供自己的基础镜像 — `deploy.py` 会下载 Windows Server ISO + virtio-win + Ubuntu 云镜像,然后使用 Packer 自动构建 qcow2 基础镜像。 ### 流水线阶段 `deploy.py` 端到端运行 7 个阶段 (`--phase N` / `--from-phase` 可从任一阶段重新开始): | # | 阶段 | 执行内容 | |---|---|---| | 0 | media | 将 Windows ISO、virtio-win、Ubuntu 云镜像下载到 `media/` | | 1 | packer | 构建 server2019 / server2022 基础 qcow2 镜像 | | 2 | network | 创建 `empire-ctf` 网桥 + 项目本地 dnsmasq + nftables | | 3 | VMs | 生成每个 VM 的 `autounattend.xml` + `post-install.ps1`,克隆磁盘并启动 | | 4 | WinRM | 等待每个 VM 完成 Windows 设置 (写入 `vms/.installed`) |
| 5 | ansible | 域提升 → 建立信任 → ADCS → 全面漏洞注入 (`site.yml`) |
| 6 | verify | 第 1 层被动配置检查 (`scripts/verify_vulns.py`) |
首次完整运行预计需要 **45–90 分钟** (主要由 Windows 安装 + packer 耗时)。仅重新运行 Ansible 只需几分钟。
## 交互式控制台
运行不带 `--yes` 参数的 `python3 deploy.py` 会进入一个感知设置的控制台。输入 `help` (或 `?`) 查看菜单:
| 分组 | 命令 |
|---|---|
| **实验环境** | `check` · `install` · `build` · `network` · `vms` · `provision` · `resume ` |
| **VM** | `status` · `start` · `stop` · `destroy` · `snapshot` · `reset` · `vnc` |
| **配置** | `provision_tags ` (例如 `kerberos,adcs`) · `verify` |
| **设置** | `settings` · `set_profile` · `set_provider` · `set_ram` · `set_attacker` · `set_flag_mode` · `set_disk` |
在成功配置后执行 `snapshot`,随后即可通过 `reset` 在几秒钟内将所有 VM 回滚,而无需重新配置。
## CLI 参数 (`python3 deploy.py --help`)
| 参数 | 效果 |
|---|---|
| `--yes`, `-y` | 跳过所有提示 (用于 CI / cron) |
| `--profile {full,minimal,single-dc}` | 实验环境规模 |
| `--provider {qemu,virtualbox}` | Hypervisor (默认为 qemu) |
| `--phase N`, `-p N` | 从阶段 N 开始 (0=media … 6=verify) |
| `--from-phase PHASE` | 从该阶段开始运行 Ansible 直到结束,然后退出 |
| `--only-phase PHASE` | 仅运行该 Ansible 阶段,然后退出 |
| `--limit HOST` | Ansible `--limit` (例如 `endor.empire.local`) |
| `--ram GB` | 所有 VM 的总内存预算 |
| `--disk-path PATH` | VM 磁盘目录 (默认为 `./vms`) |
| `--attacker-ip IP` | 打入 payload 的攻击者 / 监听端 IP |
| `--flag-mode {ctf,training}` | `ctf` = 获取 flag 需要利用漏洞;`training` = 在 `C:\Flags\` 可见 |
| `--base-action {build,skip}` | `build` = 运行 packer;`skip` = 镜像已存在 |
| `--destroy` | 销毁所有 VM + 网络 |
| `--install-cron` | 写入 crontab + sudoers 并退出 |
| `--log-file PATH` | 将所有输出追加到日志文件 |
Ansible 子阶段 (用于 `--from-phase` / `--only-phase`):`1 2 5 6 7 8 8b 9 10 11 13 14 16 17 18 19 20`。
## 部署完成后
```
# 仅重新运行 Ansible (VMs 已经启动):
cd ansible && ansible-playbook -i inventory.yml playbooks/site.yml -v
# 语法 / dry-run 验证:
ansible-playbook -i inventory.yml playbooks/site.yml --syntax-check
ansible-playbook -i inventory.yml playbooks/site.yml --check
# 从给定阶段重新运行 Ansible (helper):
scripts/run-from.sh 8b --limit endor.empire.local
```
连接到某个 VM:
```
vncviewer 127.0.0.1:5901 # coruscant console
evil-winrm -i 10.10.0.10 -u Administrator -p 'SithLord123!' # WinRM (5985 open)
xfreerdp /v:10.10.0.100 /u:Administrator /p:'SithLord123!' # RDP where enabled
```
攻击需从**您自己的 Kali / BlackArch** 发起,位于主机网桥上 — 即运行 `deploy.py` 的那台机器。`tatooine` 是受害者,而不是攻击机。请自带 `impacket`, `BloodHound`, `certipy`, `Rubeus`, `mimikatz`, `netexec`, `Responder`, `mitm6`, `ntlmrelayx`。
## 刻意制造的漏洞
简短列表 — 完整规范请见 `PLAN.md`:
- 每台主机均禁用 Defender、关闭防火墙、削弱 UAC
- `ms-DS-MachineAccountQuota = 10` (noPac / Certifried 前置条件)
- 将 `krbtgt` 重置为已知的实验室值,以实现确定性的 Golden Ticket
- 发布了 ADCS ESC1–ESC16 模板 (`EMPIREUserESC1`, `EMPIREMachineESC2`, …)
- 带有弱密码的 Kerberoastable 服务账号 (`svc_*`)
- AS-REP roastable 账号 (`DoNotRequirePreAuth`)
- 为非管理员用户授予 DCSync 权限
- 在两个跨林信任上禁用了 SID 过滤;信任密钥重置为 `TrustKey4!`
- ZeroLogon 前置条件,非约束/约束/RBCD 委派,gMSA 后门
- AdminSDHolder GenericAll 后门,可写的 GPO (`EMPIREBackdoorGPO`, PER-034)
- 不要求 SMB 签名,不要求 LDAP 签名,开启 LLMNR,开启 IPv6 (mitm6)
- ……以及跨越 IA / REC / ENUM / CRED / LAT / PE / PER / DF 类别的约 370 多个 ID — 详见 `PLAN.md`
**请勿“修复”其中任何一项。** 如果某些看起来已损坏的内容*未*包含在 `PLAN.md` 中,那才是真正的 Bug — 请提交问题。
## 重置 / 销毁
```
python3 deploy.py --destroy --yes # VMs + networks (qcow2 deleted)
# 或者,在 console 内:destroy
```
`vms/` 和 `media/` 在网络销毁后会保留;请手动删除它们以回收磁盘空间。
## 仓库结构
```
EMPIRE/
├── deploy.py # Entry point — the only script you run
├── PLAN.md # Authoritative attack-matrix spec (all flag IDs)
├── providers/
│ ├── qemu/
│ │ ├── vm-create.sh # VM_DEFS (MAC/RAM/CPU/VNC/bridge), autounattend +
│ │ │ # post-install generation, VM lifecycle
│ │ └── network-setup.sh # empire-ctf bridge + dnsmasq static leases + nftables
│ └── virtualbox/
│ └── vm-create.sh # VirtualBox provider equivalent
├── packer/ # Packer templates (server2019 / server2022 base images)
├── ansible/
│ ├── inventory.yml # Canonical inventory: 9 hosts × 3 forests
│ └── playbooks/
│ └── site.yml # Master playbook — phased AD setup + vuln injection
│ └── roles/ # 23 roles (5 setup + 18 vuln_*)
├── chains/ # Static attack-path graph + reachability validator
├── scripts/ # Helper scripts (see Scripts reference below)
├── wordlists/ # Lab usernames + passwords
├── vms/ # Generated per-VM state (gitignored)
└── media/ # Windows ISOs + virtio + Ubuntu image (gitignored, ~5 GB)
```
Ansible 角色:设置 (`ad_domain`, `child_domain`, `ad_trust`, `dns`, `domain_join`) + 漏洞注入 (`vuln_adcs`, `vuln_cloud_entra`, `vuln_cred_access`, `vuln_cve`, `vuln_defense_evasion`, `vuln_exchange`, `vuln_forest`, `vuln_ia_surface`, `vuln_kerberos`, `vuln_lateral`, `vuln_linux`, `vuln_network_protocols`, `vuln_persistence`, `vuln_privesc`, `vuln_recon`, `vuln_traffic_sim`, `vuln_victim_exec`, `vuln_web_apps`)。`vuln_*` 角色是整个实验室的核心意义所在;其余部分皆为脚手架。
## 脚本参考
`deploy.py` 是入口;下方的所有内容要么由它调用,要么由用户手动运行。
**流水线 — 由 `deploy.py` 自动调用:**
| 脚本 | 作用 |
|---|---|
| `providers/qemu/vm-create.sh` | 为每个 QEMU/KVM VM 生成 autounattend + post-install,并创建和启动 |
| `providers/qemu/network-setup.sh` | 创建 `empire-ctf` 网桥 + 项目本地 dnsmasq 静态租约 |
| `providers/virtualbox/vm-create.sh` | VirtualBox provider 等价物 (当使用 `--provider virtualbox` 时) |
| `scripts/verify_vulns.py` | 第 1 层被动配置验证 (也是 `verify` 控制台命令) |
| `ansible/roles/vuln_linux/files/empire_app.py` | 由 Ansible 部署到 `mandalore` 的存在漏洞的 Web 应用 |
**手动 / 可选工具:**
| 脚本 | 作用 |
|---|---|
| `scripts/setup-deps.sh` | 按发行版安装主机软件包 — 在 `deploy.py` 之前运行一次 |
| `scripts/run-from.sh` | 从给定阶段到结束重新运行 Ansible `site.yml` |
| `scripts/verify_exploits.sh` | 第 2 层攻击者侧漏洞验证 |
| `scripts/vps-wg-gateway.sh` | 可选的 WireGuard 网关,用于远程 VPS 访问 |
| `scripts/activate-windows.sh` | Massgrave Windows 激活助手 |
| `scripts/finalize.sh` | 部署后实验室的最终确定 / 验证 |
| `chains/attack_graph.py` + `chains/validator.py` | 静态攻击路径图 + 可达性报告 |
**独立备选方案 — `deploy.py` 已在进程内执行这些操作,保留以供手动使用:**
| 脚本 | 作用 |
|---|---|
| `scripts/wait-vms.sh`, `scripts/wait-for-install.sh` | 轮询 VM 的 WinRM / 写入 `.installed` 标记 (deploy.py: `phase_wait_winrm`) |
| `scripts/setup-sudoers.sh` | 写入 NOPASSWD sudoers (deploy.py: `--install-cron`) |
| `scripts/download-windows.sh` | 下载 Windows + virtio ISO (deploy.py: 进程内下载器) |
**遗留 / 实用工具:**
| 脚本 | 作用 |
|---|---|
| `scripts/exploit_graph.py` | 废弃的兼容垫片 → `chains/validator.py` |
| `scripts/check_docs.py`, `scripts/check_study_flags.py`, `scripts/generate_missing.py` | 文档 / flag 一致性助手 |
## 文档导览
| 文档 | 用途 |
|---|---|
| `README.md` | 本文件 — 设置、生命周期、仓库结构 |
| `PLAN.md` | 权威攻击矩阵规范 — 每个 flag ID、前置条件和预期技术 |
## 故障排除
| 症状 | 原因 / 修复 |
|---|---|
| 在 `/dev/kvm` 上遇到 `Permission denied` | 已被添加到 `kvm`/`libvirt` 组但未重新登录。请注销并重新登录。 |
| Ansible WinRM 连接被拒绝 | VM 尚未完成 `post-install.ps1`。deploy.py 正在等待 `vms/.installed` 标记;如果卡住,请通过 VNC 监视 VM。 |
| 缺少跨林信任 | 创建信任首先需要 DNS 条件转发器;`dns` 阶段在 `ad_trust` 之前运行。重新运行 `ansible-playbook … --tags dns,trusts` (幂等)。 |
| VM 内核崩溃 / 启动时三重错误 | OVMF/`swtpm` 版本不匹配 — 请从您的发行版软件仓库安装这两者。 |
| Packer 构建失败 | 检查 `packer-output/logs/`;确保 Windows ISO 已存放在 `media/` 中 (阶段 0)。 |
## 免责声明
EMPIRE 是一个研究和训练工具,故意制造了一个极易受攻击的 Windows AD 环境。**请勿在您无法控制的网络中部署它。** 该实验室的密码和故意设置的漏洞配置是公开的;请将每台 VM 视为具有敌意。作者对任何滥用行为概不负责。
# 星战元素与主题映射
该实验环境将 Active Directory 概念映射到银河帝国、义军同盟和贸易联盟之间的星际斗争。
```
graph TD
classDef empire fill:#000000,stroke:#ff0000,stroke-width:2px,color:#fff;
classDef rebel fill:#2b5c8f,stroke:#ff9900,stroke-width:2px,color:#fff;
classDef trade fill:#4a4a4a,stroke:#aaaaaa,stroke-width:2px,color:#fff;
classDef highlight fill:#440000,stroke:#ff0000,stroke-width:3px,color:#fff;
subgraph empire_forest["The Galactic Empire — empire.local"]
Coruscant["Coruscant (Root DC)
coruscant.empire.local"]:::empire DeathStar["The Death Star (Child DC)
deathstar.eu.empire.local"]:::highlight Scarif["Scarif Citadel (File Server)
scarif.empire.local"]:::empire Kamino["Kamino Cloning Facility (SQL)
kamino.empire.local"]:::empire Endor["Endor Shield Generator (CA)
endor.empire.local"]:::empire Mandalore["Mandalore Mercenary Base (Linux)
mandalore.empire.local"]:::empire Coruscant -- "Imperial Command" --> DeathStar Coruscant --- Scarif Coruscant --- Kamino Coruscant --- Endor Coruscant --- Mandalore end subgraph rebel_forest["The Rebel Alliance — rebel.local"] Yavin4["Yavin 4 Base
yavin4.rebel.local"]:::rebel end subgraph trade_forest["The Trade Federation — trade.corp"] Neimoidia["Cato Neimoidia
neimoidia.trade.corp"]:::trade end Coruscant <-->|Espionage / External Trust| Yavin4 Coruscant <-->|Treaty / Forest Trust| Neimoidia ``` - **`empire.local` (银河帝国):** 根域 — 皇帝的宝座。这里的 Domain Admin = 银河系的钥匙。 - **`eu.empire.local` (死星):** 子域。从中逃逸并危及根域就如同窃取死星设计图。 - **`rebel.local` (义军同盟):** 外部林,信任关系中的薄弱环节。 - **`trade.corp` (贸易联盟):** 林信任 — 伪造跨领域 TGT 以跨越边界。 - **`endor` (护盾发生器 / ADCS):** 攻陷 CA (ESC1/ESC8…) 可为任何人伪造证书。 - **`scarif` (堡垒 / 文件服务器):** SMB 共享中的脚本和配置文件中遗留了密码。 - **`kamino` (克隆设施 / SQL):** SQLi / `xp_cmdshell` 突破口。 - **`mandalore` (雇佣军基地 / Linux):** 本地权限提升 + 跨操作系统枢纽。 愿原力与您同在,助您征服 EMPIRE AD。
python3 deploy.py
QEMU/KVM · Packer · Ansible · dnsmasq"]:::host CTF{"empire-ctf
10.10.0.1/16
(ALL forests)"}:::bridge Host --> CTF CTF --- coruscant["coruscant.empire.local
10.10.0.10"]:::vm CTF --- deathstar["deathstar.eu.empire.local
10.10.0.11"]:::vm CTF --- endor["endor.empire.local
10.10.0.12"]:::vm CTF --- scarif["scarif.empire.local
10.10.0.13"]:::vm CTF --- kamino["kamino.empire.local
10.10.0.14"]:::vm CTF --- mandalore["mandalore.empire.local
10.10.0.15"]:::vm CTF --- tatooine["tatooine.empire.local
10.10.0.100"]:::vm CTF --- yavin4["yavin4.rebel.local
10.10.20.10"]:::vm CTF --- neimoidia["neimoidia.trade.corp
10.10.30.10"]:::vm ``` ### Active Directory (林 + 信任) ``` graph TD classDef domain fill:#1d2b38,stroke:#00d2ff,stroke-width:2px,color:#fff; subgraph EMPIRE Forest EMPIRE["empire.local
(root domain)"]:::domain EU["eu.empire.local
(child domain)"]:::domain EMPIRE -- "Parent / Child" --> EU end subgraph REBEL Forest FIN["rebel.local"]:::domain end subgraph TRADE Forest TRADE["trade.corp"]:::domain end EMPIRE <-->|External Trust · BiDirectional · SID filter OFF| FIN EMPIRE <-->|Forest Trust · BiDirectional · SID filter OFF| TRADE ``` 信任关系由 `ad_trust` 角色创建 (对 empire↔rebel 使用 `TrustType=External`,对 empire↔trade 使用 `Forest`,均为双向) 并通过 .NET `CreateTrustRelationship` API 实现,同时禁用了 SID 过滤 (DF-008),以便 SID-history 注入能够跨边界工作。跨林名称解析通过 `coruscant.empire.local` 上的条件转发器实现 (`dns` 角色)。 | 域 | 林 | IP 范围 | DC (清单名称) | 到 empire.local 的信任 | |---|---|---|---|---| | `empire.local` | EMPIRE (根) | `10.10.0.x` | `coruscant.empire.local` | — | | `eu.empire.local` | EMPIRE (子) | `10.10.0.x` | `deathstar.eu.empire.local` | 父/子,同林 | | `rebel.local` | REBEL (根) | `10.10.20.x` | `yavin4.rebel.local` | 外部,双向 | | `trade.corp` | TRADE (根) | `10.10.30.x` | `neimoidia.trade.corp` | 林,双向 | ### VM 清单 规格硬编码在 `providers/qemu/vm-create.sh` (`VM_DEFS`) 中,静态 dnsmasq 租约在 `providers/qemu/network-setup.sh` 中。当您添加或重命名 VM 时,`vm-create.sh`、`network-setup.sh`、`ansible/inventory.yml` 以及任何引用该主机名的角色/任务,这**四项**必须保持同步。 | 主机 | IP | 内存 | vCPU | VNC | 基础镜像 | 角色 | |---|---|---|---|---|---|---| | `coruscant.empire.local` | 10.10.0.10 | 1792 MB | 2 | :5901 | server2022 | 根 DC | | `deathstar.eu.empire.local` | 10.10.0.11 | 1280 MB | 2 | :5902 | server2022 | 子 DC | | `endor.empire.local` | 10.10.0.12 | 1536 MB | 2 | :5903 | server2022 | ADCS / 企业 CA | | `scarif.empire.local` | 10.10.0.13 | 1280 MB | 2 | :5904 | server2019 | 文件服务器 (SMB) | | `kamino.empire.local` | 10.10.0.14 | 1792 MB | 2 | :5905 | server2022 | SQL Server | | `tatooine.empire.local` | 10.10.0.100 | 1024 MB | 2 | :5906 | server2022 (Core) | 受害者“工作站” | | `mandalore.empire.local` | 10.10.0.15 | 1280 MB | 2 | :5909 | ubuntu 22.04 | Linux 成员 | | `yavin4.rebel.local` | 10.10.20.10 | 1280 MB | 2 | :5907 | server2022 | rebel.local DC | | `neimoidia.trade.corp` | 10.10.30.10 | 1280 MB | 2 | :5908 | server2022 | trade.corp DC | 配置文件:**`full`** = 全部 9 个 VM / 3 个林 (分配约 12.25 GB)。**`minimal`** = 7 个 VM (empire.local + mandalore,无 rebel/trade DC,约 9.75 GB)。**`single-dc`** = 仅 `coruscant` (约 1.5 GB 冒烟测试)。 ### 实验环境凭据 (非机密 — 刻意设置为弱口令) | 用途 | 值 | |---|---| | 域管理员 (每个域) | `SithLord123!` | | DSRM / 安全模式密码 | `SithLord123!` | | `krbtgt` (empire.local) | `KrbtgtEMPIRE2024!` | | `krbtgt` (eu.empire.local) | `KrbtgtEU2024!` | | 跨林信任密钥 | `TrustKey2024!` | ## 环境要求 - 带有 **KVM** 的 Linux 主机 (在 BIOS 中启用 Intel VT-x / AMD-V) - 约 **16 GB 空闲内存** (full) / 约 10 GB (minimal) / 约 2 GB (single-dc) - 约 **100 GB 空闲磁盘空间**,用于 qcow2 镜像 + Windows ISO + virtio-win - `sudo` (网桥创建、dnsmasq、nftables 需要 root 权限) - 首次运行需要联网 (下载 Windows ISO + virtio + Ubuntu 云镜像 + 软件包) - 主机软件包:`qemu`/KVM, `libvirt`, `swtpm`, `ovmf`, `packer`, `ansible`, `dnsmasq` `scripts/setup-deps.sh` 会根据不同发行版安装主机软件包:Debian/Ubuntu (`apt`)、Fedora/RHEL/Rocky/Alma (`dnf`)、Arch/Manjaro (`pacman`)、openSUSE (`zypper`)。在将您添加到 `kvm`/`libvirt` 组之后,您必须**注销并重新登录**,然后才能在不使用 sudo 的情况下启动 VM。 ## 快速开始 ``` git clone https://github.com/sanchitsahni/Damn-Vunerable-Active-Directory.git EMPIRE cd EMPIRE sudo bash scripts/setup-deps.sh # one-time host dependency install # ... 注销 / 重新登录 (kvm + libvirt group 成员资格) ... python3 deploy.py # interactive wizard (recommended first run) # 非交互式: python3 deploy.py --profile full --provider qemu --yes python3 deploy.py --profile minimal --provider qemu --yes # empire.local + mandalore python3 deploy.py --profile single-dc --yes # 1-VM smoke test python3 deploy.py --ram 24 --disk-path /mnt/vms --yes # resource caps ``` 您**无需**提供自己的基础镜像 — `deploy.py` 会下载 Windows Server ISO + virtio-win + Ubuntu 云镜像,然后使用 Packer 自动构建 qcow2 基础镜像。 ### 流水线阶段 `deploy.py` 端到端运行 7 个阶段 (`--phase N` / `--from-phase` 可从任一阶段重新开始): | # | 阶段 | 执行内容 | |---|---|---| | 0 | media | 将 Windows ISO、virtio-win、Ubuntu 云镜像下载到 `media/` | | 1 | packer | 构建 server2019 / server2022 基础 qcow2 镜像 | | 2 | network | 创建 `empire-ctf` 网桥 + 项目本地 dnsmasq + nftables | | 3 | VMs | 生成每个 VM 的 `autounattend.xml` + `post-install.ps1`,克隆磁盘并启动 | | 4 | WinRM | 等待每个 VM 完成 Windows 设置 (写入 `vms/
coruscant.empire.local"]:::empire DeathStar["The Death Star (Child DC)
deathstar.eu.empire.local"]:::highlight Scarif["Scarif Citadel (File Server)
scarif.empire.local"]:::empire Kamino["Kamino Cloning Facility (SQL)
kamino.empire.local"]:::empire Endor["Endor Shield Generator (CA)
endor.empire.local"]:::empire Mandalore["Mandalore Mercenary Base (Linux)
mandalore.empire.local"]:::empire Coruscant -- "Imperial Command" --> DeathStar Coruscant --- Scarif Coruscant --- Kamino Coruscant --- Endor Coruscant --- Mandalore end subgraph rebel_forest["The Rebel Alliance — rebel.local"] Yavin4["Yavin 4 Base
yavin4.rebel.local"]:::rebel end subgraph trade_forest["The Trade Federation — trade.corp"] Neimoidia["Cato Neimoidia
neimoidia.trade.corp"]:::trade end Coruscant <-->|Espionage / External Trust| Yavin4 Coruscant <-->|Treaty / Forest Trust| Neimoidia ``` - **`empire.local` (银河帝国):** 根域 — 皇帝的宝座。这里的 Domain Admin = 银河系的钥匙。 - **`eu.empire.local` (死星):** 子域。从中逃逸并危及根域就如同窃取死星设计图。 - **`rebel.local` (义军同盟):** 外部林,信任关系中的薄弱环节。 - **`trade.corp` (贸易联盟):** 林信任 — 伪造跨领域 TGT 以跨越边界。 - **`endor` (护盾发生器 / ADCS):** 攻陷 CA (ESC1/ESC8…) 可为任何人伪造证书。 - **`scarif` (堡垒 / 文件服务器):** SMB 共享中的脚本和配置文件中遗留了密码。 - **`kamino` (克隆设施 / SQL):** SQLi / `xp_cmdshell` 突破口。 - **`mandalore` (雇佣军基地 / Linux):** 本地权限提升 + 跨操作系统枢纽。 愿原力与您同在,助您征服 EMPIRE AD。
标签:Active Directory, AI合规, Plaso, StruQ, 应用安全, 模拟器, 特权提升, 系统提示词, 自动化部署, 逆向工具, 靶场环境