Hi! Let’s go with nmap:
Added
10.10.11.239 codify.htb
to hosts.
I assume that it’s apache revproxy, but let’s check port 80 and 3000 in browser.
ffuf found nothing interesting.
How I assumed port 80 is reverse proxy to port 3000, in real world configuration port 3000 should be blocked by firewall.
Untitled.avif
We have quite interesting web service that provides way to run nodejs code with some restrictions.
From about page I found that it uses vm2 library, and link to it points not to releases page, but to
3.9.16 release, so I assume it uses vm2 3.9.16
Searched web for CVEs in vm2.
-
Found CVE-2023-29199, but it was patched in 3.9.16 which I assume is our version.
-
Found CVE-2023-30547, it was patched in 3.9.17
-
Found CVE-2023-37466, it was patched in 3.9.19
I’ll search exploits for this two CVEs
Found this:
First I’ll try exploit from gist, it seems easier to use.
It works! Let’s put revshell there and run listener.
nc -lvnp 4444
And we got shell!
There is .pm2 folder so pm2 might be helpful.
I checked all of them, all just run
/var/www/editor/index.js
While investigating machine I found
Looking into /var/www/contact/index.js
I found that it saves creds to /var/www/contact/tickets.db
I ran python3 -m http.server
and downloaded it on my machine
wget 10.10.11.239:8000/tickets.db
Returning to db file:
So i ran
sqlite3 tickets.db
That’s hash! let’s crack it with hashcat
echo -n '$2<REDACTED>' > hash
Looking thru
example hashes I found it’s 28400 bcrypt(sha512($pass)) / bcryptsha512
hashcat.exe -m28400 hash /usr/share/wordlists/rockyou.txt
It can’t crack it. I don’t really like it. Maybe let’s try john?
Untitled-1.avif
It did work… Why? Possibly I made something wrong with hashcat…
We login thru ssh.
Let’s start privesc:
So we can run that script that I’ve seen before with sudo. Let’s view it again.
So we can just bruteforce password with a basic script:
Got password with it!
Pwned!