How jpaulmora/pyrit works
Project type and purpose
• Pyrit is a command-line driven, open-source tool (Python2 with C/C++ extension modules) for massively pre-computing WPA/WPA2-PSK keys in a space–time trade-off.
• It exposes a CLI, intrinsic library (“cpyrit” package), a plugin architecture for CPU/GPU compute back-ends (CPU/SSE2, CUDA, OpenCL, etc.), and a storage/RPC layer for distributed operation.
File structure
Top-level
• pyrit_cli.py – the user-facing entry point
• setup.py – installation script
• README.md, COPYING, LICENSE, CHANGELOG, MANIFEST.in
• .github/ – CI, funding, issue templates, etc.
Core library (cpyrit/)
• cpyrit.py – high-level Python APIs (Job management, storage access, core dispatch)
• network.py – RPC server/client for remote compute/storage
• storage.py – abstraction over local/remote database (e.g. MySQL)
• util.py, pckttools.py, config.py, cpufeatures.h – helpers & feature detection
• _cpyrit_cpu.* – C extension for CPU/SSE2 kernels
Modules/ (plugin back-ends)
• cpyrit_calpp/ – C++ accelerated FFT (“calpp”) implementation
• cpyrit_cuda/ – NVIDIA CUDA back-end
• cpyrit_opencl/ – OpenCL back-end
Test/
• test_pyrit.py and sample packet dumps for unit/integration tests
README for additional insights
• Confirms multi-platform (Linux, BSD, MacOS X) support
• Highlights three compute platforms (CPU, CUDA, OpenCL)
• Describes storage options: single DB server, local-network direct DB access, untrusted-network via RPC
• Emphasizes distributed architecture: many computation nodes share one storage or RPC interface
a. Main components
1. CLI Client (pyrit_cli.py)
2. Core Engine (cpyrit Python package)
3. Compute Back-ends (CPU/SSE2, Calpp, CUDA, OpenCL modules)
4. Storage Layer (MySQL/PostgreSQL or local file; accessed via storage.py)
5. RPC Interface (network.py)
6. Remote Worker Nodes (instances of CLI or headless engine connecting over RPC)
b. Relationships & data flow
• User invokes CLI → CLI calls Core Engine
• Core Engine reads configuration → selects storage backend
• For “init” or “benchmark” commands: Engine dispatches work to Compute Back-end module
• Compute Back-end (C extension) executes PBKDF2-HMAC-SHA1 loops, returns results to Engine
• Engine writes pre-computed keys (PMKs) to Storage via storage.py (direct DB or over RPC)
• Other Worker Nodes poll Storage or RPC for unprocessed jobs → fetch work → compute → push results
c. Architectural patterns & design principles
• Layered architecture: CLI → Engine → Compute Modules → Storage/RPC
• Plugin pattern for compute back-ends, discoverable via Python’s setuptools entry points (setup.py in each module)
• Distributed system: Master storage or RPC server coordinates multiple workers
• Separation of concerns: network vs. storage vs. compute logic
d. Key technologies/frameworks
• Python2 core with C/C++ extension modules (CPython C-API)
• SSE2 assembly for CPU acceleration
• NVIDIA CUDA (cuptikernel)
• OpenCL kernels (.cl files)
• MySQL/PostgreSQL (via Python DB-API) or flatfile for storage
• RPC implemented over sockets (JSON or custom protocol)
Detail
• Version or compile-time flags (e.g., SSE2, CUDA compute capability) near each compute back-end
• Configuration file (config.py) feeding into both Engine and Network modules
• Plugin discovery mechanism (setuptools entry points) to illustrate how new back-ends can be added