Post

devguru-1 Walkthrough

.git泄露,cms打点、gitea提权、sudo提权

devguru-1 Walkthrough

Recon

这台机器开放了标准端口的ssh、http和8585/tcp的Golang web

image-20251004160659808

Web

80端口是一个官网

image-20251004160904068

8585端口是Gitea

image-20251004160943193

对80端口目录扫描,发现存在.git泄露以及/backend后台

image-20251004194542504

使用git-dumper转储,发现存在adminer.php

image-20251004194800930

在conf/database.php中得到数据库凭证

image-20251004195025548

登录adminier,查询数据得到Frank密码hash

image-20251004195256667

使用https://www.tunnelsup.com/hash-analyzer/判定为bcrypt

使用https://bcrypt-generator.com/生成bcrypt,修改密码hash为已知密码hash进行登录

image-20251004200322343

image-20251004200511814

shell as www-data by october-cms

根据页面内容能发现这是october-cms

编辑Home page,在code中写入onStart()生命周期函数,写入myVar变量一句话木马

image-20251004203001709

在markup中添加模板标签调用myVar

image-20251004204217290

传递?cmd参数执行命令,使用wget落地reverse.php反弹shell

image-20251004204231369

image-20251005131904662

shell as frank by gitea

例行检查,发现frank系统用户,8585的gitea是以用户frank身份启动

那么当前的重点就是通过gitea getshell

image-20251005132325945

查看/etc/gitea/app.ini,没有权限

通过find命令发现/var/backups/app.ini.bak

image-20251005132544428

得到数据库账号密码

image-20251005133036146

得到frank密码hash,此处使用的是pdkdf2

image-20251005133433719

修改密码hash和加密算法,使用bcrypt

image-20251005133719218

登录成功

image-20251005133751213

gitea版本为1.12.5,存在后台RCE

在Git Hooks中添加反弹shell代码

image-20251005134617669

然后修改仓库Readme.md后提交,会触发git commit然后被git hooks捕获触发反弹shell代码

image-20251005134941059

shell as root by sudo

例行检查发现能sudo执行/usr/bin/sqlite3,但是只能使用非root权限

image-20251005135117435

sudo -V查看版本,能对应上一个bypass漏洞https://www.exploit-db.com/exploits/47502

image-20251005135226481

使用poc getshell

image-20251005135635899

This post is licensed under CC BY 4.0 by the author.