17 Dec

ATI Stream & Pyrit update!

Category:Hacking, Howto's

You might remember a while back, i posted some entries about using your ATI GPU to do some number-crunching for you. Specifically, Pyrit can be used to break the PMK or Pairwise Master Key of a WPA protected WLAN. Pyrit can use both ATI and NVIDIA cards (plus some others); this entry will deal only with ATI, since i have an ATI Radeon 4850.


Let’s get started. The platform that i have for doing all this is as follows:

  • ATI Radeon HD4850 graphics card (Asus brand, 512 MB memory)
  • Gigabyte motherboard with AMD790 chipset
  • AMD Phenom II X4 processor
  • 4 GB DDR2 memory
  • Ubuntu 9.10 64-bit clean installation
  • Latest fglrx drivers from ATI, installed using the System -> Administration -> Hardware Drivers
  • Kernel is 2.6.31-16

To start out, i installed the following packages (packages are in the ubuntu repositories):

  • binutils, build-essential, libssl-dev, python-dev, zlib1g-dev, libzlcore-dev

There shouldn’t be other dependencies, but do download anything that apt suggests with the aforementioned packages. After this, you need to install the ATI-stream packages, which is split into two parts: Atical and Atibrook. The files can be downloaded from ATI’s site, but installation may be tricky. I used alien to convert the .rpm packages to .deb packages, which worked somewhat well. I’m not brave enough to distribute the .deb’s i made on this site, as i never heard anything from ATI when i asked about this. Sufficed to say it can be done and wasn’t too hard, since i managed.

After this you can go two ways. Either install the stable 0.2.4 packages of Pyrit, or go the SVN route, and get the very latest builds (revision 193 or 0.2.5-dev at the time of writing). In either case, the process is the same, but the SVN is always the “latest”, which doesn’t necessarily translate to “most stable” or even “working”. I tried SVN, because i had an issue (which later turned out not to be Pyrit’s fault, more on this later).

The SVN-way:

Install a svn client by doing:

sudo apt-get install subversion

Go to your home directory, or other location where you have write privileges. Run the following command:

svn checkout http://pyrit.googlecode.com/svn/trunk/ pyrit_svn

It will create a directory called pyrit_svn where you are, and download the latest source-code. To update this later, run:

svn update

You will end up with a directory-tree that contains everything in the pyrit project. The ones we are interested in now are the directories called pyrit and cpyrit_stream.

From here on the instructions continue the same way, whether you got the SVN or the stable code.

Compiling Pyrit

If you downloaded the packages, open them up and place them for instance in your home directory. First, enter the directory called pyrit and run the following command:

python setup.py build

If that succeeds, and you don’t see any errors (it should be pretty quick), type in the following command:

sudo python setup.py install

You should also get no errors from this before moving on.

Compiling cpyrit_stream

Now we’re compiling the ATI Stream component of Pyrit (as opposed to CUDA for Nvidia cards). Go back to the directory you unpacked the stream files (or the pyrit_svn directory if you downloaded that), and enter the cpyrit_stream directory. Run the same commands as you did with Pyrit main, i.e python setup.py build and then sudo python setup.py install.

Note! You will probably hit a glitch here, as i have done every single time i’ve compiled Pyrit. These are known issues, which are adressed in the following way:

You’ll get an error that says something about:

/usr/local/atibrook/sdk/include/brook/CPU/brtvector.hpp:190: explicit template specialization cannot have a storage class

There’s an error in two files (with the latest version of Linux Kernel/ATI drivers, i’m not a developer so i can’t say what changed, but these changes were necessary) that need to be corrected before you can compile cpyrit_stream.

You need to locate and open the following file: /usr/local/atibrook/sdk/include/brook/CPU/brtvector.hpp

Inside this file, find the following line: #define SPECIALGETAT(TYP) template <> static TYP GetAt (const TYP& in,int i) {return in;}

From this line, remove the word static. Save and close the file. Do this as sudo, because atistram is installed somewhere where you probably don’t have write permission.

From the same directory, open as sudo the file brtarray.hpp, and in the beginning of the file, find the line or lines that start with include, and add the following there:

#include cstdio (with cstdio inside < these > characters)

Save and close the file. cpyrit_stream should now compile perfectly. If you have doubts, replace the word build with clean, and then start the compilation again.

