Wednesday, January 5, 2011

Setting up Pyrit on OSX with CUDA Support

A quick guide on getting pyrit installed and working on OSX with gpu (CUDA) support.

First you need to download and install CUDA drivers and CUDA SDK from nvidia.
Drivers -
http://www.nvidia.com/object/macosx-cuda-3.2.17-driver.html

CUDA SDK -
http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.17_macos.pkg


Next you need to install Scapy
Scapy requires a couple libraries to be installed first - pylibpcap and libdnet.

Download and install libdnet and its python bindings
http://libdnet.googlecode.com/files/libdnet-1.12.tgz
tar -xzf libdnet-1.12.tgz
cd libdnet-1.12
./configure
make
sudo make install
cd python
sudo python setup.py install


Download and install pylibpcap
http://dfn.dl.sourceforge.net/sourceforge/pylibpcap/pylibpcap-0.6.2.tar.gz
tar -xzf pylibpcap-0.6.2.tar.gz
cd pylibpcap-0.6.2
sudo python setup.py install


Download and install scapy
http://www.secdev.org/projects/scapy/files/scapy-latest.tar.gz
tar -xzf scapy-latest.tar.gz
cd scapy-latest
sudo python setup.py install



Now that all the pre-reqs are installed we can now build and install Pyrit.

Download the latest pyrit from svn -
svn checkout http://pyrit.googlecode.com/svn/trunk/ pyrit-read-only

Build and install pyrit -
cd pyrit-read-only
cd pyrit
sudo python setup.py install


Build and install pyrit-cuda -
cd pyrit-read-only
cd cpyrit_cuda
sudo LDFLAGS=-L/usr/local/cuda/lib python setup.py install



Now that Pyrit is installed verify that cuda support is working -
pyrit list_cores
Pyrit 0.4.0-dev (svn r288) (C) 2008-2010 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

The following cores seem available...
#1: 'CUDA-Device #1 'GeForce GT 330M''
#2: 'CPU-Core (SSE2)'
#3: 'CPU-Core (SSE2)'
#4: 'CPU-Core (SSE2)'
#5: 'Network-Clients'

