Install pyrit in Kali Linux/Debian with CUDA

Pyrit is one of the most useful security tool to crack WPA or WPA2-PSK passphrase, simply a powerful wi-fi password hacking tool.

Why it’s crazy fast ? Because it uses the processing power of multicore CPU, SSE2 CPU extension, OennCL platform on Radeon GPUs, CUDA platform on NVDIA GPUs or the Padlock cryptographic accelator of VIA CPUs.

In this tutorial we are going to install and configure pyrit with CUDA to take the advantage of massive parallel processing power of the NVIDIA GPU. Here is the system configuration

  • Hardware: CPU Intel Core i5 2410M, GPU NVIDIA GeForce GT 540M
  • OS: Debian testing, currently stretch
  • Kernel version: Linux 4.2.1-2
  • NVIDIA driver version: 340.93
  • CUDA toolkit version: 6.5.14-2

 

1. Install nvidia drivers and minimal cuda

Cuda is not supported with the opensource nouveau drivers, we have to install non-free nvidia drivers to get nvidia cuda working. If you have a NVIDIA Optimus system, check this detailed article about installing and configuring nvidia optimus in Debian/Kali Linux.

Installing nvidia drivers

Before installing anything, you must have to enable the non-free repository, to do so, put the line bellow in the /etc/apt/sources.list file

deb http://ftp.debian.org/debian/ stretch main contrib non-free

Change the word stretch according to your disrto, like if you are using the Kali Linux, replace the  above line with suitable Kali Linux repository URL. If you are not sure what I’m talking about, have a look at there and check out how to add the non-free repository.

sudo apt-get update
sudo apt-get install gcc make linux-headers-amd64
sudo apt-get install nvidia-kernel-dkms nvidia-xconfig nvidia-settings
sudo apt-get install nvidia-vdpau-driver vdpau-va-driver mesa-utils

Install minimal cuda

After rebooting, Just run this command bellow, this will install a minimal version of cuda, less packages and fast installation.

sudo apt-get --no-install-recomands install nvidia-cuda-toolkit

Link the cuda install directory to /usr/local, this is step is necessary,

sudo ln -s /usr/lib/nvidia-cuda-toolkit/ /usr/local/cuda 

 

2. Install various development headers

Various development header files are necessay to compile pyrit from sorce, lets install them.

sudo apt-get install python2.7-dev libssl-dev zlib1g-dev libpcap-dev

 

3. Download latest pyrit and cpyrit-cuda

Pyrit is hosted on google code, Download it from there,

cd ~/
wget -c https://pyrit.googlecode.com/files/pyrit-0.4.0.tar.gz
wget -c https://pyrit.googlecode.com/files/cpyrit-cuda-0.4.0.tar.gz

NOTE: It seems that pyrit development is stalled, and it is available as a read-only project at google code.

 

4. Compile and install pyrit

tar -xf pyrit-0.4.0.tar.gz
cd cd pyrit-0.4.0/
python setup.py build
sudo python setup.py install

These commands will bulid and install the pyrit, with CPU only support, lest test run pyrit

pyrit -help # prints a help message
pyrit list_cores

This command should return a result something like bellow,

 

debian pyrit lsit_cores commandNow run a benchmark test, and save the results for future reference, my system got about 1660 PMKs/s with a Core i5 CPU.

pyrit benchmark

 

5. Compile and install cpyrit-cuda

Cpyrit-cuda is a pyrit extension, written in C and used as a loadable shared library. With this, pyrit tekes advantage of the NVIDIA GPU to significantly speed up the whole cracking processs. Lets install cpyrit cuda,

tar -xf cpyrit-cuda-0.4.0.tar.gz
cd cpyrit-cuda-0.4.0/
python setup.py build
sudo python setup.py install

installation is complete, now again test pyrit with cuda compatibility.

pyrit list_cores

Alternetively if you have a laptop with nvidia optimus GPU like me, run this command

optirun pyrit lsit_cores

