Schooled, a FreeBSD machine on Hackthebox created by user TheCyberGeek was a medium difficulty machine. Initial foothold on this machine was Cross-Site Scripting (XSS) attack to steal Teacher cookie. After getting Teacher account It was about using an CVE CVE-2020-14321 to get an RCE and a shell. After getting shell on the box it is about finding a hash cracking it and using that password to get user on the box. Privilege Escalation on the box was about creating a malicious package and installing it which get us root.
Initial Enumeration
nmap
1
$ nmap -sC -sV -oN nmap/schooled 10.10.10.234
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-04 12:27 IST Nmap scan report for 10.10.10.234 Host is up (0.083s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9 (FreeBSD 20200214; protocol 2.0) | ssh-hostkey: | 2048 1d:69:83:78:fc:91:f8:19:c8:75:a7:1e:76:45:05:dc (RSA) | 256 e9:b2:d2:23:9d:cf:0e:63:e0:6d:b9:b1:a6:86:93:38 (ECDSA) |_ 256 7f:51:88:f7:3c:dd:77:5e:ba:25:4d:4c:09:25:ea:1f (ED25519) 80/tcp open http Apache httpd 2.4.46 ((FreeBSD) PHP/7.4.15) | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Apache/2.4.46 (FreeBSD) PHP/7.4.15 |_http-title: Schooled - A new kind of educational institute Service Info: OS: FreeBSD; CPE: cpe:/o:freebsd:freebsd
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 18.44 seconds
we see two ports open 22 and 80 from SSH banner we know it is (FreeBSD 20200214; protocol 2.0)
Lets Enumerate more on 80
Web (80)
from page we find an email admissions@schooled.htb so i kept that in note
I also added schoooled.htb in my hosts to see if we get something else
Using that i get a session as Manuel Phillips After this I was stuck on this for very long and googling around i found an CVE-2020-14321 and a videogithub
following the step in the video i was able to get a shell as www
www
Enumerating the box I found db credentials as moodle:PlaybookMaster2020
jamie@Schooled:~ $ sudo -l User jamie may run the following commands on Schooled: (ALL) NOPASSWD: /usr/sbin/pkg update (ALL) NOPASSWD: /usr/sbin/pkg install *
we see we can install a pkg without password
so lets create a malicious package and try installing it
jamie@Schooled:/tmp/.f3v3r $ sudo pkg install *.txz Updating FreeBSD repository catalogue... pkg: Repository FreeBSD has a wrong packagesite, need to re-create database
but got this error checking the man page of pkg-install
we see an option as --no-repo-update
running
1 2 3 4 5 6 7 8 9 10 11 12
$ sudo pkg install --no-repo-update *.txz pkg: Repository FreeBSD has a wrong packagesite, need to re-create database ..[snip].. New packages to be INSTALLED: f3v3r: 1.0_6
Number of packages to be installed: 1
Proceed with this action? [y/N]: y [1/1] Installing f3v3r-1.0_6... Extracting f3v3r-1.0_6: 100% Registering root shell