> 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/hacking-wifi/wpa-wpa2-psk-network-attacks/precomputed-attacks/pyrit-installation-compilation-and-handshake-validation.md).

# Pyrit-Installation, -Kompilierung und Handshake-Validierung

Legacy-Pyrit sicher erstellen und damit WPA/WPA2-Handshake-Erfassungen validieren.

Pyrit kann dabei helfen, WPA/WPA2-Handshake-Mitschnitte zu validieren und Fehlalarme zu reduzieren. Verwenden Sie es nur mit freigegebenen Mitschnitten und dokumentiertem Umfang.

{% embed url="<https://github.com/JPaulMora/Pyrit>" %}

{% hint style="warning" %}
Pyrit wird nicht mehr weiterentwickelt. Es hängt von Python 2.7 und OpenSSL 1.1.1 ab, die das End-of-Life erreicht haben. Installieren Sie es nicht auf einem Produktionssystem.
{% endhint %}

### Überblick über den Build

Dieser Build benötigt eine separate OpenSSL-Installation, Python 2.7 und Kompatibilitätspatches. Verwenden Sie eine wegwerfbare virtuelle Maschine oder einen Container.

1. Installieren Sie die Build-Abhängigkeiten.
2. Kompilieren Sie OpenSSL 1.1.1w und Python 2.7.18.
3. Patchen und kompilieren Sie Pyrit.
4. Konfigurieren Sie den Laufzeitbibliothekspfad und überprüfen Sie das Ergebnis.

### Voraussetzungen

Installieren Sie diese Build-Abhängigkeiten:

`build-essential git libssl-dev libpcap-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libgdbm-dev libffi-dev libnss3-dev wget`

`python2-dev` ist nicht mehr verfügbar. Erstellen Sie stattdessen Python 2.7.18 aus dem Quellcode.

### Die veralteten Abhängigkeiten erstellen

#### OpenSSL 1.1.1w

Das systemweite OpenSSL 3.x ist mit diesem Python-2-Workflow nicht kompatibel. Erstellen Sie OpenSSL 1.1.1w separat:

```bash
./config --prefix=/opt/openssl-1.1.1w --openssldir=/opt/openssl-1.1.1w shared zlib
make && sudo make install_sw
```

#### Python 2.7.18

Erstellen Sie Python gegen die obige OpenSSL-Installation:

```bash
CPPFLAGS="-I/opt/openssl-1.1.1w/include" LDFLAGS="-L/opt/openssl-1.1.1w/lib -Wl,-rpath=/opt/openssl-1.1.1w/lib" ./configure --enable-optimizations
make && sudo make altinstall
```

Dies installiert `python2.7` ohne die System-Python-Version zu ändern.

### Pyrit vorbereiten und kompilieren

#### pip2 installieren

Ausführen `get-pip.py` durch `python2.7`.

#### Patchen `setup.py`

Pyrit verwendet eine Python-Klasse im alten Stil. Ersetzen Sie `super().build_extension(ext)` durch `build_ext.build_extension(self, ext)`.

Hinzufügen `include_dirs` und `library_dirs` Einträge, die auf die OpenSSL-Installation verweisen.

#### Mit GCC-14-Kompatibilitätsflags kompilieren

Der veraltete C-Code löst auf modernen GCC-Versionen strenge Compilerfehler aus:

```bash
CFLAGS="-Wno-error=implicit-int -Wno-error=implicit-function-declaration -Wno-error=int-conversion -Wno-error=incompatible-pointer-types" python2.7 setup.py build/install
```

#### Gemischte Python-Syntax patchen

Einige Dateien enthalten inkompatible Python-3-Syntax. Wenden Sie diese Kompatibilitätsänderungen an:

* Ersetzen Sie f-Strings durch `%` Formatierung.
* Ersetzen `print(..., file=sys.stderr)` durch `print >> sys.stderr`.
* Entfernen Sie `von e` von `raise` Anweisungen.
* Ersetzen `import queue` durch `import Queue as queue`.
* Ersetzen `xmlrpc.client` und `xmlrpc.server` durch `xmlrpclib` und `SimpleXMLRPCServer`.

### Den Laufzeitbibliothekspfad konfigurieren

Setzen Sie `LD_LIBRARY_PATH=/opt/openssl-1.1.1w/lib` in `.zshrc`. Pyrit findet dann zur Laufzeit die erforderliche OpenSSL-Bibliothek.

### Die Installation überprüfen

Bestätigen Sie, dass Pyrit die verfügbaren Verarbeitungskerne erkennt. Führen Sie dann den Benchmark aus:

```bash
pyrit list_cores
pyrit benchmark
```

### Empfohlene Alternativen

Bevorzugen Sie für neue Assessments gepflegte Tools:

* `hashcat`
* `aircrack-ng`

Sie vermeiden die Abhängigkeitskette aus Python 2 und veralteter OpenSSL-Version.

### Handshakes erfassen und validieren

Verwenden Sie diesen Workflow in einem drahtlosen Netzwerk, das Ihnen gehört oder für das Sie autorisiert sind.

#### Zielverkehr erfassen

Erfassen Sie den Verkehr des Zielnetzwerks auf seinem bekannten Kanal:

{% code overflow="wrap" %}

```bash
airodump-ng --channel 1 -w CAPTURE --essid WIFI wlan0mon
```

{% endcode %}

#### Validierungsverkehr erzeugen

Senden Sie mit ausdrücklicher Freigabe des Umfangs Deauthentifizierungs-Frames an den angegebenen Client. Dies kann eine erneute Verbindung auslösen und einen neuen Handshake erzeugen:

{% code overflow="wrap" %}

```bash
aireplay-ng --deauth 0 -e WIFI -c FF:FF:FF:FF:FF:FF wlan0mon
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FY0DLasTq31XPJXAolpiV%2F%7B3632C541-1951-464D-8587-E548F8772AC4%7D.png?alt=media&amp;token=9cd47df5-667a-4607-80a4-345c7b748081" alt=""><figcaption></figcaption></figure>

#### Erfasste Handshakes validieren

Analysieren Sie die Mitschnittdatei mit Pyrit. Es meldet Handshakes, die von den beobachteten Stationen verfügbar sind:

{% code overflow="wrap" %}

```bash
pyrit -r CAPTURE-01.cap analyze
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F1BDYkAbZzJcwBmMIZ9O1%2F%7BD80376D6-C44D-4F8C-BCD0-9C8BF854C729%7D.png?alt=media&amp;token=533d329d-00cf-4bbd-baa6-942c5ca21be1" alt=""><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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/de/hacking-wifi/wpa-wpa2-psk-network-attacks/precomputed-attacks/pyrit-installation-compilation-and-handshake-validation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
