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

# Pyrit Installation, Compilation, and Handshake Validation

Build legacy Pyrit safely and use it to validate WPA/WPA2 handshake captures.

Pyrit can help validate WPA/WPA2 handshake captures and reduce false positives. Use it with approved captures and documented scope.

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

{% hint style="warning" %}
Pyrit is abandoned. It depends on Python 2.7 and OpenSSL 1.1.1, which are end-of-life. Do not install it on a production system.
{% endhint %}

### Build overview

This build needs a separate OpenSSL installation, Python 2.7, and compatibility patches. Use a disposable virtual machine or container.

1. Install the build dependencies.
2. Compile OpenSSL 1.1.1w and Python 2.7.18.
3. Patch and compile Pyrit.
4. Configure the runtime library path and verify the result.

### Prerequisites

Install these build dependencies:

`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` is no longer available. Build Python 2.7.18 from source instead.

### Build the legacy dependencies

#### OpenSSL 1.1.1w

System OpenSSL 3.x is incompatible with this Python 2 workflow. Build OpenSSL 1.1.1w separately:

```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

Build Python against the OpenSSL installation above:

```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
```

This installs `python2.7` without changing the system Python version.

### Prepare and compile Pyrit

#### Install pip2

Run `get-pip.py` with `python2.7`.

#### Patch `setup.py`

Pyrit uses an old-style Python class. Replace `super().build_extension(ext)` with `build_ext.build_extension(self, ext)`.

Add `include_dirs` and `library_dirs` entries that point to the OpenSSL installation.

#### Compile with GCC 14 compatibility flags

The legacy C code triggers strict compiler errors on modern GCC versions:

```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
```

#### Patch mixed Python syntax

Some files contain incompatible Python 3 syntax. Apply these compatibility changes:

* Replace f-strings with `%` formatting.
* Replace `print(..., file=sys.stderr)` with `print >> sys.stderr`.
* Remove `from e` from `raise` statements.
* Replace `import queue` with `import Queue as queue`.
* Replace `xmlrpc.client` and `xmlrpc.server` with `xmlrpclib` and `SimpleXMLRPCServer`.

### Configure the runtime library path

Set `LD_LIBRARY_PATH=/opt/openssl-1.1.1w/lib` in `.zshrc`. Pyrit then finds the required OpenSSL library at runtime.

### Verify the installation

Confirm that Pyrit detects the available processing cores. Then run its benchmark:

```bash
pyrit list_cores
pyrit benchmark
```

### Recommended alternatives

Prefer maintained tools for new assessments:

* `hashcat`
* `aircrack-ng`

They avoid the Python 2 and legacy OpenSSL dependency chain.

### Capture and validate handshakes

Use this workflow on a wireless network you own or are authorized to assess.

#### Capture target traffic

Capture traffic from the target network on its known channel:

{% code overflow="wrap" %}

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

{% endcode %}

#### Generate validation traffic

With explicit scope approval, send deauthentication frames to the specified client. This can prompt a reconnect and produce a new handshake:

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://131707722-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>

#### Validate captured handshakes

Analyze the capture with Pyrit. It reports handshakes available from the observed stations:

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://131707722-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/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.
