✴️Node

Node is a medium level boot2root challenge, originally created for HackTheBox. There are two flags to find (user and root flags) and multiple different technologies to play with.

1. Reconnaissance

Scanning the network to find vulnerable machine's IP

arp-scan -l

Interface: enp0s3, type: EN10MB, MAC: 08:00:27:9c:9d:c8, IPv4: 192.168.10.25
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.10.1	52:54:00:12:35:00	QEMU
192.168.10.2	52:54:00:12:35:00	QEMU
192.168.10.3	08:00:27:ec:f5:6b	PCS Systemtechnik GmbH
192.168.10.27	08:00:27:9e:3e:6f	PCS Systemtechnik GmbH

4 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 2.291 seconds (111.74 hosts/sec). 4 responded
  • We find the IP of the vulnerable machine to be 192.168.10.27

2. Scanning

2.1 Nmap

  • Using nmap to find the open ports and their services

  • We find 2 open ports, tcp ports 22 and 3000 with a ssh and a web server with apache hadoop running respectively

:3000

  • Visiting the webpage at :3000 , we are greeted with a welcome page

  • Exploring the source code of the homepage, we can see a number of javascript files.

  • As we check out each of them, we see a very interesting endpoint referenced in /assets/js/app/controllers/home.js which points to /api/users/latest

  • Navigating to the endpoint /api/users/latest, we see the usernames and passwords of the newest members who were shown in the homepage who are normal users.

  • Navigating up to /api/users, we get admin credentials

  • Trying to decode the password hash dffc504aa55359b9265cbebe1e4032fe600b64475ae3fd29c07d23223334d0af using crackstation

  • We find that it is a common word and can be cracked. We get the admin credentials

myP14ceAdm1nAcc0uNT : manchester

  • Login in with the credentials from the hompage

  • We are greeted with a minimal admin page with an option to download backup

  • Downloading the backup myplace.backup and examining the file type

  • We can see that although its file type is ASCII text, we we view the file, we can see that it is base64 encoded.

  • Decoding the file and saving it to decopde_backup

  • Now if we examine the decoded file, we can see that it is a zip file which is password protected

2.2 Brute-Forcing zip password

  • We can use fcrackzip to bruteforce the password

  • Using the password magicword, we can extract the zip file.

  • Extracting it, we find out that it contains the copy of the var directory of the target.

  • After further examination we find the credentials of user mark in /var/www/myplace/app.js file

mark : 5AYRft73VtFpc84k

3. Initial Foothold

3.1 SSH

  • We can log in via ssh as user mark with the password.

  • We find the user.txt flag in the home directory of user tom which cannot be accessed by user mark

3.2 Lateral Movement

  • Sidenote: We are moving to the next step, as that was the intended way of solving the box when it was released. After its release, a kernel exploit was found which can directly give us root access. We use this kernel exploit to gain root access once we get the user.txt using the original intended method. You can totally bypass the next few steps and directly use the exploit to get root. Personally, I felt that solving the box this way helped me to learn some more

  • In order to change to user tom we can first find out if they are running any processes currently.

  • We see an interesting process run by tom at /var/scheduler/app.js which has a similar structure as our backup files.

  • Viewing app.js

  • Here, we see that after very 30 seconds, the user tom logs in as mark to the database (MongoDB) and checks if there are any tasks. If there are, he executes the task with doc.cmd and then deletes them.

  • We can modify this to spawn us a shell.

  • Logging in as mark to the database.

  • We can modify the command to include a netcat reverse shell from pentestmonkey

  • Starting an nc listener, capturing and stabilizing the shell

  • Reading user.txt

4. Privilege Escalation

  • The kernel version of the machine is outdated and vulnerable to CVE-2017-16995

  • Downloading the exploit (44298)from ExploitDB to the tmp directory of our target and renaming it as 44298.c

  • Compiling it to exploit and executing it.

  • We are root

  • Reading the contents of root.txt

Last updated