After this, add the following lines to your .bashrc .bash_profile .profile file (s). I frankly don’t know which of them is the effective one, but the idea is to load this when you load your profile. We want to add a few variables so that Pyrit can execute the ATI stream code successfully.

export LD_LIBRARY_PATH=/usr/local/atibrook/sdk/lib:/usr/local/atical/utilities/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/atibrook/sdk/bin:$PATH

Additional problems & Testing

You should now have a working Pyrit that can utilize ATI Stream. I ran in to some more problems at this point, but i was able to solve them with the help of the internets.

Next, try seeing of you can locate the GPU using the FindNumDevices which should tell you that you have one device ready, or the number equal to the amount of GPU’s you have. The bin is inside /usr/local/atical/bin/lnx64 in my case, and you can run it with ./FindNumDevices.

Note! At this point i ran in to a segfault, which is caused by the fglrx driver and the PAT option being enabled in the kernel. You can try the command, and see what you get, but if you get a segfault, see the next chapter.

Your output should be like this:

Supported CAL Runtime Version: 1.3.185
Found CAL Runtime Version: 1.4.427
Use -? for help
CAL initialized.
Finding out number of devices :-
Device Count = 1
CAL shutdown successful.

Press enter to exit…

Where the device count is .. what i said before.

If you get this, you are ready to try out Pyrit. Type in pyrit list_cores to see the devices available for calculation use in Pyrit. You should get your processor cores minus one, and your gpu(s).  My output looks like this:

Pyrit 0.2.5-dev (svn r193) (C) 2008, 2009 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3

Connecting to storage… connected

The following cores seem available…
#1:  ‘ATI-Stream device 1’
#2:  ‘CPU-Core (SSE2)’
#3:  ‘CPU-Core (SSE2)’
#4:  ‘CPU-Core (SSE2)’

You can now run pyrit benchmark to see what kind of processing power you are looking at. Refer to the pyrit site for a more complete howto of the program. The benchmark command will give you the amount of PMKs per second that the different cores can do. In my case, the output was something like, 8400 PMKs/s for my Radeon, and around 700 PMKs/s for each of my Phenom cores.

Troubleshooting the Segfault

Starting out according to the instructions on various sites (mainly the Pyrit site), i ran into a segfault with both pyrit list_cores and ./FindNumDevices. It wouldn’t execute at all. Running list_cores as sudo, i didn’t get the segfault, i got my four Phenom Cores  (and no Radeon cores anywhere).

I found exactly one (1) result with google, but that got me in the right direction. It has something to do with a problem between PAT and fglrx, PAT being Page Attribute Table (yeah, i googled that..). To get rid of the problem, pass the nopat option to the kernel at boot. If you haven’t done this before, boot your machine, and when you get to to grub, hit e to edit the commands being run.

Locate the line which has the boot command, and at the end of my line (my line ended with the options quiet nosplash) so i made it quiet nosplash nopat and hit ctrl-x to boot with those commands. You can edit your grub to always start with nopat, but i will not get in to that here.

After this, both ./FindNumDevices and pyrit list_cores ran like a charm and produced the end-result i was looking for, that is, using your GPU to chip away at some pesky PMK.

This is just an expansion and update on the great instruction in Pyrit’s wiki, but other sources were used as well!

3 thoughts on “ATI Stream & Pyrit update!

  1. Following the guide I’ve decided to second someone elses comment about this being a frustrating “Piece of Shit” piece of software to get working for ATI/Ubuntu. Oddly enough, I googled “Pyrit is a piece of shit” and this is where I ended up. Nice that you attempted the guide but it doesn’t even come close to what really happens when you try and install it via svn or tar’s. Perhaps this doesn’t work with 9.1? Either way, I’m about ready to break my keyboard in half. Time to go for a walk.

    +1 karma for the attempt tho.

    1. Well, the guide was made pretty much as i did the installation, so it should be pretty close. And done on 9.10.

      Before breaking your keyboard in half (which can be a satisfying pastime, i’ll admit), please tell me where the guide differs from what happened to you?

      I might improve on this, or simply offer tips, since i’ve done this quite a number of times already on my own machine.

      (P.S. Do you have any idea how many times i wanted to start doing something violent while trying to get this working.. jeesh. It’s not easy, by any stretch of the imagination, but it can be done.)

  2. It’s been a while since I did some keyboard ninja…Currently pimping my backtrack 4 installation. Also Pyrit is the tool of choice for BF.

    Thanks for this great install guide


Leave a Reply

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