# DailyBugle

## Daily Bugle

**Date**: 04/04/2022

**Difficulty**: Hard

**CTF**: <https://tryhackme.com/room/dailybugle>

***

## Deploy

### Access the web server, who robbed the bank?

First of all, a quick scan:

<figure><img src="/files/EpRE7toR0DAmt5if85Ve" alt=""><figcaption></figcaption></figure>

Ping tell us that it will be a linux machine (ttl=63)

<figure><img src="/files/UBZxWw0wd0AOFKuNAjnR" alt=""><figcaption></figcaption></figure>

A quick nmap scan discover that ports 22, 80 and 3306 are open.

<figure><img src="/files/H4JDkl54Go5ksDwoVjlP" alt=""><figcaption></figcaption></figure>

A more detailed nmap scan shows us the version of the services.

For the http service it also discovered that the site uses Joomla, and that robots.txt file exists and has several directories configured as disallowed entries, we may check them all later.

For now, let’s visit the page:

<figure><img src="/files/WFrHkmC6PMkp7NH4xhgG" alt=""><figcaption></figcaption></figure>

## Obtain user and root

### What is the Joomla version?

💡 Instead of using SQLMap, why not use a python script!

As I have never used SQLMap before, I’m going to do it with a python script first and then I’ll find how to do it with SQLMap:

#### Python Script

