【THM】Daily Bugle-练习

本文相关的TryHackMe实验房间链接:https://tryhackme.com/room/dailybugle

通过学习相关知识点:通过SQLi渗透Joomla CMS的用户帐户,进行哈希破解并利用yum完成提权操作。

image

部署目标机

部署机器(重新部署靶机将导致目标ip发生变化),访问目标站点。

image

获取用户权限

使用nmap进行端口扫描

nmap -Pn -sC -sV 10.10.74.183

image

由扫描结果得知:目标站点使用的CMS应该是Joomla CMS,并且还开启了mysql服务。

使用gobuster进行目录扫描

gobuster dir -u http://10.10.74.183/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --no-error

image

查看网站robots文件

image

访问网站的管理页面( http://10.10.74.183/administrator/ ),成功进入到网站管理系统的登录页面。

image

使用joomscan针对目标站点进行扫描,joomscan是一个专门用于扫描Joomla CMS的工具。

joomscan -u http://10.10.74.183 #此处ip为目标ip
#也可以通过浏览器在线快速获取Joomla CMS的版本信息:直接访问10.10.74.183/language/en-GB/en-GB.xml即可。

image

image

可知目标所使用的Joomla CMS版本为:Joomla 3.7.0

image

在漏洞库中搜索该CMS 版本,发现存在SQL注入漏洞,此漏洞详情可以参考:https://blog.sucuri.net/2017/05/sql-injection-vulnerability-joomla-3-7.html

image

image

在此我们不使用exploit-db所提供的exp,转而使用另外一个Python形式的exp方案:https://github.com/XiphosResearch/exploits/tree/master/Joomblah

具体的脚本地址为:https://github.com/XiphosResearch/exploits/blob/master/Joomblah/joomblah.py

wget https://raw.githubusercontent.com/XiphosResearch/exploits/master/Joomblah/joomblah.py
sudo python2 joomblah.py http://10.10.74.183
#此处ip为目标ip

image

image

成功获取到用户名和密码信息:jonah、$2y$10$0veO/JSFh4389Lluc4Xya.dfy2MF.bZhz0jVMw.V.d3p12kBtZutm

查询上述hash值的加密方式( https://hashcat.net/wiki/doku.php?id=example_hashes )并使用john工具进行hash破解(需要提前将hash值保存为txt文件)

john --wordlist=/usr/share/wordlists/rockyou.txt jonahhash.txt --format=bcrypt

image

破解得到的hash密码明文为:spiderman123

image

jonah:spiderman123登录目标站点的CMS管理后台( http://target_ip/administrator/ ),进入templates即模板界面,找到模板beez3并在index.php中写入反向shell脚本内容,参考以下链接(记得修改ip和端口):https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php

image

image

image

在本地机上建立一个Netcat监听器,然后访问已修改的CMS模版主页面(http://ip/templates/beez3/index.php ),即可成功在本地机终端获得一个shell界面。

image

image

image

获取到目标网站的shell之后:查看身份权限,切换至/home目录查看用户信息,前往网站目录(cd /var/www/html)检查配置文件。

image

image

我们在网站目录下的configuration.php文件中发现一个凭据:nv5uz9r3ZEDzVjNu

继续使用当前shell界面,尝试通过刚才获取的凭据来切换用户身份

image

成功切换为jjameson用户,查看到的user.txt的内容为:27a260fe3cba712cfdedb1c86d80442e

image

提权-获取root权限

基于上一小节的shell界面(身份为jjameson),输入命令sudo -l检查用户 jjameson 的 sudo 权限。

image

由上述结果可知:用户 jjameson可以以 sudo 身份运行 yum命令

https://gtfobins.github.io/ 网站查找yum在sudo身份下的提权方式。

image

为了方便操作,我们可以通过ssh连接到jjameson用户(登录凭证和前面的相同),然后再复制以上提权命令到ssh界面直接执行,即可得到root shell。

image

image

输入命令进入/root目录并查看root.txt内容。

image

root.txt内容为:eec3d53292b1821868266858d7fa6f79

image

posted @ 2023-02-10 20:41  Hekeatsll  阅读(227)  评论(0编辑  收藏  举报