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

# Mirai HackTheBox Writeup

Mirai HackTheBox Easy Linux machine writeup covering Identifying an IoT device, Forensic file recovery, with practical enumeration, exploitation, foothold, and privilege escalation notes.

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

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

* Identifying an IoT device
* Forensic file recovery
  {% 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-af4bfc4f7562c78765f9c16b46170a62afbdfcaa%2Fimage%20(982).png?alt=media" alt=""><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-d2dfdea2d662c18f04fa94f8eb2f8e516fb7735b%2Fimage%20(983).png?alt=media" alt=""><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 10.10.10.48 -oG allPorts
```

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

**Open Port Analysis with extractPorts:**

Use the extractPorts function to display open ports in a concise format and copy them to the clipboard (22,53,80,1178,32400,32469)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0dca90065c16658da6bd091893d483940a9a8ed9%2Fimage%20(985).png?alt=media" alt="" width="563"><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,53,80,1178,32400,32469 10.10.10.48 -oN targeted
```

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

## Port 80 - Pi-hole

When scanning port 80, the Wappalyzer tool does not reveal any significant information.

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

However, after doing a bit of fuzzing, we discover a directory "`admin`" associated with Pi-hole, containing a login panel.

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

We then search the Internet for default credentials and find the following information:

* **User:** pi
* **Password:** raspberry

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

We are trying to connect via SSH because port 22 is open:

```bash
ssh pi@10.10.10.48
```

The connection is successful.

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

### 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-62a8468d4116d3bf67b2bfd81dd34d52a22a90f7%2Fimage%20(992).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## **Privilege Escalation :**

**Sudo Group:** Checking the user groups, we see that the user "pi" belongs to the sudo group. Since we already know its password, we can gain root privileges.

```bash
id
```

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

Next, we run `sudo su` and enter the password for user "pi":

```bash
sudo su
```

### Flag root.txt

**Recovery of the root.txt file:** The attacker informs us that he has lost the `root.txt` file and that we must look for it in a backup on a USB key.

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

We search for connected USB devices and find a `/dev/sdb` disk

```bash
df -h 
```

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

When attempting to read this disc directly, the data is unreadable. However, after using the `strings` command, we are able to recover readable information from the device:

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

```bash
strings /dev/sdb
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d7c843813e19430b9fefb27f076c3562337adfbd%2Fimage%20(996).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-ee2704119fe1a89dc3d5f9dfb41d14f663745cbc%2Fimage%20(997).png?alt=media" alt="" width="530"><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-easy/mirai-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.