Doing a bit of research I found [Juumla Github repository](https://github.com/oppsec/juumla). This tool is a python script that discovers the version of a Joomla site.

<figure><img src="/files/aWqdmL1hkJyM9hI0M8PY" alt=""><figcaption></figcaption></figure>

So let’s clone the repository in our local machine and follow the instructions:

<figure><img src="/files/EpyQlBKC83IEKcQjAxEm" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/FK4njcVuktmpMx1Hnuff" alt=""><figcaption></figcaption></figure>

Pretty fast!

#### SQLMap

After some research I didn’t find a way to do it with SQLMap... Maybe that phrase was referring to the next task?

#### Other

There is other way to obtain the Joomla version according to [this site](https://www.itoctopus.com/how-to-quickly-know-the-version-of-any-joomla-website). As it says, is as easy as navigate to this url: [`http://10.10.121.47/administrator/manifests/files/joomla.xml`](http://10.10.121.47/administrator/manifests/files/joomla.xml) and a config file appears where you can easy see the Joomla version:

<figure><img src="/files/QljUU5E84tIavWtQaiyu" alt=""><figcaption></figcaption></figure>

### What is Jonah's cracked password?

Looking for any exploit for this Joomla version, the results are aligned, there is a SQL Injection vulnerability in this version we can exploit.

<figure><img src="/files/vinGROXWHWa1PvrAG1g7" alt=""><figcaption></figcaption></figure>

So, let’s try with the [python script of stefanlucas](https://github.com/stefanlucas/Exploit-Joomla) first:

<figure><img src="/files/VeLmI9iB5YTEBpavKZAw" alt=""><figcaption></figcaption></figure>

Nice, now we have to crack the password. To do it we should know the hash format... Let’s discover it:

<figure><img src="/files/FrxGGZHP8XdqHqRP0tL6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/zf9Mcov8caxWI6zc7jZ6" alt=""><figcaption></figcaption></figure>

A user in hashcat forum says is bcrypt... It has an avatar of a cat, I should trust on him.

So, let’s try to crack it using John the Ripper, fasttrack wordlist and bcrypt hash format:

<figure><img src="/files/rcesLio6mwoVr4WpZUfI" alt=""><figcaption></figcaption></figure>

After 5 minutes we get a cracked password!

### What is the user flag?

In the nmap scan we did before, it discovered robots.txt file, which had some directories we have taken note. Let’s try to visit the ones that look like an administrator page:

<figure><img src="/files/KD06Z3m7vtJn6Ki4m3tj" alt=""><figcaption></figcaption></figure>

At /administrator we find this login. Let’s try to login as jonah:

<figure><img src="/files/LHgIlGepft2NgikMBAze" alt=""><figcaption></figcaption></figure>

We are in. Let’s look for the flag...

After some navigation it doesn’t look like there is a flag inside joomla itself. I think I can upload a php reverse shell and try to catch it on my local machine:

<figure><img src="/files/ZBRsEY6iUkFoHd16l4rg" alt=""><figcaption></figcaption></figure>

It doesn’t work. Apparently I can’t upload .php files there.

<figure><img src="/files/Sf69GgWm1YGlCLRcOlqL" alt=""><figcaption></figcaption></figure>

But... I can modify this hahaha

<figure><img src="/files/hyQB4gnSHbAip0pPK9Np" alt=""><figcaption></figcaption></figure>

Let’s try again:

<figure><img src="/files/DxDd1aSkBwJDnkZ4wKhf" alt=""><figcaption></figcaption></figure>

Nah, there is no way.

Just for the sake of trying, let’s see if we can login via SSH using this credentials:

<figure><img src="/files/d7O6cMESNwsfmB2XsUlk" alt=""><figcaption></figcaption></figure>

Nope, okay. Let’s try again to open a reverse shell. I’m going to search how to upload php files in Joomla.

After some searching, apparently there is no way to upload php files, buuuut, there are php files you can edit: the templates. So let’s try to use them to inject our code there:

<figure><img src="/files/lNUZNMw98SMZ13YLaY8L" alt=""><figcaption></figcaption></figure>

I’ll backup all the index.php code to undo it if neccesary, and replace all the cod with the php-reverse-shell.php one:

<figure><img src="/files/NStpVzzNTZ1nnawB8Chz" alt=""><figcaption></figcaption></figure>

It will work if I click on preview? Nope. Let’s save it.

<figure><img src="/files/CVRzzdKtdJhU224S9W7G" alt=""><figcaption></figcaption></figure>

And now let’s click on preview, And Instantly we get the reverse shell!

<figure><img src="/files/D6bCuf11UQDnouzMOke2" alt=""><figcaption></figcaption></figure>

I’m going to stabilize the shell:

<figure><img src="/files/SzBBlGXuIO50hqgnb2TH" alt=""><figcaption></figcaption></figure>

Now, let’s look for the flag:

<figure><img src="/files/IWpMnSdUw4XgEjMQMbH6" alt=""><figcaption></figcaption></figure>

hmmm... we have not access to jjameson folder. Let’s see what can I do with this user:

<figure><img src="/files/UaNEKeIHXarytcFN9YKS" alt=""><figcaption></figcaption></figure>

I have no permissions to read /etc/shadow and there is nothing being executed on crontab.

<figure><img src="/files/c8f1IQEdsZH46YewxWCX" alt=""><figcaption></figcaption></figure>

No interesting SUID binaries, no interesting capabilities binaries, no NFS...

Ok, we know the other user is jjameson. Maybe we can start an hydra attack? I tried for 30 min with no success, so I guess is not the correct way.

Let’s see if there is any vulnerability we can exploit in the apache version 2.4.6. After some research I didn’t find nothing exploitable for privesc.

What about the OpenSSH version 7.4? Nothing neither...

And Maria DB? Nothing? uhm...

Ok, let’s try another thing. Let’s investigate if there is something we can use in the /var/www/html folder which contains the files hosted in the httpd service:

<figure><img src="/files/rPQmZ4oyxfm0L3utIiRM" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Z9s6bRD4crzpLHYYGNnB" alt=""><figcaption></figcaption></figure>

This is interesting, there are credentials of a user “root”. This credentials seems to be for a database service. Maria DB maybe? Let’s check:

`mysql -h <hostname> -u <username> -p <databasename>`

<figure><img src="/files/PE50tU7ubP6XAeG2IDU8" alt=""><figcaption></figcaption></figure>

Looks like we cannot access to the database from our local machine. Let’s try with the target machine:

<figure><img src="/files/OpbwilRvj7oriluBPVVi" alt=""><figcaption></figcaption></figure>

Yeah, we can from target machine. Let’s see what’s inside this DB:

<figure><img src="/files/aUHbUURMN2Tk2k0SCO02" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dxajFDfKaFUpwQ0TxVrJ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/q65nKipNZ9iwhQpVq194" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/c6rxtHRVBoxztAC4jP7S" alt=""><figcaption></figcaption></figure>

Mmmh... we got this before when we exploited the joomla vulnerability. Maybe we are in the incorrect DATABASE.

<figure><img src="/files/nP00QLM48EcB7V0xINal" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/qnMO96jI9E7HULd3gSfP" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/EwDXtizgSEyIEprbZhuG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/UXDnP9lmMijR2xGihdAO" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GoNfZAmZwDytYFZCrw1v" alt=""><figcaption></figcaption></figure>

I have found nothing interesting through the database. Let’s try this password in the root user of the target machine just in case:

<figure><img src="/files/TNMJTpYp5ZuVkfbHAoIs" alt=""><figcaption></figcaption></figure>

Nope. Let’s try as the password of the jjameson user, just to discard everything:

<figure><img src="/files/CboStIFeO7vEegVL99Wu" alt=""><figcaption></figcaption></figure>

OMG... it is. Let’s go for the user flag:

<figure><img src="/files/pxfLNldGKb6kjUIfmqWL" alt=""><figcaption></figcaption></figure>

### What is the root flag?

Ok, root flag would be probably located into /root folder. This user has no access there, so it’s time for privesc.

Let’s see if we can execute anything using sudo:

<figure><img src="/files/aWwfs0C7nYxCVRir1Xi7" alt=""><figcaption></figcaption></figure>

We can use yum as sudo... Let’s check it at GTFOBins:

<figure><img src="/files/ZEQ3hyMoWzeHGMbxPBcb" alt=""><figcaption></figcaption></figure>

We can escalate privileges using yum!

<figure><img src="/files/FuVUTnmMF9Y0dkPyNsKF" alt=""><figcaption></figcaption></figure>

First way is not possible, as the target system doesn’t recognize fpm as a command. Let’s try with the second option:

<figure><img src="/files/DPFtPQCUIpDd7Au6VoyG" alt=""><figcaption></figcaption></figure>

This second one worked like a charm (even if I don't fully understand how it works). Now let’s go for the root flag!

<figure><img src="/files/negPgJIy9uujUttyBFJz" alt=""><figcaption></figcaption></figure>

And challenge finished!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://angellm.gitbook.io/hacknotes/thm/2022/dailybugle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
