Hackmyvm: Chromatica

Vishal
4 min readMay 19, 2024

--

Let’s solve the Chromatica machine from hackmyvm.

It is the easy machine with SQLi which give us few password hashes and usernames, then we need to SSH (which is little bit tricky) and then exploit the cron job to get shell as another user. Then there is a privilege escalation using sudo by nmap command.

Let’s begin with nmap to enumerate the open ports and services running on those ports. Nmap shows only three ports open.

nmap showing ports 22,80 and 5353 ports open

Use wfuzz or dirb to bruteforce webpages and directories on web app.

wfuzz shows robots.txt

When I visit the robots.txt, I got below entry.

robots.txt

I tried to visit dev-portal, but got Forbidden.

dev-portal

I tried to fuzz using wfuzz, but did not get any additional directory or web page. Then I change tried changing the User-Agent header to dev and tried to access the dev-portal.

I added the rule in burp suite to replace User-Agent header with that of “User-Agent: dev” and then visit the /dev/portal and it shows me below web page.

This page allow us to search cities.

Let’s use SQLmap to find sql injection. For that save the request in a file and use that with SQLmap. Sqlmap says the URL is vulnerable.

SQL injection using SQLmap

SQLmap discovered couple of databases.

Sqlmap showing databases

Let’s enumerate Chromatica database and try to find the tables in it.

Tables in Chromatica db

We are interested in users table, lets enumerate the columns of users table.

columns in user tables

Let’s find username and password.

username and passwored hashes

I use crackstation to crack the remaining hashes.

Cracked hashes

Stored username and hashes in separate files to bruteforce SSH login. Used hydra and it found the correct combination.

hydra: ssh creds

As soon as I tried to login in ssh, I did not get the access to the box.

SSH login with dev user

I again enumerate the /dev-portal directory and found login.php

use creds found in hydra, dead end

The login.php was a rabbit hole. I again moved towards SSH, reduced the size of my terminal to minimum I can do and the use !/bin/bash after my creds when it shows more option.

While enumerating the box further, I noticed a cron running every minute with user analyst.

Let’s see the permission and contents of a shell script /opt/scripts/end_of_day.sh

That is very dangerous permission as whole world can read and write into it. We can write a reverse shell code into this which can call back us at a listener.

shell as analyst user

I use command to check sudo permissions for user analyst and it shows analyst can run nmap without password.

sudo -l output

using nmap, able to escalate the privilege to the root.

So this is how we are able to get the root on the box Chromatica from hackmyVM.

I searched for why we are unable to get the dev-portal with normal User-Agent, the apache2.conf file has below line mentioned which blocked us from accessing dev-portal with normal user agent.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response