CentOS 8 安装 Apache Caldera 指南
CentOS 8 从零安装 Apache Caldera 5.3.0 对抗模拟平台:EOL 源切换、Python 3.9 与 Node.js 依赖、源码获取、依赖排障、启动验证、systemd 托管与卸载,均实测。
CentOS 8 安装 Apache Caldera 指南
目标:在 CentOS 8 服务器上从零安装并运行 Apache Caldera 5.3.0 对抗模拟(红队)平台,覆盖基础环境、源码部署、前端构建、启动验证、systemd 托管与卸载。本文所有命令与回显均在一台 CentOS Linux release 8.4.2105 服务器上实测通过。
一、环境信息
本指南实测环境如下:
| 项目 | 值 |
|---|---|
| 操作系统 | CentOS Linux release 8.4.2105(x86_64) |
| Python | 3.9.6(系统包 python39,配合 pip 20.2.4 升级至 25.x) |
| Node.js | v16.13.1(npm 8.1.2,系统模块 nodejs:16) |
| Caldera 版本 | 5.3.0(源码 git tag,commit b24f6e7) |
| 部署目录 | /opt/caldera |
| Web 服务端口 | 8888(HTTP/REST API/WebUI) |
| Agent 通讯端口 | 7010(TCP)、7011(UDP)、7012(WebSocket)、8022(SSH 隧道)、2222(FTP)、8853(DNS) |
| 内存/CPU 建议 | 官方推荐 8GB+ 内存、2+ CPU |
💡 说明:Caldera(MITRE 贡献、2025 年进入 Apache 孵化器)是一套自动化对抗模拟/红队平台,用于在受控环境内模拟攻击者的战术、技术与过程(TTPs),从而评估与训练防御能力。它以「agent(代理)+ operation(行动)」模型工作:agent 部署在目标主机上回连服务器,服务器按既定「adversary(对手模型)」编排操作。
二、前置条件
2.1 硬件与网络
服务器需满足:
- 内存 8GB 以上、CPU 2 核以上(官方推荐硬件基线);
- 可访问外网(GitHub 拉取源码与 Python/Node 依赖);
- 放行 8888 端口供 WebUI/API 使用;如需 agent 回连,还需放行 7010、7012 等通讯端口。
2.2 修复 yum 源(CentOS 8 已 EOL)
CentOS 8 已于 2021 年底停止维护,默认的 mirrorlist.centos.org 已无法解析,直接安装软件包会报错:
Errors during downloading metadata for repository 'appstream':
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container
定位:mirrorlist.centos.org 域名已停服(EOL),需改用归档源或国内镜像。先切换到官方归档源 vault.centos.org:
cd /etc/yum.repos.d
sed -i "s|^mirrorlist=|#mirrorlist=|g" CentOS-*.repo
sed -i "s|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" CentOS-*.repo
yum repolist
回显:
repo id repo name
appstream CentOS Linux 8 - AppStream
baseos CentOS Linux 8 - BaseOS
extras CentOS Linux 8 - Extras
但 vault.centos.org 在部分网络环境会返回 403:
Errors during downloading metadata for repository 'appstream':
- Status code: 403 for http://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 13.249.182.17)
定位:vault 归档源地域性访问受限。解决方案:改用阿里云 centos-vault 镜像,并把仓库路径指向当前系统版本号(8.4.2105,用 cat /etc/redhat-release 确认):
sed -i "s|http://vault.centos.org|https://mirrors.aliyun.com/centos-vault|g" /etc/yum.repos.d/CentOS-*.repo
sed -i "s|/centos/8/|/8.4.2105/|g" /etc/yum.repos.d/CentOS-*.repo
yum repolist
回显(三个仓库均正常列出):
repo id repo name
appstream CentOS Linux 8 - AppStream
baseos CentOS Linux 8 - BaseOS
extras CentOS Linux 8 - Extras
⚠️ 注意:第二行 sed 的
/8.4.2105/需替换为你服务器的实际系统版本(cat /etc/redhat-release查看)。若版本号与仓库目录不一致会导致 404。
三、版本选型说明
Caldera 官方源码仓库(github.com/apache/caldera)以 git tag 管理版本。安装前先查看当前所有稳定版本 tag:
git ls-remote --tags https://github.com/apache/caldera.git
回显(节选,按字典序排列的较新 tag):
9c0f41f688342e7f2c838dcfc42b2f09047e7a37 refs/tags/2.8.0
…
a1f6a919cbee846412fb273d357ccf7eea7de800 refs/tags/4.1.0
bcaac299e050ed7a1aa9b5bf2ea3d5537074acda refs/tags/4.2.0
9ceb72d7bd11a3c8dc3851c90d0899379ab250d1 refs/tags/5.0.0
cc4b9cdb31996f78027cee288d1b285e5335c9d2 refs/tags/5.1.0
06e4ded7bf4949a17a1437b7e25586f48e99564d refs/tags/5.2.0
dd22d543a519afe63ca35c454bf1add5d75c45dc refs/tags/5.3.0
| 版本代 | 说明 |
|---|---|
| 2.x / 3.x | 早期版本,UI 为旧式模板渲染 |
| 4.x | 4.0 起重构 API 层 |
| 5.x | 5.0 起前端改为 VueJS(magma 插件),需 Node.js 16+ 构建 |
解读:v5 系列是当前主线,其中 5.3.0 为本文实测的最新稳定 tag。生产环境建议直接安装 5.3.0(本指南即按此版本部署)。v5 的 UI 与 agent 通讯栈已与旧版差异较大,升级需整体迁移。
四、在线源码安装方案(官方推荐)
本章按「编译依赖 → 源码 → Python 依赖 → 前端依赖 → 配置 → 启动 → 验证 → systemd 托管」的完整 0→1 顺序执行。
4.1 安装编译依赖与 Python 3.9
Caldera 5.x 要求 Python 3.9+(README 明确「Python 3.9+ (with Pip3)」),而 CentOS 8 自带的 python3 是 3.6.8,不满足要求。AppStream 提供 python39 模块,直接安装:
yum install -y gcc gcc-c++ make git wget curl python39 python39-devel
回显(节选):
python3-setuptools-39.2.0-6.el8.noarch
python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
wget-1.19.5-10.el8.x86_64
Complete!
确认 Python 3.9 与 pip 可用:
python3.9 --version
python3.9 -m pip --version
回显:
Python 3.9.6
pip 20.2.4 from /usr/lib/python3.9/site-packages/pip (python 3.9)
⚠️ 为什么不用系统自带 python3(3.6.8)?Caldera 5.3.0 的 requirements.txt 中
websockets==15.0的 requires-python 为>=3.9,且 marshmallow 3.20 也要求 3.9+,Python 3.6/3.8 均无法安装依赖(详见「常见问题」6.1 节的实测排障)。
4.2 获取官方源码
官方推荐使用 --recursive --tag 完整克隆(plugins 全部是 git 子模块,其中 magma 插件含 VueJS 前端源码,缺少会导致启动失败):
cd /opt
git clone https://github.com/apache/caldera.git --recursive --tag 5.3.0
回显(节选):
Cloning into 'caldera'…
…
Submodule path 'plugins/sandcat': checked out '0a35cd525f1cfabfcf602282428055c41f144513'
Submodule path 'plugins/stockpile': checked out '08f37d8c1c5325910176d9fbaf9a83efccafd96c'
Submodule path 'plugins/training': checked out 'd4d19a2f1f829d5fea904a44e52a8ba5d7e07696'
⚠️ 若之前已用不带
--recursive的浅克隆拉了代码,启动时会报ModuleNotFoundError: No module named 'plugins.manx.app',补拉子模块即可:cd /opt/caldera && git submodule update --init --recursive
确认版本:
cd /opt/caldera
git log -1 --format="%H %s"
回显:
b24f6e7a99cab19cbf417009bda9b9c6c81abc31 app version tag
查看部署目录结构(节选):
ls -la /opt/caldera | head -15
回显:
drwxr-xr-x 11 root root 4096 … .
drwxr-xr-x 1 root root 4096 … ..
-rw-r--r-- 1 root root 2638 … .asf.yaml
-rw-r--r-- 1 root root 4552 … Dockerfile
-rw-r--r-- 1 root root 10172 … LICENSE
-rw-r--r-- 1 root root … README.md
drwxr-xr-x … app
drwxr-xr-x … conf
drwxr-xr-x … data
drwxr-xr-x … plugins
-rw-r--r-- … requirements.txt
-rwxr-xr-x … server.py
4.3 安装 Python 依赖
先升级 pip,再安装 requirements.txt(已装 gcc、python39-devel,绝大多数包使用预编译 wheel,无需本地编译):
python3.9 -m pip install --upgrade pip
cd /opt/caldera
python3.9 -m pip install -r requirements.txt
回显(节选,末尾):
Installing collected packages: webencodings, pytz, zipp, websockets, urllib3, …
Successfully installed Markdown-3.4.4 … aiohttp-3.10.11 aiohttp-apispec-3.0.0b2 … cryptography-44.0.1 … jinja2-3.1.6 ldap3-2.9.1 lxml-4.9.4 marshmallow-3.20.1 … pyyaml-6.0.1 reportlab-4.0.4 … websockets-15.0 yarl-1.22.0 …
⚠️ 注意:若误用
python3.8安装会在此步失败:ERROR: No matching distribution found for websockets==15.0(详见 6.1 节)。本方案全程使用python3.9。
验证核心依赖可导入:
python3.9 -c "import aiohttp, cryptography, websockets, jinja2; print('deps OK')"
回显:
deps OK
4.4 安装 Node.js 16(前端构建依赖)
v5 的 VueJS 前端在首次启动时通过 --build 构建,需要 Node.js 16+。CentOS 8 AppStream 提供 nodejs:16 模块:
dnf module install -y nodejs:16
node --version
npm --version
回显:
v16.13.1
8.1.2
💡 技术拓展:Caldera v5 前端构建工具链不止 npm 一种选择——
工具 特点 适用场景 npm(默认) Node 官方包管理器,安装依赖后 npm run build官方默认,v5 前端即以此构建 yarn 缓存更优、并行安装更快 前端团队习惯 yarn 的场合 pnpm 磁盘占用小、安装快 磁盘紧张或追求速度的场合 本文采用官方默认的 npm(
--build参数内部即调用npm install)。
4.5 修改默认配置(账号与密钥)
Caldera 的默认配置文件为 /opt/caldera/conf/default.yml。首次部署必须修改两项安全项:默认管理员口令与 API 密钥。
先查看默认的 users 段与 api_key 段:
grep -A 6 "^users:" /opt/caldera/conf/default.yml
grep -E "^(api_key_red|api_key_blue|encryption_key)" /opt/caldera/conf/default.yml
回显:
users:
blue:
blue: admin
red:
admin: admin
red: admin
api_key_red: ADMIN123
api_key_blue: BLUEADMIN123
encryption_key: ADMIN123
将 red 组管理账号 admin 的默认口令由 admin 改为统一示例口令 q1w2e3r4(首次登录后应再次修改为强口令):
sed -i "s|^ admin: admin$| admin: q1w2e3r4|" /opt/caldera/conf/default.yml
grep -A 5 "^users:" /opt/caldera/conf/default.yml
回显:
users:
blue:
blue: admin
red:
admin: q1w2e3r4
red: admin
⚠️ 注意:Caldera 自带两个组(red/红队、blue/蓝队),默认口令均为 admin。上述命令仅修改 red 组 admin 账号的口令;生产环境还建议同步修改
api_key_red、api_key_blue与encryption_key(各参数含义与改法见《Apache Caldera 配置参数详解》篇)。
4.6 启动服务并验证
首次启动使用 --insecure(等价 -E default,加载默认配置)并加 --build 构建 VueJS 前端:
cd /opt/caldera
nohup python3.9 server.py --insecure --build > /tmp/caldera.log 2>&1 &
启动日志(节选,前端构建约需 1–2 分钟):
WARNING --insecure flag set. Caldera will use server.py:219
the default user accounts in default.yml config file.
INFO Using main config from server.py:228
conf/default.yml
INFO Building VueJS front-end. server.py:265
…
INFO VueJS front-end build complete. server.py:268
INFO Enabled plugin: fieldmanual app_svc.py:131
INFO Enabled plugin: manx app_svc.py:131
INFO Enabled plugin: stockpile app_svc.py:131
INFO Enabled plugin: sandcat app_svc.py:131
…
INFO Enabled plugin: magma app_svc.py:131
INFO Creating SSH listener on 0.0.0.0, …
INFO serving on 0.0.0.0:2222 server.py:741
验证一:端口监听。确认 Web 服务与各通讯端口已监听:
ss -ltnp | grep -E "8888|7010|7012|8022|2222"
回显:
LISTEN 0 128 0.0.0.0:8888 0.0.0.0:* users:(("python3.9",pid=1334,fd=20))
LISTEN 0 100 0.0.0.0:8022 0.0.0.0:* users:(("python3.9",pid=1334,fd=19))
LISTEN 0 100 0.0.0.0:7010 0.0.0.0:* users:(("python3.9",pid=1334,fd=16))
LISTEN 0 100 0.0.0.0:7012 0.0.0.0:* users:(("python3.9",pid=1334,fd=8))
LISTEN 0 100 0.0.0.0:2222 0.0.0.0:* users:(("python3.9",pid=1334,fd=17))
验证二:Web 页面:
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://127.0.0.1:8888/
curl -s http://127.0.0.1:8888/ | grep -oE "<title>[^<]*</title>"
回显:
HTTP 200
<title>Magma | Caldera</title>
验证三:REST API 健康检查(使用 API 密钥头 KEY: ADMIN123,即 default.yml 的 api_key_red 默认值):
curl -s http://127.0.0.1:8888/api/v2/health -H "KEY: ADMIN123"
回显(节选):
{"application": "Caldera", "version": "5.3.0", "access": "RED", "plugins": [{"name": "access", "description": "A toolkit containing initial access throwing modules", "enabled": true, …}]}
验证四:WebUI 登录。登录端点为 POST /enter,使用表单(form)格式提交,成功返回 302 并下发 API_SESSION 会话 Cookie:
curl -s -v -X POST http://127.0.0.1:8888/enter -d "username=admin&password=q1w2e3r4" 2>&1 | grep -iE "HTTP/1.1|Set-Cookie"
回显:
< HTTP/1.1 302 Found
< Location: /
< Set-Cookie: API_SESSION="gAAAAABqzm3MP4g5ZkizMPFLbPmEGc1ITSxiJrGuhGivkKarlGFzI0AA1YIIWj5OmAlOKTwidLRrxMq8P_m_ykiYLk1TcWpauDzUBUXIoHY6pn5hi9NufAfTALI6gmC5AGJPHHOOWm69x7nXBzzvEEKnfEnldcNzgiWGAzvLKYAhyW5fwqJWEgQ="; HttpOnly; Path=/
⚠️ 注意:登录接口接收的是表单格式(
username=admin&password=q1w2e3r4),用 JSON 体(-d '{"username":"…"}')会因无法解析而登录失败——这是实测踩过的坑。
至此,Caldera 已在 CentOS 8 上完整运行。
4.7 systemd 托管
⚠️ 前置要求:本节 systemd 托管需要 Linux 真机(systemd 环境)。CentOS 8 服务器均满足;若在受限模拟环境无法复现
systemctl,属宿主能力限制,不影响真实服务器上的可用性。
创建服务单元 /etc/systemd/system/caldera.service:
cat > /etc/systemd/system/caldera.service <<'EOF'
[Unit]
Description=Apache Caldera
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/caldera
ExecStart=/usr/bin/python3.9 /opt/caldera/server.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
加载并启动(每个单元单独一行操作):
systemctl daemon-reload
systemctl enable caldera.service
systemctl start caldera.service
systemctl status caldera.service
预期回显(节选):
● caldera.service - Apache Caldera
Loaded: loaded (/etc/systemd/system/caldera.service; enabled; vendor preset: disabled)
Active: active (running) …
⚠️ 注意:生产环境请勿同时使用
nohup后台启动与 systemd 托管,二者取其一;systemd 托管的ExecStart不需要--insecure,应在配置文件中显式配置安全参数后直接server.py启动(详见《Apache Caldera 配置参数详解》篇)。
五、方案对比与选择建议
| 维度 | 官方源码安装(本文方案) | 离线/内网部署 |
|---|---|---|
| 版本 | 5.3.0(git tag 精确锁定) | 需提前下载源码包与依赖 wheel |
| 是否需联网 | 需要(GitHub、PyPI、npm) | 不需要 |
| 安装方式 | git clone + pip + npm | 拷贝源码 + 离线 pip/npm 源 |
| 前端构建 | 首次启动 --build | 需在离线环境预构建 |
| 优点 | 官方推荐、升级方便(git tag/fetch) | 断网隔离环境可用 |
| 缺点 | 依赖外网可达 | 依赖预下载工作量 |
解读:可联网环境直接采用本文方案;纯内网隔离环境需在一台可联网机器上先 git clone --recursive、pip download -r requirements.txt、npm pack 后整体搬运,并在目标机配置本地 PyPI/npm 镜像源。本文默认网络可达,仅详述在线方案。
六、配置说明
- 配置文件位置:
/opt/caldera/conf/default.yml,启动时可用-E <文件名>指定其他环境文件(-E default即 default.yml)。 - 常用键速览(完整详解见《Apache Caldera 配置参数详解》篇):
| 键 | 默认值 | 作用 |
|---|---|---|
| port | 8888 | Web/API 监听端口 |
| host | 0.0.0.0 | 监听地址 |
| api_key_red | ADMIN123 | 红队 API 密钥(HTTP 头 KEY:) |
| api_key_blue | BLUEADMIN123 | 蓝队 API 密钥 |
| encryption_key | ADMIN123 | 加密密钥(生产必改) |
| crypt_salt | REPLACE_WITH_RANDOM_VALUE | 加密盐(生产必改) |
| plugins | access…magma 共 15 个 | 启用的插件列表 |
| users | red/blue 两组 | 用户账号与口令 |
- 数据目录:
/opt/caldera/data(对象存储 object_store、本地存储 local_store);exfil 外传数据目录默认/tmp/caldera(键exfil_dir)。
七、常见问题(FAQ)
Q1:yum 安装报「Could not resolve host: mirrorlist.centos.org」
CentOS 8 已 EOL,官方源停服。按 2.2 节切换到阿里云 centos-vault 镜像(mirrors.aliyun.com/centos-vault),仓库路径中的版本号改为 cat /etc/redhat-release 所示实际版本。
Q2:用 python3.8 装依赖报「No matching distribution found for websockets==15.0」
实测排障过程:CentOS 8 默认 python3 为 3.6.8,安装 python38 后仍失败:
ERROR: Could not find a version that satisfies the requirement websockets==15.0 (from versions: 1.0, 2.0, ..., 13.1)
ERROR: No matching distribution found for websockets==15.0
定位:查询 PyPI 元数据确认 websockets 15.0 要求 Python ≥ 3.9:
curl -s https://pypi.org/pypi/websockets/15.0/json | python3.8 -c "import json,sys; d=json.load(sys.stdin); print(d['info']['requires_python'])"
回显:
>=3.9
解决:按 4.1 节安装 python39(3.9.6),改用 python3.9 -m pip install -r requirements.txt 即可成功。
Q3:启动报 ModuleNotFoundError: No module named 'plugins.manx.app'
根因:克隆源码时未带 --recursive,plugins 子模块未拉取。解决:
cd /opt/caldera
git submodule update --init --recursive
并在启动日志确认 Enabled plugin: magma(Vue 前端插件)。若用 --build 仍提示「Vue UI should be located in ./plugins/magma」,说明子模块仍未就位。
Q4:启动日志出现 go/upx 版本警告
WARNING go does not meet the minimum version of 1.19
WARNING upx does not meet the minimum version of 0.0.0.
go(1.19+)用于按需动态编译 Go 系 agent(sandcat),upx 用于压缩 payload,均为可选依赖,不影响核心框架运行;需要对应能力时再安装。
Q5:如何确认服务已停止?
ss -ltn | grep 8888
无输出即 8888 已关闭;或用 ps -ef | grep "[s]erver.py" 查看进程。
八、卸载与清理
停止服务:
systemctl stop caldera.service
systemctl disable caldera.service
rm -f /etc/systemd/system/caldera.service
卸载 Python 依赖并删除部署目录(先卸载依赖再删目录,否则卸载命令将无法读取 requirements.txt):
cd /opt/caldera
python3.9 -m pip uninstall -y -r requirements.txt
cd /opt
rm -rf /opt/caldera
清理数据目录(默认在 /opt/caldera/data 内,随目录一并删除):
rm -rf /opt/caldera
💡 说明:Caldera 无系统级服务安装包,卸载即「停进程 + 删目录 + 卸载 pip 依赖」三步;默认不写 /etc 全局配置(systemd 单元为管理员自建),无残留。
九、参考链接
- 官方文档:https://caldera.apache.org
- 源码仓库:https://github.com/apache/caldera
- 安装说明(README Requirements/Installation):https://github.com/apache/caldera/blob/5.3.0/README.md
- 阿里云 centos-vault 镜像:https://mirrors.aliyun.com/centos-vault/