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

# Pyrit のインストール、コンパイル、およびハンドシェイク検証

レガシー Pyrit を安全にビルドし、WPA/WPA2 ハンドシェイクキャプチャの検証に使用する。

PyritはWPA/WPA2のハンドシェイクキャプチャの検証を支援し、偽陽性を減らすのに役立ちます。承認済みのキャプチャと文書化された範囲で使用してください。

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

{% hint style="warning" %}
Pyritは放棄されています。Python 2.7とOpenSSL 1.1.1に依存しており、どちらもサポート終了です。本番システムにはインストールしないでください。
{% endhint %}

### ビルドの概要

このビルドには別途OpenSSLのインストール、Python 2.7、および互換性パッチが必要です。使い捨ての仮想マシンまたはコンテナを使用してください。

1. ビルド依存関係をインストールします。
2. OpenSSL 1.1.1w と Python 2.7.18 をコンパイルします。
3. Pyrit にパッチを適用してコンパイルします。
4. 実行時ライブラリパスを設定し、結果を確認します。

### 前提条件

次のビルド依存関係をインストールします:

`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` 現在は利用できません。代わりにソースから Python 2.7.18 をビルドしてください。

### レガシー依存関係をビルドする

#### OpenSSL 1.1.1w

システムの OpenSSL 3.x はこの Python 2 ワークフローと互換性がありません。OpenSSL 1.1.1w を別途ビルドします:

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

上記のOpenSSLインストールに対してPythonをビルドします:

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

これにより `python2.7` がシステムの Python バージョンを変更せずにインストールされます。

### Pyrit の準備とコンパイル

#### pip2 をインストール

実行 `get-pip.py` を `python2.7`.

#### パッチ適用 `setup.py`

Pyrit は旧式の Python クラスを使用しています。置き換えます `super().build_extension(ext)` を `build_ext.build_extension(self, ext)`.

追加 `include_dirs` および `library_dirs` OpenSSL のインストール先を指すエントリ。

#### GCC 14 互換フラグを付けてコンパイル

旧式の C コードは、最新の GCC バージョンでは厳格なコンパイラエラーを引き起こします:

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

#### 混在した Python 構文にパッチを適用

一部のファイルには互換性のない Python 3 構文が含まれています。次の互換性変更を適用してください:

* f文字列を `%` 書式設定に置き換えます。
* 置き換え `print(..., file=sys.stderr)` を `print >> sys.stderr`.
* 削除 `e から` から `raise` 文。
* 置き換え `import queue` を `import Queue as queue`.
* 置き換え `xmlrpc.client` および `xmlrpc.server` を `xmlrpclib` および `SimpleXMLRPCServer`.

### 実行時ライブラリパスを設定

設定 `LD_LIBRARY_PATH=/opt/openssl-1.1.1w/lib` の中に `.zshrc`。これで Pyrit は実行時に必要な OpenSSL ライブラリを見つけられます。

### インストールを確認

Pyrit が利用可能な処理コアを検出できることを確認します。次にベンチマークを実行します:

```bash
pyrit list_cores
pyrit benchmark
```

### 推奨される代替手段

新しい評価には、保守されているツールを優先してください:

* `hashcat`
* `aircrack-ng`

これらは Python 2 と旧式の OpenSSL の依存関係チェーンを回避します。

### ハンドシェイクをキャプチャして検証する

この手順は、あなたが所有するか評価の許可を得ている無線ネットワークでのみ使用してください。

#### 対象トラフィックをキャプチャする

既知のチャンネルで対象ネットワークのトラフィックをキャプチャします:

{% code overflow="wrap" %}

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

{% endcode %}

#### 検証用トラフィックを生成する

明示的な範囲承認のもと、指定したクライアントに認証解除フレームを送信します。これにより再接続が促され、新しいハンドシェイクが生成されることがあります:

{% code overflow="wrap" %}

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

{% endcode %}

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

#### キャプチャしたハンドシェイクを検証する

Pyrit でキャプチャを分析します。観測されたステーションから利用可能なハンドシェイクが報告されます:

{% code overflow="wrap" %}

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

{% endcode %}

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