All pastes #2067211 Raw Edit

Anonymous

public text v1 · immutable
#2067211 ·published 2011-05-23 01:07 UTC
rendered paste body
#setup.py

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
#    Copyright 2008-2011, Lukas Lueg, lukas.lueg@gmail.com
#
#    This file is part of Pyrit.
#
#    Pyrit is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Pyrit is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Pyrit.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import with_statement

from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
from distutils.command.clean import clean
import os
import re
import subprocess
import sys
import zlib

VERSION = '0.4.1-dev' 

OPENCL_INC_DIRS = []
OPENCL_LIB_DIRS = []
EXTRA_LINK_ARGS = []
LIBRARIES = ['crypto', 'z']
if sys.platform == 'darwin':
    # Use the built-in framework on MacOS
    EXTRA_LINK_ARGS.extend(('-framework', 'OpenCL'))
    OPENCL_INC_DIRS.append('/System/Library/Frameworks/OpenCL.framework/Headers')
else:
    LIBRARIES.append('OpenCL')
    try:
        if os.path.exists(os.environ['ATISTREAMSDKROOT']):
            OPENCL_INC_DIRS.append(os.path.join(os.environ['ATISTREAMSDKROOT'], 'include'))
            for path in ('lib/x86_64','lib/x86'):
                if os.path.exists(os.path.join(os.environ['ATISTREAMSDKROOT'], path)):
                    OPENCL_LIB_DIRS.append(os.path.join(os.environ['ATISTREAMSDKROOT'], path))
                    break
    except:
        pass
    for path in ('/usr/local/opencl/OpenCL/common/inc', \
                '/opt/opencl/OpenCL/common/inc', \
                '/usr/local/opencl/include', \
                '/usr/local/cuda/include'):
        if os.path.exists(path):
            OPENCL_INC_DIRS.append(path)
            break
    else:
        print >>sys.stderr, "The headers required to build the OpenCL-kernel " \
                            "were not found. Trying to continue anyway..."

# Get exact version-string from svn
try:
    svn_info = subprocess.Popen(('svn', 'info'), \
                                stdout=subprocess.PIPE).stdout.read()
    VERSION += ' (svn r%i)' % \
                int(re.compile('Revision: ([0-9]*)').findall(svn_info)[0])
except:
    pass
EXTRA_COMPILE_ARGS = ['-Wall', '-fno-strict-aliasing', \
                      '-DVERSION="%s"' % (VERSION,)]


class GPUBuilder(build_ext):
    def run(self):
        with open("_cpyrit_opencl.h", 'rb') as f:
            header = f.read()
        with open("_cpyrit_oclkernel.cl", 'rb') as f:
            kernel = f.read()
        oclkernel_code = header + '\n' + kernel + '\x00'
        oclkernel_inc = zlib.compress(oclkernel_code)        
        with open("_cpyrit_oclkernel.cl.h", 'wb') as f:
            f.write("unsigned char oclkernel_packedprogram[] = {")
            f.write(",".join(("0x%02X" % ord(c) for c in oclkernel_inc)))
            f.write("};\nsize_t oclkernel_size = %i;\n" % len(oclkernel_code))
        print "Building modules..."
        build_ext.run(self)


class GPUCleaner(clean):
    def _unlink(self, node):
        try:
            if os.path.isdir(node):
                os.rmdir(node)
            else:
                os.unlink(node)
        except OSError:
            pass

    def run(self):
        print "Removing temporary files and pre-built GPU-kernels..."
        try:
            for f in ('_cpyrit_oclkernel.cl.h',):
                self._unlink(f)
        except Exception, (errno, sterrno):
            print >>sys.stderr, "Exception while cleaning temporary " \
                                "files ('%s')" % sterrno
        clean.run(self)


opencl_extension = Extension('cpyrit._cpyrit_opencl',
                    libraries = LIBRARIES,
                    sources = ['_cpyrit_opencl.c'],
                    include_dirs = OPENCL_INC_DIRS,
                    library_dirs = OPENCL_LIB_DIRS,
                    extra_compile_args = EXTRA_COMPILE_ARGS,
                    extra_link_args = EXTRA_LINK_ARGS)

