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

# Instalação, Compilação e Validação de Handshake do Pyrit

Compile o Pyrit legado com segurança e use-o para validar capturas de handshake WPA/WPA2.

O Pyrit pode ajudar a validar capturas de handshake WPA/WPA2 e reduzir falsos positivos. Use-o com capturas aprovadas e escopo documentado.

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

{% hint style="warning" %}
O Pyrit foi abandonado. Ele depende do Python 2.7 e do OpenSSL 1.1.1, que estão fora de suporte. Não o instale em um sistema de produção.
{% endhint %}

### Visão geral da compilação

Esta compilação precisa de uma instalação separada do OpenSSL, Python 2.7 e patches de compatibilidade. Use uma máquina virtual ou contêiner descartável.

1. Instale as dependências de compilação.
2. Compile o OpenSSL 1.1.1w e o Python 2.7.18.
3. Aplique patches e compile o Pyrit.
4. Configure o caminho da biblioteca em tempo de execução e verifique o resultado.

### Pré-requisitos

Instale estas dependências de compilação:

`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` não está mais disponível. Em vez disso, compile o Python 2.7.18 a partir do código-fonte.

### Compile as dependências legadas

#### OpenSSL 1.1.1w

O OpenSSL 3.x do sistema é incompatível com este fluxo de trabalho com Python 2. Compile o OpenSSL 1.1.1w separadamente:

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

Compile o Python usando a instalação do OpenSSL acima:

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

Isso instala `python2.7` sem alterar a versão do Python do sistema.

### Prepare e compile o Pyrit

#### Instale o pip2

Execute `get-pip.py` por `python2.7`.

#### Aplique o patch `setup.py`

O Pyrit usa uma classe Python no estilo antigo. Substitua `super().build_extension(ext)` por `build_ext.build_extension(self, ext)`.

Adicionar `include_dirs` e `library_dirs` as entradas que apontam para a instalação do OpenSSL.

#### Compile com flags de compatibilidade do GCC 14

O código C legado gera erros rigorosos do compilador em versões modernas do 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
```

#### Corrija a sintaxe mista de Python

Alguns arquivos contêm sintaxe incompatível do Python 3. Aplique estas alterações de compatibilidade:

* Substitua f-strings por `%` formatação.
* Substituir `print(..., file=sys.stderr)` por `print >> sys.stderr`.
* Remova `from e` from `raise` instruções.
* Substituir `import queue` por `import Queue as queue`.
* Substituir `xmlrpc.client` e `xmlrpc.server` por `xmlrpclib` e `SimpleXMLRPCServer`.

### Configure o caminho da biblioteca em tempo de execução

Defina `LD_LIBRARY_PATH=/opt/openssl-1.1.1w/lib` em `.zshrc`. Então o Pyrit encontra a biblioteca OpenSSL necessária em tempo de execução.

### Verifique a instalação

Confirme que o Pyrit detecta os núcleos de processamento disponíveis. Em seguida, execute seu benchmark:

```bash
pyrit list_cores
pyrit benchmark
```

### Alternativas recomendadas

Prefira ferramentas mantidas para novas avaliações:

* `hashcat`
* `aircrack-ng`

Elas evitam a cadeia de dependências do Python 2 e do OpenSSL legado.

### Capture e valide handshakes

Use este fluxo de trabalho em uma rede sem fio de sua propriedade ou para a qual você esteja autorizado a realizar avaliação.

#### Capture o tráfego do alvo

Capture o tráfego da rede alvo em seu canal conhecido:

{% code overflow="wrap" %}

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

{% endcode %}

#### Gere tráfego de validação

Com aprovação explícita do escopo, envie quadros de desautenticação ao cliente especificado. Isso pode solicitar uma reconexão e produzir um novo handshake:

{% code overflow="wrap" %}

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

{% endcode %}

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

#### Valide os handshakes capturados

Analise a captura com o Pyrit. Ele informa os handshakes disponíveis a partir das estações observadas:

{% code overflow="wrap" %}

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

{% endcode %}

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