User flag

Started by doing some nmap scans:

Pasted image 20250506102143.png

Pasted image 20250506102149.png

Pasted image 20250506102156.png

Pasted image 20250506102204.png

Pasted image 20250506102212.png

The only interesting port seems to be port 80, so lets enumerate it.

Found a statistics vhost but returning a 401 unauthorized http code:

Pasted image 20250506102228.png

Still, gonna add it to the /etc/hosts file. Going to this subdomain, we are asked for credentials:

Pasted image 20250506102242.png

The login form is simply sending the username and password, base64 encoded, in the authorization header:

Pasted image 20250506102421.png

I also did a dir scan on the page, but only got the expected results, except for a messages page:

Pasted image 20250506102440.png

This might be the page where the administrator sees the messages we sent by the contact form:

Pasted image 20250506102452.png

Pasted image 20250506102456.png

By going to this page we get a 200 http code, but the page is empty:

Pasted image 20250506102506.png

Finally, I also did a file inclusion scan to see if I could get any files returned, but got nothing.

Lets move on to the markdown viewer functionality. I recently done a box in htb were there also was a markdown viewer and there, I spent quite some time trying to do some XSS attacks (with no success). But since this box is called Alert, I immediately am thinking we can do some of those.

I created a markdown file with some simple XSS payloads:

Pasted image 20250506102545.png

Some markdown viewers also process html tags, so lets try it:

Pasted image 20250506102558.png

Success. So now for the exploitation:

Pasted image 20250506102607.png

We get a request back, but no cookie:

Pasted image 20250506102614.png

If we generate a valid md file:

Pasted image 20250506102623.png

We get a link to share the md file. We can check if sending this url through the contacts form, if the administrator clicks it.

Pasted image 20250506102654.png

This script will get the index page, convert it to text, then URI encode the text and send it to my nc listener. So lets see if we receive anything when we share the link with the administrator.

Pasted image 20250506102710.png

When we generate the md, we receive data and when we share it with the contacts page:

Pasted image 20250506102727.png

We receive it as well. So we can confirm that the administrator is clicking in the url that we sent him thought the contact form.

Now, lets remember that there was a messages page, that seemed that only the administrator could see. We can use this exploit to send the data of the messages page back to us.

Pasted image 20250506102746.png

We do the same process of sharing the md url and wait for the data:

Pasted image 20250506102755.png

By decoding the date we can see that there a link to a file in the messages.php page. Lets download it:

Pasted image 20250506102805.png

We do the same process and we get:

Pasted image 20250506102819.png

Humm, it seems that the file is empty? But if we can read this file maybe now we can do the file inclusion vulnerability.

Pasted image 20250506102826.png

Pasted image 20250506102832.png

We got it.

From the nmap scan we know that the webserver is an apache http server. So lets try to get some of its conf files:

Pasted image 20250506102842.png

We get the apache conf file and looking and the decode data we find:

Pasted image 20250506102851.png

We know that there is a statistics vhost, so lets get its conf:

Pasted image 20250506102858.png

We get no data. Lets try the default sites available apache naming:

Pasted image 20250506102906.png

Pasted image 20250506102910.png

We can see where the .htpasswd is stored. Lets get it:

Pasted image 20250506102918.png Pasted image 20250506102922.png

We get a user and an hash. Time to crack it:

Pasted image 20250506102930.png

Pasted image 20250506102939.png

Pasted image 20250506102943.png

And we are in.

Still lets try to login to statistics subdomain:

Pasted image 20250506102957.png

And get a bunch of usernames, but probably not relevant:

Pasted image 20250506103134.png

We can ssh and get the flag:

Pasted image 20250506103143.png

Root Flag

We are in group management:

Pasted image 20250506103212.png

And there is only one file that belongs to this group:

Pasted image 20250506103219.png

Pasted image 20250506103223.png

Looking at the website monitor app, it seems that is supposed to take some metric from the previous webapps we interact at the beginning of the machine and save its results.

Pasted image 20250506103239.png

Pasted image 20250506103243.png

This seems to be the webapp running in the port 8080, so lets port foward to interact with it:

Pasted image 20250506103251.png

Pasted image 20250506103255.png

Pasted image 20250506103259.png

Looking for the process of the web-site monitor, we can notice that the inotify command is running with the dir that the group management owns.

Pasted image 20250506103324.png

The man for the command says that the command as the ability to execute a script every time it changes. So potentially whenever the /opt/website-monitor/config/configuration.php changes, that inotifywait command will execute it again.

Pasted image 20250506103340.png

Pasted image 20250506103344.png

Looking at the flags of the commands this seem exactly what is happening, so lets try changing the php file with a rev shell:

Pasted image 20250506103351.png

And as soon as we save the configuration file we get the shell:

Pasted image 20250506103400.png

Pasted image 20250506103405.png

And the root flag!

Pasted image 20250506103412.png