setup_args = dict(
        name = 'cpyrit-opencl',
        version = VERSION,
        description = 'GPU-accelerated attack against WPA-PSK authentication',
        long_description = \
            "Pyrit allows to create massive databases, pre-computing part " \
            "of the WPA/WPA2-PSK authentication phase in a space-time-" \
            "tradeoff. Exploiting the computational power of Many-Core- " \
            "and other platforms through ATI-Stream, Nvidia CUDA, OpenCL " \
            "and VIA Padlock, it is currently by far the most powerful " \
            "attack against one of the world's most used security-protocols.",
        license = 'GNU General Public License v3',
        author = 'Lukas Lueg',
        author_email = 'lukas.lueg@gmail.com',
        url = 'http://pyrit.googlecode.com',
        classifiers = \
              ['Development Status :: 4 - Beta',
               'Environment :: Console',
               'License :: OSI Approved :: GNU General Public License (GPL)',
               'Natural Language :: English',
               'Operating System :: OS Independent',
               'Programming Language :: Python',
               'Topic :: Security'],
        platforms = ['any'],
        ext_modules = [opencl_extension],
        cmdclass = {'build_ext': GPUBuilder, 'clean': GPUCleaner},
        options = {'install': {'optimize': 1}, \
                   'bdist_rpm': {'requires': 'pyrit = 0.4.0-1'}}
        )
        
if __name__ == "__main__":
    setup(**setup_args)



#.bashrc 


ATISTREAMSDKROOT=/root/AMD-APP-SDK-v2.4-lnx64/
ATISTREAMSDKSAMPLESROOT=/root/AMD-APP-SDK-v2.4-lnx64/samples
LD_LIBRARY_PATH=opt/oracle/instantclient_10_2:$ATISTREAMSDKROOT/lib/x86_64
export ATISTREAMSDKROOT
export ATISTREAMSDKSAMPLESROOT