pyrit cuda list cores
These command should return a result with a recognized cuda capable device.

 

6. Pyrit CUDA benchmark testing

A benchmark test will clearly show the advange of GPU based cracking. The performance differance between GPU based and only CPU based cracking is surprising, lets check it out

pyrit benchmark
optirun pyrit benchmark  # for NVIDIA optimus systems

Compare the results with the previous CPU only benchmark, it was about 4.4 times faster than the CPU alone. My system got about 7340 PMKs/s with a NVIDIA GeForce GT540M GPU.

 

7. Few tips

I got some performance boost with pyrit if the system running a lightweight desktop environment like LXDE, LXQt or Openbox. It’s simply because the CPU has to do less with a lightweight desktop.

 

7. Troubleshooting

After extensive bug reporting and bug fixing, now compiling and installing pyrit and cpyrit-cuda is really smooth and easy. Both Debian and Kali Linux 2.0 don’t complain about anything while compiling it. I faced no problem with a Debian testing system, if you have any problem/bug, please let me know, leave a comment here.

 

So that’s it, the whole installation process is pretty straight forward. I hope this guide will help you, if you find this article useful, don’t hesitate to share it with your friends.

 

58 Responses

  1. karma says:

    Hey. I’m getting this error when i building cpyrit-cuda:

    [email protected]:~/cpyrit-cuda-0.4.0# python setup.py build
    svn: E155007: ‘/root/cpyrit-cuda-0.4.0’ is not a working copy
    running build
    running build_ext
    Compiling CUDA module using nvcc 8.0, V8.0.44…
    Executing ‘/usr/local/cuda/bin/nvcc -m64 –host-compilation C -Xcompiler “-fPIC” –ptx ./_cpyrit_cudakernel.cu’
    nvcc fatal : Unknown option ‘-host-compilation’
    Traceback (most recent call last):
    File “setup.py”, line 175, in
    setup(**setup_args)
    File “/usr/lib/python2.7/distutils/core.py”, line 151, in setup
    dist.run_commands()
    File “/usr/lib/python2.7/distutils/dist.py”, line 953, in run_commands
    self.run_command(cmd)
    File “/usr/lib/python2.7/distutils/dist.py”, line 972, in run_command
    cmd_obj.run()
    File “/usr/lib/python2.7/distutils/command/build.py”, line 128, in run
    self.run_command(cmd_name)
    File “/usr/lib/python2.7/distutils/cmd.py”, line 326, in run_command
    self.distribution.run_command(command)
    File “/usr/lib/python2.7/distutils/dist.py”, line 972, in run_command
    cmd_obj.run()
    File “setup.py”, line 100, in run
    subprocess.check_call(nvcc_cmd, shell=True)
    File “/usr/lib/python2.7/subprocess.py”, line 541, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘/usr/local/cuda/bin/nvcc -m64 –host-compilation C -Xcompiler “-fPIC” –ptx ./_cpyrit_cudakernel.cu’ returned non-zero exit status 1

    help me pls

  2. karma says:

    Thanks for responding me.
    And i should install the Cpyrit of this link too?

    • karma says:

      I had install pyrit 0.5.1 and cpyrit 0.5.0 of the github/PaulMoura.
      But CUDA-Device don’t appears.

      [email protected]:~/Pyrit/modules/cpyrit_cuda# python setup.py build
      running build
      running build_ext
      Skipping rebuild of Nvidia CUDA kernel …
      Building modules…
      [email protected]:~/Pyrit/modules/cpyrit_cuda# python setup.py install
      running install
      running build
      running build_ext
      Skipping rebuild of Nvidia CUDA kernel …
      Building modules…
      running install_lib
      running install_egg_info
      Removing /usr/local/lib/python2.7/dist-packages/cpyrit_cuda-0.5.0.egg-info
      Writing /usr/local/lib/python2.7/dist-packages/cpyrit_cuda-0.5.0.egg-info
      [email protected]:~/Pyrit/modules/cpyrit_cuda# pyrit list_coresPyrit 0.5.1 (C) 2008-2011 Lukas Lueg – 2015 John Mora
      https://github.com/JPaulMora/Pyrit
      This code is distributed under the GNU General Public License v3+

      The following cores seem available…
      #1: ‘CPU-Core (SSE2/AES)’
      #2: ‘CPU-Core (SSE2/AES)’
      #3: ‘CPU-Core (SSE2/AES)’
      #4: ‘CPU-Core (SSE2/AES)’
      #5: ‘CPU-Core (SSE2/AES)’
      #6: ‘CPU-Core (SSE2/AES)’
      #7: ‘CPU-Core (SSE2/AES)’
      #8: ‘CPU-Core (SSE2/AES)’
      [email protected]:~/Pyrit/modules/cpyrit_cuda#

    • Arnab says:

      Yes you’ve to install it from the git hub repo, as in your case, pyrit and cpyrit versions are mismatched, perhaps it’s the reason of CUDA device is not detected.

  3. karma says:

    And what’s the solution?
    Pyrit is 0.5.1 and cpyrit-cuda is 0.5.0. Maybe it’s work with version 0.5.0 pyrit?
    Thanks

  4. h says:

    I have the same issue:
    python setup.py build
    svn: E155007: ‘/root/cpyrit-cuda-0.4.0’ is not a working copy
    running build
    running build_ext
    Compiling CUDA module using nvcc 8.0, V8.0.44…
    Executing ‘/usr/local/cuda/bin/nvcc -m64 –host-compilation C -Xcompiler “-fPIC” –ptx ./_cpyrit_cudakernel.cu’
    nvcc fatal : Unknown option ‘-host-compilation’
    Traceback (most recent call last):
    File “setup.py”, line 176, in
    setup(**setup_args)
    File “/usr/lib/python2.7/distutils/core.py”, line 151, in setup
    dist.run_commands()
    File “/usr/lib/python2.7/distutils/dist.py”, line 953, in run_commands
    self.run_command(cmd)
    File “/usr/lib/python2.7/distutils/dist.py”, line 972, in run_command
    cmd_obj.run()
    File “/usr/lib/python2.7/distutils/command/build.py”, line 128, in run
    self.run_command(cmd_name)
    File “/usr/lib/python2.7/distutils/cmd.py”, line 326, in run_command
    self.distribution.run_command(command)
    File “/usr/lib/python2.7/distutils/dist.py”, line 972, in run_command
    cmd_obj.run()
    File “setup.py”, line 101, in run
    subprocess.check_call(nvcc_cmd, shell=True)
    File “/usr/lib/python2.7/subprocess.py”, line 541, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘/usr/local/cuda/bin/nvcc -m64 –host-compilation C -Xcompiler “-fPIC” –ptx ./_cpyrit_cudakernel.cu’ returned non-zero exit status 1

  5. Huy says:

    Hey. I’m getting this error when i building cpyrit-cuda:
    python setup.py build
    svn: E155007: ‘/root/cpyrit-cuda-0.4.0’ is not a working copy
    running build
    running build_ext
    Skipping rebuild of Nvidia CUDA kernel …
    Building modules…
    building ‘cpyrit._cpyrit_cuda’ extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-EkQe1J/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/cuda/include -I/usr/include/python2.7 -c _cpyrit_cuda.c -o build/temp.linux-x86_64-2.7/_cpyrit_cuda.o -Wall -fno-strict-aliasing -DVERSION=”0.4.0″
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/cpyrit
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-EkQe1J/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-EkQe1J/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_cpyrit_cuda.o -lcrypto -lcuda -lz -o build/lib.linux-x86_64-2.7/cpyrit/_cpyrit_cuda.so
    /usr/bin/ld: cannot find -lcuda
    collect2: error: ld returned 1 exit status
    error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

Leave a Reply

Your email address will not be published. Required fields are marked *