Tuesday 25 March 2014

Pyrit and CUDA, How To?

Hello again for another quick guide, this time I am trying to light your path to Pyrit-CUDA on Kali Linux and an hybrid notebook. By hybrid I mean, 2 GPU; 1 Intel 1 NVidia.

It was originally my first experience with gp-gpu experience and it was ridiculously hard. I mean I really gave more time and effort than actually learn to crack some WPA in the first place. Whole drivers and SDKs, finding the right libraries, correct combinations, etc... was very tiresome; I tried and crashed Kali and re-install like so many times actually forgot the count.

Anyways the below is the way I got it working with my Fujitsu Lifebook LH532, essentially it is a Core i3 notebook with a GT 620m GPU.

First thing is first, like on many Debian start with;

apt-get update

Of course if anything goes wrong you know what to do. Get a better sources.list and kernel-headers.

Then this is the critical part. It will quite possibly crash your setting if it is not like mine. But what the cow, you prolly did crashed your system so many times already; at this point you are willing to try anything...

apt-get install nvidia-detect nvidia-libopencl1 nvidia-opencl-common nvidia-support nvidia-opencl-icd nvidia-visual-profiler nvidia-glx nvidia-installer-cleanup nvidia-kernel-common nvidia-smi nvidia-alternative nvidia-opencl-dev libglx-nvidia-alternatives nvidia-kernel-dkms nvidia-cuda-toolkit nvidia-vdpau-driver nvidia-xconfig glx-alternative-nvidia libgl1-nvidia-alternatives nvidia-settings libgl1-nvidia-glx xserver-xorg-video-nvidia libcublas4 libcudart4 libcufft4 libnpp4 libnvidia-compiler libcuda1 libcuinj4 libnvidia-ml1 libxvmcnvidia1 libcusparse4 libcurand4 python-pycuda-doc python-pycuda-headers python-pycuda nvidia-cuda-doc nvidia-cuda-gdb

I found above command as a whole on a japanese blog, and cannot find again to give credit. But thanks to dude who did in the first place. I remember he stated this line should work for Ubuntu on a hybrid notebook also.

Again sources.list is very important if you intend to complete above command successfully.

If everything is still working order, then do the magic below;

/root/.bashrc <<

PATH=$PATH:/usr/lib/nvidia-cuda-toolkit/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-cuda-toolkit/lib:/lib
export PATH
export LD_LIBRARY_PATH

After this we actually have CUDA on Kali, just restart the system and see if it is still booting up :) if not well re-install Kali, sorry.

----------------------------------------------------

Now time for actually settin up Pyrit-CUDA, don't worry tho; worse is behind and there is no danger crashing after this point.

We should download the official packages from the official site. which are pyrit-0.4.0.tar.gz and cpyrit-cuda-0.4.0.tar.gz that you need. Before you do anything just get below 2 library first.

atp-get install libpcap-dev python2.7-dev

Then for Pyrit do the following;

tar -xzvf pyrit-0.4.0.tar.gz
cd pyrit-0.4.0
python setup.py build
python setup.py install

Now you have Pyrit if everything went smoothly, but not yet Pyrit-CUDA. Here goes the magic again;

tar -xzvf cpyrit-cuda-0.4.0.tar.gz
cd cpyrit-cuda-0.4.0

setup.py <<

for path in ('/usr/local/cuda', '/opt/cuda'):
>> (must be like below or appropriate)
for path in ('/usr/local/cuda','/usr/lib/nvidia-cuda-toolkit','/opt/cuda'):

python setup.py build
python setup.py install

Tadaa (Windows 3.1 sound) !!! We have Pyrit with CUDA support. Enjoy the show;

note: you can see the device by "pyrit list_cores" and test via "pyrit benchmark".

Thursday 6 March 2014

HD 7770 (x2) X-Fire Setting For OpenCL + Pyrit

Not long ago, I bought 2 HD7770 for my rig. And then decided to give a try to the Pyrit. Everyone knows Pyrit right? Ok.

It's actually pretty easy to set Pyrit up for gpu. IN THEORY! I spent 4-5 hours for my setting to operate correctly this time around... Last time I was trying Pyrit-CUDA on a hybrid gpu notebook and it was a real pain. Like real pain.

Anyhow, I use Kali as my distro cause at least it is pre-patched for all my wifi dongles. I, at least, don't bother with the firmware patching and stuff.

So let's start with the AMD-ATI official drivers. Use this script to install them, the guy who wrote is brilliant and did a tremendous amount of work. So we don't have to get through that hell every time we need to install AMD-ATI drivers. Script simply works just run it and pour a cup of coffee and enjoy.

Then we need to install AMDAPP 2.7 because the script installs drivers version 8.96 something. these can be found on official AMD site. If you somehow manage the install the drivers without above script, you probably have another version. You should check the appropriate compatible version of APP SDK and then download that specific version accordingly. You can trust the instructions on the official page. They work, unlike the driver installation part of the official AMD site.

If all is well so far, then we need some more libraries that is not included with the standard setup of KALI Linux. Below the command to do that;
apt-get install opencl-icd-dev
apt-get install libpcap0.8-dev

You may need to update kernel headers and apt-get update. I assume you are familiar with those or already done it.

Now it is time for us to compile Pyrit. We should edit cpyrit/setup.py script accordingly to this blog. Read carefully and do exactly, we should be fine. Then we compile opencl-pyrit module. We should get no error if everything is good so far.

We should be done at this point just test it if Pyrit sees your AMD OpenCL supported device by 'listcores' parameter. We should see the whole device as one single core just like a CPU core. That's OK though. Pyrit will utilize all the cores available on that OpenCL device.

Congrats, you have now acquired more power to crack WPA passwords faster. If you still have problems or could not complete the guide above for some reason, please let me know so I may be able to help.

PS: Sorry I published this post before I finished it and never realized. This is the finished version.