root@bt:~/pyrit_svn/cpyrit_opencl# python setup.py build install
The headers required to build the OpenCL-kernel were not found. Trying to continue anyway...
running build
running build_ext
Building modules...
building 'cpyrit._cpyrit_opencl' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c _cpyrit_opencl.c -o build/temp.linux-x86_64-2.6/_cpyrit_opencl.o -Wall -fno-strict-aliasing -DVERSION="0.4.1-dev (svn r308)"
_cpyrit_opencl.c:45:23: error: CL/cl.h: No such file or directory
_cpyrit_opencl.c:69: error: expected specifier-qualifier-list before ‘cl_device_id’
_cpyrit_opencl.c:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
_cpyrit_opencl.c:81: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘num_platforms’
_cpyrit_opencl.c:86: error: expected ‘)’ before ‘error’
_cpyrit_opencl.c: In function ‘oclplatf_init’:
_cpyrit_opencl.c:145: error: ‘cl_uint’ undeclared (first use in this function)
_cpyrit_opencl.c:145: error: (Each undeclared identifier is reported only once
_cpyrit_opencl.c:145: error: for each function it appears in.)
_cpyrit_opencl.c:145: error: expected ‘;’ before ‘num_devices’
_cpyrit_opencl.c:146: error: ‘cl_int’ undeclared (first use in this function)
_cpyrit_opencl.c:146: error: expected ‘;’ before ‘err’
_cpyrit_opencl.c:153: error: ‘num_platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:163: error: ‘err’ undeclared (first use in this function)
_cpyrit_opencl.c:163: warning: implicit declaration of function ‘clGetDeviceIDs’
_cpyrit_opencl.c:163: error: ‘platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:163: error: ‘CL_DEVICE_TYPE_ALL’ undeclared (first use in this function)
_cpyrit_opencl.c:163: error: ‘num_devices’ undeclared (first use in this function)
_cpyrit_opencl.c:164: error: ‘CL_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:166: warning: implicit declaration of function ‘getCLresultMsg’
_cpyrit_opencl.c:177: warning: implicit declaration of function ‘clGetPlatformInfo’
_cpyrit_opencl.c:177: error: ‘CL_PLATFORM_NAME’ undeclared (first use in this function)
_cpyrit_opencl.c:190: error: ‘CL_PLATFORM_VENDOR’ undeclared (first use in this function)
_cpyrit_opencl.c: In function ‘ocldevice_init’:
_cpyrit_opencl.c:219: error: ‘cl_uint’ undeclared (first use in this function)
_cpyrit_opencl.c:219: error: expected ‘;’ before ‘num_entries’
_cpyrit_opencl.c:220: error: ‘cl_device_id’ undeclared (first use in this function)
_cpyrit_opencl.c:220: error: ‘devices’ undeclared (first use in this function)
_cpyrit_opencl.c:221: error: ‘cl_device_type’ undeclared (first use in this function)
_cpyrit_opencl.c:221: error: expected ‘;’ before ‘device_type’
_cpyrit_opencl.c:225: error: ‘cl_int’ undeclared (first use in this function)
_cpyrit_opencl.c:225: error: expected ‘;’ before ‘err’
_cpyrit_opencl.c:230: error: ‘num_platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:236: error: ‘err’ undeclared (first use in this function)
_cpyrit_opencl.c:236: error: ‘platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:236: error: ‘CL_DEVICE_TYPE_ALL’ undeclared (first use in this function)
_cpyrit_opencl.c:236: error: ‘num_entries’ undeclared (first use in this function)
_cpyrit_opencl.c:237: error: ‘CL_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:248: error: expected expression before ‘)’ token
_cpyrit_opencl.c:261: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:264: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:264: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:264: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:265: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:266: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:267: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:268: error: ‘OpenCLDevice’ has no member named ‘dev_queue’
_cpyrit_opencl.c:270: warning: implicit declaration of function ‘clGetDeviceInfo’
_cpyrit_opencl.c:270: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:270: error: ‘CL_DEVICE_NAME’ undeclared (first use in this function)
_cpyrit_opencl.c:276: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:277: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:283: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:283: error: ‘CL_DEVICE_TYPE’ undeclared (first use in this function)
_cpyrit_opencl.c:283: error: ‘device_type’ undeclared (first use in this function)
_cpyrit_opencl.c:289: error: ‘CL_DEVICE_TYPE_CPU’ undeclared (first use in this function)
_cpyrit_opencl.c:291: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:292: error: ‘CL_DEVICE_TYPE_GPU’ undeclared (first use in this function)
_cpyrit_opencl.c:294: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:295: error: ‘CL_DEVICE_TYPE_ACCELERATOR’ undeclared (first use in this function)
_cpyrit_opencl.c:297: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:300: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:302: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:308: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:308: error: ‘CL_DEVICE_MAX_WORK_GROUP_SIZE’ undeclared (first use in this function)
_cpyrit_opencl.c:308: error: ‘OpenCLDevice’ has no member named ‘dev_workgroupsize’
_cpyrit_opencl.c:308: error: ‘OpenCLDevice’ has no member named ‘dev_workgroupsize’
_cpyrit_opencl.c:315: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:315: error: ‘CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS’ undeclared (first use in this function)
_cpyrit_opencl.c:328: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:328: error: ‘CL_DEVICE_MAX_WORK_ITEM_SIZES’ undeclared (first use in this function)
_cpyrit_opencl.c:335: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:336: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:343: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c: In function ‘ocldevice_compile’:
_cpyrit_opencl.c:353: error: ‘cl_int’ undeclared (first use in this function)
_cpyrit_opencl.c:353: error: expected ‘;’ before ‘err’
_cpyrit_opencl.c:355: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:357: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:357: warning: implicit declaration of function ‘clCreateContext’
_cpyrit_opencl.c:357: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:357: error: ‘err’ undeclared (first use in this function)
_cpyrit_opencl.c:358: error: ‘CL_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:365: error: ‘OpenCLDevice’ has no member named ‘dev_queue’
_cpyrit_opencl.c:367: error: ‘OpenCLDevice’ has no member named ‘dev_queue’
_cpyrit_opencl.c:367: warning: implicit declaration of function ‘clCreateCommandQueue’
_cpyrit_opencl.c:367: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:367: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:375: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:377: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:377: warning: implicit declaration of function ‘clCreateProgramWithSource’
_cpyrit_opencl.c:377: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:385: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:387: warning: implicit declaration of function ‘clBuildProgram’
_cpyrit_opencl.c:387: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:390: warning: implicit declaration of function ‘clGetProgramBuildInfo’
_cpyrit_opencl.c:390: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:390: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:390: error: ‘CL_PROGRAM_BUILD_LOG’ undeclared (first use in this function)
_cpyrit_opencl.c:395: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:395: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:395: error: ‘CL_PROGRAM_BUILD_STATUS’ undeclared (first use in this function)
_cpyrit_opencl.c:395: error: ‘status’ undeclared (first use in this function)
_cpyrit_opencl.c:396: error: ‘CL_BUILD_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:398: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:398: error: ‘OpenCLDevice’ has no member named ‘device’
_cpyrit_opencl.c:403: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:403: warning: implicit declaration of function ‘clCreateKernel’
_cpyrit_opencl.c:403: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c: In function ‘ocldevice_dealloc’:
_cpyrit_opencl.c:418: error: ‘OpenCLDevice’ has no member named ‘dev_queue’
_cpyrit_opencl.c:419: warning: implicit declaration of function ‘clReleaseCommandQueue’
_cpyrit_opencl.c:419: error: ‘OpenCLDevice’ has no member named ‘dev_queue’
_cpyrit_opencl.c:420: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:421: warning: implicit declaration of function ‘clReleaseKernel’
_cpyrit_opencl.c:421: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:422: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:423: warning: implicit declaration of function ‘clReleaseProgram’
_cpyrit_opencl.c:423: error: ‘OpenCLDevice’ has no member named ‘dev_prog’
_cpyrit_opencl.c:424: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:425: warning: implicit declaration of function ‘clReleaseContext’
_cpyrit_opencl.c:425: error: ‘OpenCLDevice’ has no member named ‘dev_ctx’
_cpyrit_opencl.c:426: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:426: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:426: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:426: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:427: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:427: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:427: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:427: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:428: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:428: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:428: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c:428: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c: At top level:
_cpyrit_opencl.c:433: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘calc_pmklist’
_cpyrit_opencl.c: In function ‘cpyrit_solve’:
_cpyrit_opencl.c:517: error: ‘OpenCLDevice’ has no member named ‘dev_kernel’
_cpyrit_opencl.c:612: warning: implicit declaration of function ‘calc_pmklist’
_cpyrit_opencl.c:616: error: ‘CL_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:619: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
_cpyrit_opencl.c: At top level:
_cpyrit_opencl.c:693: error: ‘OpenCLDevice’ has no member named ‘dev_name’
_cpyrit_opencl.c:694: error: ‘OpenCLDevice’ has no member named ‘dev_type’
_cpyrit_opencl.c:695: error: ‘OpenCLDevice’ has no member named ‘dev_maxworksize’
_cpyrit_opencl.c: In function ‘init_cpyrit_opencl’:
_cpyrit_opencl.c:760: error: ‘cl_int’ undeclared (first use in this function)
_cpyrit_opencl.c:760: warning: statement with no effect
_cpyrit_opencl.c:760: error: expected ‘;’ before ‘err’
_cpyrit_opencl.c:762: error: ‘err’ undeclared (first use in this function)
_cpyrit_opencl.c:762: warning: implicit declaration of function ‘clGetPlatformIDs’
_cpyrit_opencl.c:762: error: ‘num_platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:762: warning: statement with no effect
_cpyrit_opencl.c:763: error: ‘CL_SUCCESS’ undeclared (first use in this function)
_cpyrit_opencl.c:765: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
_cpyrit_opencl.c:769: error: ‘platforms’ undeclared (first use in this function)
_cpyrit_opencl.c:769: error: ‘cl_platform_id’ undeclared (first use in this function)
_cpyrit_opencl.c:769: error: invalid operands to binary / (have ‘long int’ and ‘struct PyMemberDef *’)
_cpyrit_opencl.c:769: warning: comparison between pointer and integer
_cpyrit_opencl.c:769: error: expected expression before ‘)’ token
_cpyrit_opencl.c:769: error: invalid operands to binary * (have ‘struct PyMemberDef *’ and ‘struct PyMemberDef *’)
_cpyrit_opencl.c:769: warning: statement with no effect
_cpyrit_opencl.c:776: warning: statement with no effect
_cpyrit_opencl.c:779: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
error: command 'gcc' failed with exit status 1