Adhyan Agarwal logoadhyan agarwal
BACK TO ARCHIVE
HTB|2017.03.22

Cronos — SQLi Auth Bypass & Command Injection to Laravel Cron Root

OS

Linux

Difficulty

Medium

Category

WEB

Released

2017.03.22

Fuzzed a virtual host to reach an admin panel, bypassed its login with SQL injection, and turned the panel's net-tool feature into command injection for a shell as www-data. Found database credentials in config.php, then escalated by overwriting the www-data-owned Laravel artisan file that a root cron job runs every minute with a PHP reverse shell.

Want to try this box yourself?

Spoiler-free mode is on by default — every solution stays hidden behind a reveal. Peek the hints, attempt each step, then unlock the answer when you're stuck. Turn it off to read every solution inline.

Nmap

Full Port Scan

Script and Service Scan

Enumeration

The web page is a simple landing page. We scan for subdirectories and subdomains.

The subdirectory scan does not reveal anything, but the subdomain fuzzing shows a subdomain.

ffuf -u 'http://cronos.htb/' -H "Host:FUZZ.cronos.htb" -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt -fw 3534

        /'___\  /'___\           /___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://cronos.htb/
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt
 :: Header           : Host: FUZZ.cronos.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response words: 3534
________________________________________________

www                     [Status: 200, Size: 2319, Words: 990, Lines: 86, Duration: 375ms]
admin                   [Status: 200, Size: 1547, Words: 525, Lines: 57, Duration: 3977ms]
:: Progress: [19966/19966] :: Job [1/1] :: 1041 req/sec :: Duration: [0:00:24] :: Errors: 0

We add admin.cronos.htb to the /etc/hosts file.

Cronos admin login page

The login page is vulnerable to SQLi.

SQL injection authentication bypass on the admin login

This gets us onto the admin page.

The admin net tool interface after bypassing the login

This page appears to take a command and a host, then executes them.

Intercepting the request in Burp Suite, we find it is vulnerable to command injection.

This gives us command execution on the box as the user www-data.

Command injection returning output as www-data

Initial Access

We use a simple reverse shell.

Sending the reverse shell payload through the injection point

The application hangs, and we get a shell.

Reverse shell connection received as www-data

Lateral Movement

The /etc/passwd file reveals another user named noulis.

The directory contains a config file that holds database credentials.

The box runs MySQL.

However, no credentials are stored for any users.

Privilege Escalation

There is a cron job running as root every minute.

The artisan file is owned by www-data, so we can overwrite it with our own malicious code, in this case a PHP reverse shell.

We start a listener:

Overwriting artisan and catching the root callback

Root shell from the scheduled artisan job