14 comments:

  1. print the results from the self test!! i wanna see! :D

    ReplyDelete
  2. I am guessing you mean the benchmark? My machine is a bit slower then the one posted above which is running an i7 but here are my benchmarks and Selftest on an older macbook..

    bash-3.2# pyrit selftest
    Pyrit 0.4.0-dev (svn r288) (C) 2008-2010 Lukas Lueg http://pyrit.googlecode.com
    This code is distributed under the GNU General Public License v3+

    Cores incorporated in the test:
    #1: 'CUDA-Device #1 'GeForce 9400M''
    #2: 'CPU-Core (SSE2)'
    #3: 'Network-Clients'

    Running selftest...

    All results verified. Your installation seems OK
    bash-3.2# pyrit benchmark
    Pyrit 0.4.0-dev (svn r288) (C) 2008-2010 Lukas Lueg http://pyrit.googlecode.com
    This code is distributed under the GNU General Public License v3+

    Running benchmark (1067.7 PMKs/s)... /

    Computed 1067.72 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce 9400M'': 651.2 PMKs/s (RTT 3.0)
    #2: 'CPU-Core (SSE2)': 539.1 PMKs/s (RTT 2.9)
    #3: 'Network-Clients': 0.0 PMKs/s (RTT 0.0)
    bash-3.2#

    ReplyDelete
  3. Here are my results on benchmark -

    $ pyrit benchmark
    Pyrit 0.4.0-dev (svn r288) (C) 2008-2010 Lukas Lueg http://pyrit.googlecode.com
    This code is distributed under the GNU General Public License v3+

    Running benchmark (3169.6 PMKs/s)... \

    Computed 3169.65 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce GT 330M'': 2067.6 PMKs/s (RTT 2.9)
    #2: 'CPU-Core (SSE2)': 448.2 PMKs/s (RTT 2.9)
    #3: 'CPU-Core (SSE2)': 444.2 PMKs/s (RTT 3.1)
    #4: 'CPU-Core (SSE2)': 442.5 PMKs/s (RTT 3.1)
    #5: 'Network-Clients': 0.0 PMKs/s (RTT 0.0)

    ReplyDelete
  4. Here's mine:

    $ pyrit benchmark
    Pyrit 0.4.0-dev (svn r288) (C) 2008-2010 Lukas Lueg http://pyrit.googlecode.com
    This code is distributed under the GNU General Public License v3+

    Running benchmark (1257.4 PMKs/s)... |

    Computed 1257.44 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce 9400M'': 681.8 PMKs/s (RTT 3.0)
    #2: 'CPU-Core (SSE2)': 655.0 PMKs/s (RTT 3.0)

    ReplyDelete
  5. I did all this on OSX 10.6.6 and it gives

    $ pyrit
    -bash: pyrit: command not found

    can someone help please

    ReplyDelete
  6. 2011 2.3 i7 MBP
    Running benchmark (3316.8 PMKs/s)... /

    Computed 3316.75 PMKs/s total.
    #1: 'CPU-Core (SSE2)': 437.8 PMKs/s (RTT 3.2)
    #2: 'CPU-Core (SSE2)': 438.7 PMKs/s (RTT 3.2)
    #3: 'CPU-Core (SSE2)': 437.3 PMKs/s (RTT 3.2)
    #4: 'CPU-Core (SSE2)': 438.4 PMKs/s (RTT 3.2)
    #5: 'CPU-Core (SSE2)': 437.6 PMKs/s (RTT 3.2)
    #6: 'CPU-Core (SSE2)': 437.8 PMKs/s (RTT 3.1)
    #7: 'CPU-Core (SSE2)': 437.4 PMKs/s (RTT 3.2)
    #8: 'CPU-Core (SSE2)': 438.2 PMKs/s (RTT 3.2)

    ReplyDelete
  7. gunit:
    Is that the MBP 13" or 15" ?
    or the ATI is not supported in Pyrit?

    ReplyDelete
  8. I'm getting this:
    Cores incorporated in the test:
    #1: 'CUDA-Device #1 'GeForce 9600M GT''
    #2: 'CUDA-Device #2 'GeForce 9400M''

    Computed 1399.59 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce 9600M GT'': 903.1 PMKs/s (RTT 3.0)
    #2: 'CUDA-Device #2 'GeForce 9400M'': 599.1 PMKs/s (RTT 2.9)

    any ideas why my CPU isn't used?

    ReplyDelete
  9. $ sudo python setup.py install
    Password:
    running install
    running build
    running build_py
    copying pyrit_cli.py -> build/lib.macosx-10.6-universal-2.6
    copying cpyrit/storage.py -> build/lib.macosx-10.6-universal-2.6/cpyrit
    running build_ext
    building 'cpyrit._cpyrit_cpu' extension
    gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c cpyrit/_cpyrit_cpu.c -o build/temp.macosx-10.6-universal-2.6/cpyrit/_cpyrit_cpu.o -Wall -fno-strict-aliasing -DVERSION="0.4.1-dev (svn r304)" -maes -mpclmul
    cc1: error: unrecognized command line option "-maes"
    cc1: error: unrecognized command line option "-mpclmul"
    cc1: error: unrecognized command line option "-maes"
    cc1: error: unrecognized command line option "-mpclmul"
    cc1: error: unrecognized command line option "-maes"
    cc1: error: unrecognized command line option "-mpclmul"
    lipo: can't open input file: /var/tmp//ccKcX4hy.out (No such file or directory)
    error: command 'gcc-4.2' failed with exit status 1

    Why cannot I do this again? It worked before with cuda and all.

    ReplyDelete
  10. it's the same error i encountered, i think it's because of xcode 4, to fix it, you have to use this command
    env ARCHFLAGS="-arch i386 -arch x86_64" python setup.py install

    insted of only python setup.py install

    it worked for me!
    Bye

    ReplyDelete
  11. Thanks a lot for the post.

    Line: "cd scapy-latest" should be "cd scapy-2.1.0"

    Benchmark:
    Dualcore 2.5GhZ, 4GB RAM, 10.6.8

    Computed 1790.41 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce 8600M GT'': 1301.4 PMKs/s (RTT 2.9)
    #2: 'CPU-Core (SSE2)': 653.5 PMKs/s (RTT 3.2)

    On precomputed, that's where it's getting really nice: 1,675,388 PMKs/s

    Once again,
    Thanks a lot!

    ReplyDelete
  12. I know this was a bit ago but here are the benchmarks on the newest retinia macbook with 2.7 processer 16gigs ram and and the GT650 card that comes stock.. Its quite a bit faster

    Computed 8787.57 PMKs/s total.
    #1: 'CUDA-Device #1 'GeForce GT 650M'': 6287.1 PMKs/s (RTT 2.8)
    #2: 'CPU-Core (SSE2)': 463.6 PMKs/s (RTT 3.2)
    #3: 'CPU-Core (SSE2)': 462.5 PMKs/s (RTT 3.2)
    #4: 'CPU-Core (SSE2)': 461.6 PMKs/s (RTT 3.2)
    #5: 'CPU-Core (SSE2)': 463.6 PMKs/s (RTT 3.2)
    #6: 'CPU-Core (SSE2)': 464.6 PMKs/s (RTT 3.2)
    #7: 'CPU-Core (SSE2)': 463.2 PMKs/s (RTT 3.2)
    #8: 'CPU-Core (SSE2)': 463.2 PMKs/s (RTT 3.2)

    ReplyDelete
  13. I get to the LAST command,and get this....

    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

    Any idea?
    cuda is usr/local/cuda/bin

    ReplyDelete
  14. a query, I installed everything correctly,
    when running list_cores: shows me this.
    all right, let me know as I do that
    "'CUDA-Device # 1' GeForce 410 '' 'show me
    the other 3 cores?

    #1: 'CUDA-Device #1 'GeForce 410''
    #2: 'CPU-Core (SSE2)'
    #3: 'CPU-Core (SSE2)'
    #4: 'CPU-Core (SSE2)'

    ReplyDelete

Note: Only a member of this blog may post a comment.

Filling in the Gaps of your foundational Knowlege

  Hacking is basically just abuse of foundational knowledge. Seriously, its about foundational knowledge. So learn it!! So the new kids don...