No.186-HackTheBox-Linux-ForwardSlash-Walkthrough渗透学习

**

HackTheBox-Linux-ForwardSlash-Walkthrough

**
靶机地址:https://www.hackthebox.eu/home/machines/profile/239
靶机难度:中级(3.8/10)
靶机发布日期:2020年7月1日
靶机描述:
ForwardSlash is a hard Linux machine featuring a compromised server. Through directory busting it is possible to identify a virtual host that points to a backup instance of the website. After registering a new account, an LFI vulnerability is identified through a disabled HTML form. The LFI vulnerability can be used to access the dev endpoint, which only allows local connections. The dev page accepts XML input and an XXE vulnerability is identified. Successful exploitation of the vulnerability leads to the disclosure of FTP credentials for the user chiv . As the credentials have been reused for SSH, it is possible to gain a foothold on the server. A SUID binary is found that attempts to read files whose name is the MD5 hash of the time the binary is run. A symbolic link is created that points to a backup of a PHP configuration, leading to disclosure of credentials for the user pain . These new credentials also work with SSH, and the user flag is acquired. Finally a cipher text is found in the user’s home directory along with the
code used to encrypt it. Upon successful creation of a decryption script, a password is revealed. This can be used to decrypt a LUKS image found at /var/backups/recovery . The image contains the RSA private key for the root account.

作者:大余
时间:2020-08-18

请注意:对于所有这些计算机,我是通过平台授权允许情况进行渗透的。我将使用Kali Linux作为解决该HTB的攻击者机器。这里使用的技术仅用于学习教育目的,如果列出的技术用于其他任何目标,我概不负责。

一、信息收集

在这里插入图片描述
可以看到靶机的IP是10.10.10.183…
在这里插入图片描述

我这里利用Masscan快速的扫描出了22,80端口,在利用nmap详细的扫描了这些端口情况…

在这里插入图片描述
可看到该页面被Backslash Gang黑客组织入侵了…提示正在使用XML和FTP自动登录…
在这里插入图片描述
爆破目录发现存在note.txt…
在这里插入图片描述
提到了一个备用站点…需要找到,继续爆破…
在这里插入图片描述
命令:wfuzz -c -u 10.10.10.183 -H "Host: FUZZ.forwardslash.htb" -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --hh 0
爆破发现了backup.forwardslash.htb备用站点信息…添加

在这里插入图片描述
这是登录表单页面…
在这里插入图片描述
这里我继续挂着爆破,发现了dev、register.php等页面信息…先放着、
在这里插入图片描述
点击登录表单页面的sign up now注册用户密码…
在这里插入图片描述
然后登录后,welcome.php仪表板页面…很多信息…
在这里插入图片描述
在Change Your Profile Picture功能中,定向到profilepicture.php页面显示一个标记为URL的文本字段,该字段和提交按钮都通过HTML被禁用了,并且有一条注释提示这是由于黑客入侵造成的…
在这里插入图片描述
这里在F12调用中,找到URL和Submit源码,然后去掉disabled=即可执行功能…
这里经过多次尝试,还是较麻烦的,我利用了burpsuit进行拦截注入…
在这里插入图片描述
很简单的LFI…查看到了etc/passwd信息…
在这里插入图片描述
继续进一步枚举,发现dev页面提示本kali地址被阻止了…这里尝试使用带有Base64 endo的php写入看看…
在这里插入图片描述
获得了base64编码…
在这里插入图片描述
正常解析是前段源码信息…我们枚举下dev阻止的信息是什么…
在这里插入图片描述
命令:url=php://filter/convert.base64-encode/resource=dev/index.php
可看到获得了base64编码…继续编译
在这里插入图片描述
在前段源码发现了chiv用户名密码信息…
这里还有另外一种思路,可以利用XXE代替LFI获得用户名密码…
在这里插入图片描述
查了SUID情况,发现backups下的config.php.bak很熟悉,这是存放用户名密码的文件…
以及backup二进制程序…
找到该目录发现了需要解密了…
在这里插入图片描述
运行backup,ERROR报错了一串32位的数值,经过尝试这是md5数值…反编译发现这就是时间…
在这里插入图片描述
这里写简单的脚本,利用md5数值查看到了config.php.bak信息,里面包含了pain用户名密码…
在这里插入图片描述
ssh登录进pain界面,获得了user_flag信息…
在这里插入图片描述
首先sudo -l 发现三组命令可直接root的…
然后在encryptorinator目录中,有一个加密密钥和一个Python脚本…
查看该脚本是解密的脚本提示信息…需要解密ciphertext…

在这里插入图片描述
google发现了很多文章提示,还需要一个LUKS分区才能解密,在前面suid中发现的目录下发现了var/backups/recovery/encrypted_backup.img分区…果然是需要密码的…解密
在这里插入图片描述
稍微修改下解密脚本,在本地进行了破解,获得了密码…
在这里插入图片描述
命令:

sudo /sbin/cryptsetup luksOpen /var/backups/recovery/encrypted_backup.img backup
mkdir mnt
sudo /bin/mount /dev/mapper/backup ./mnt/

为了挂载映像,这里使用cryptsetup命令解密图像并进行安装…
在执行了sudo挂载后,获得了id_rsa文件信息…
在这里插入图片描述
最后通过id_rsa登录了root用户界面,获得了root_flag信息…

https://elephly.net/posts/2013-10-01-dm-crypt.html
这里针对以上的界面信息,还可以用这篇文章方法进行提权root…多操作几次就能理解原理了…我这里将得可能不是很详细…自己多搜索吧…加油

由于我们已经成功得到root权限查看user和root.txt,因此完成这台中级的靶机,希望你们喜欢这台机器,请继续关注大余后期会有更多具有挑战性的机器,一起练习学习。

如果你有其他的方法,欢迎留言。要是有写错了的地方,请你一定要告诉我。要是你觉得这篇博客写的还不错,欢迎分享给身边的人。

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值