Hackthebox Node Walkthrough
07 Apr 2020
Explanation
Hackthebox is a website which has a bunch of vulnerable machines in its own VPN.
This is a walkthrough of a box “Node”.
Solution
1. Initial Enumeration
TCP Port Scanning:
2. Getting User
We can find a NodeJS website on port 3000.
Using Burp Suite, we can find an interesting HTTP request to “/api/users/latest”.
Then, access to the API.
We can see some passwords for user “tom”, “mark” and “rastating”.
Next, try “/api/users”.
We can find an admin user “myP14ceAdm1nAcc0uNT”.
We can crack the password using Crackstation.net.
The cracked password is “manchester”.
We can download a file “myplace.backup” base64 encoded.
Try to decode with base64 command.
Since the zip file is password protected, try to brute-force using “fcrackzip”.
The password is “magicword”.
Then, unzip the archive.
It looks like a source code of a NodeJS web application.
Take a look at the source code.
In “/var/www/myplace/app.js”, we can find a mongodb credential for user “mark”.
We can use the credential for SSH connection.
However, we are still not capable of getting user.txt.
We have other 2 users.
If take a look at the processes, we can see 2 processes by another user “tom”.
Using the following command, we can access the command line interface of MongoDB.
Also it is possible to insert reverse shell command.
Launch a netcat listener.
After a few minutes, we can get a reverse shell as user “tom”.
user.txt is in the directory “/home/tom”.
3. Getting Root
With the following command, we can find a binary file “/usr/local/bin/backup”
Also, we can find a way to use this executable in the previous script “/var/www/myplace/app.js”.
The “backup_key” is also in this code.
This time, we can bypass the filter of the binary with the following way.
Now we extracted the root.txt