grelbar just another hacker's blog

5Oct/104

Pyrit 0.3.0 with ATI graphics cards

Inspired by this post on the Pauldotcom website, i decided to reinstall Pyrit on my machine, and see how it has evolved. Pyrit is a program that allows you to use your graphics card (and cpu) to perform calculations relating to cracking WPA pairwise masterkeys. GPUs are considerably faster than CPU's at such calculations. I don't even pretend to understand all the math involved, since i sucked at math. But still, it's fun to put your hardware to new and exciting uses.

Starting out

The components and software involved should be mentioned, and your mileage may and will vary. Pyrit can be a real bitch to set up, and there are loads of dependencies and modifications that need to be done.

So what i have under the hood is:

  • ATI Radeon HD4850 with 512MB memory
  • Gigabyte MA-GA790X motherboard with two PCI-Express slots for graphics cards
  • 6 GB DDR2 memory
  • Western Digital Raptor hard drive for the OS and relevant files
  • Ubuntu 10.10 RC, 32-bit

I installed the fglrx drivers using the Additional Drivers tool that is under System -> Administration -> Additional Drivers. These drivers are required to run any of this fancy GPU stuff.

Start off by installing some packages that are good to have around in any case:

  • make
  • build-essential
  • python-dev
  • libssl-dev
  • zlib1g-dev
  • libstdc++5
  • libpcap0.8-dev (thanks to corby for this additional dependency)

That should be enough to get everything installed, but do comment if something is missing.

What you need to download

You need various packages from different sites to get everything you need, as these packages are not in the standard ubuntu repositories. If you know of a repository that provides these, do tell. But i think ATI/AMD want to keep stuff behind their EULAs.

Just get the packages for now, and move on to the next chapter to install them.

Installing it all

Start by installing the ATI SDK. Take the package you downloaded and unzip/untar it somewhere, i used my home folder for the example. Next, we'll set a few environment variables (replace username with your username, and/or the location with whereever you put the files):

export ATISTREAMSDKROOT=/home/username/ati-stream-sdk-v2.2-lnx32
export ATISTREAMSDKSAMPLESROOT=/home/username/ati-stream-sdk-v2.2-lnx32/samples
export LD_LIBRARY_PATH=$ATISTREAMSDKROOT/lib/x86:$LD_LIBRARY_PATH

Also, let's create a directory and some symlinks:

sudo mkdir -p /usr/lib/OpenCL/vendors
sudo ln -sf /home/username/ati-stream-sdk-v2.2-lnx32/lib/x86/libatiocl32.so /usr/lib/OpenCL/vendors/libatiocl32.so

Okay, now we should be ready to install the OpenCL license file, so as root, move that file over to your root directory, and run tar xfz icd_registration.tgz

Basically that places a file inside /etc/opencl and does some magic to make the whole thing work... no idea why this step is needed, but ATIs word is law here.

We should now be able to make the Stream SDK, so go to the folder you unzipped the SDK, and as root, run make. Wait for a while, and then go to samples/opencl/bin/x86/ and run ./HelloCL. This should produce a message indicating success. This means your SDK is properly installed and working. Problems here indicate an error with the symlinks or environment variables.

Building and Installing Pyrit 0.3.0

Unzip/tar whatever the pyrit and the opencl packages to a location of your choosing. Start with the actual pyrit package. Head on into the folder, and run the following:

python setup.py build
sudo python setup.py install

After that finishes, go to the cpyrit directory and using your favorite editor, open up setup.py and find the following location, adding the bold section:

for path in ('/usr/local/opencl/OpenCL/common/inc', \
           '/opt/opencl/OpenCL/common/inc', \
           '/home/username/ati-stream-sdk-v2.2-lnx32/include', \
           '/usr/local/opencl/include'):

This is because otherwise, you'll end up with errors the refer to some libraries that are only in that location, so you need to tell it where to find them. After your are done editing, doublecheck the path, and save the file. Then you'll want to build and install the cpyrit stuff, by running the exact same commands as with the actual pyrit package.

When you're done you can try:

pyrit list_cores

0r

pyrit benchmark

You should see something like this for the list_cores:

Pyrit list_cores output

So now you can see your GPU (or GPUs) and your regular CPU cores ( minus one core, used to handle the data to and from the GPU). With new versions of Pyrit, there's also the Network-Clients entries. I haven't looked into that yet, but maybe i will in a later post. You should be able to hook up multiple hosts. Or something.

After this you could run a pyrit benchmark to see just how well it performs. Mine got around 16000 PMK/s, and around 350 per core of my Phenom II X4 3ghz.

You should also add the environment variables to your .bashrc or equivalent so they get loaded every time you boot.

Installation is a bitch, and i worked for a few hours to get all this running. If you get weird results; reboot, check all the steps and try again. You can always build pyrit and cpyrit again if things go batshit.

I'll try to answer any questions, so post them in the comments section.

sources:

For this article, i used the following sources. Biggest source by far was http://beta.ivancover.com/wiki/index.php/Pyrit_setup, which has basically all of these steps and a bit more, but i updated and added where i thought it would add clarity, or if something changed with Ubuntu 10.10.

Other good sources are:

  • http://developer.amd.com/gpu/ATIStreamSDK/assets/ATI_Stream_SDK_Getting_Started_Guide_v2.2.pdf
  • http://developer.amd.com/gpu/ATIStreamSDK/assets/ATI_Stream_SDK_Installation_Notes.pdf
  • http://code.google.com/p/pyrit/wiki/Installation
  • http://code.google.com/p/pyrit/

So thanks to all these sources. I would have gotten nowhere without them.