HacktheBox - Retired - Frolic
Recon
Let's start out with a threader3000 scan
Some interesting results here
Port 22 and 445 aren't uncommon… but 1880 and 9999 are..
Let's let nmap run through these ports
This looks like a ubuntu box but with samba? Weird
A listing shows some shares.
Strange.
Ok what about those other ports
1880 says it's http Node-red Node.js
9999 says it's nginx
Let's try to browse to them.
On port 1800 we see this
Node-Red
Ok
What about port 9999
Just the default nginx page
I ran auto-recon on this box vi ip address and it came back with a couple of directories on port 9999 one of which is /admin
Ok let's check out the source code.
What is that login.js?
Is that a hard coded user/pass?
Yup
Ok but it then redirects to this.
Looks like something encoded, maybe? This looks interesting….
So after some googling I figured out this is a representation of the ook programing language… Luckily the decode.fr has a decoder for it.
https://www.dcode.fr/ook-language
The decoding is..
Nothing here check /asdiSIAJJ0QWE9JAS
Ok let's check out that directory on port 9999
Another cipher
Throwing a bunch of stuff from cyber chef at it I noticed this in base64
Could this be the hex of a file?
I saved the hex output from cyberchef
Looked at it in a hex editor
It starts with PK, which a quick google search leads us to
It might be a .zip file
Ok let's rename it using mv
Yay it is a zip file that looks like it contains index.php…. But the thing is password protected.
Let's run it through fcrackzip
Password is password.
And honestly what do we expect here?
More encoding..
And cyber chef again from hex gives us what looks like base64 again.
Which of course gives us something else
Which is also some ancient programming language called brainfuck.
Decode.fr to the rescue again.
https://www.dcode.fr/brainfuck-language
idkwhatispass
Well at least it's not encoded anymore, I'm assuming this is the password for something.
It didn't work for the node-red thing…. Let's through dirb at the 2 ports we found with webservers to see if we can come up with another place to login.
Dirb found this directory
Which looks like it points to another directory /playsms
Which is asking for a login let's try admin and the decoded one we got
That worked
What is playsms?
Ok
A google for vulns shows this github for authenticated RCE.
https://github.com/jasperla/CVE-2017-9101
Let's give it a shot
Exploit
Looks like it works!
Let's get a shell with this
Let's change it to interactive mode
After some working with this I couldn't get a shell to stay open, it would die immediately after connecting to get around this
I made a rs.sh file in /tmp/circusmonkey and used echo to fill it with my command
and then used the 'interactive' POC to give that file execution rights and called it
And now we have a better shell to figure out or priv esc in.
Contents of user.txt and password.txt from /var/www/html/backup
Linpeas shows an interesting SUID binary
In /home/ayush/.binary/rop
It looks like it just dumps what ever is thrown at it to a message.
First let's take a look at the binary to see if any restrictions are in place
ASLR is not enabled on the box
What about the NX bit on the binary
Well that sucks there is no execution set for the stack, so we can't just drop shell code into the stack and get execution. We will have to use another method to get our shell.
File output shows it to be a 32-bit binary
Let's see if we can overflow it
We sure can… let's try to exploit it
https://niiconsulting.com/checkmate/2019/09/exploiting-buffer-overflow-using-return-to-libc/
Let's use nc to copy this file over to our kali box to see if we can craft an BOF exploit for it.
New listener on kali
Send it from frolic
Let's load the file up in gdb
If you don't already have peda installed for gdb install it from here
https://github.com/longld/peda
Launch gdb
Set the file
Now we test just to make sure it runs like we think
Good, let's try to crash it again in gdb
Yup, let's find the offset
First let's use pattern create to make a pattern we can use to search for the offset using pattern_create
This creates a file named buffer with a unique string of 500 characters.
Then we just feed that file named buffer into the ./rop
And now we can use pattern_find to find the offset
I kept having problems here with this large of a pattern, I couldn't find the offset so I dropped it down to 100
Then pattern_offset search for "AAGA"
So our offset is 52
Let's try to send 52 A's followed by 4 B's to see if we overwrite the $eip with B's
Good that worked we can control the $eip
Ok now we need to figure out all the stuff we need to do a libc attack on this binary..
Start out by finding the version/location
Base b7e19000
Next we need to find the address for /bin/sh
15ba0b
Then we need to find system and exit
System
003ada0
Exit
0002e9d0
Ok we have what we need to exploit this thing.
Base 0xb7e19000
/bin/sh 0x0015ba0b
System 0x0003ada0
Exit 0x0002e9d0
Now we just need to build out a python script that will combine all these for us
Save all this to a python script I named frolic.py on frolic
Then run ./rop calling this script
We are root
Now we can just grab our flag and submit it
Comments
Post a Comment