Merge pull request #15 from philsmd/master
[hashcat.git] / tools / deps.sh
1 #!/bin/bash
2 # Author: Gabriele Gristina <matrix@hashcat.net>
3 # Revision: 1.01
4
5 ## global vars
6 DEPS="make gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib libc6-dev-i386 mingw-w64 build-essential unzip"
7 DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip cuda_7.5.18_linux.run NVIDIA-Linux-x86_64-352.21.run gdk_linux_amd64_352_55_release.run AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2"
8
9 ## enter the hashcat-deps directory
10 cur_directory=$(dirname ${0})
11 script_directory=$(cd ${cur_directory} && pwd -P)
12 hashcat_deps_dir=${script_directory}/../hashcat-deps
13
14 mkdir -p ${hashcat_deps_dir} # but it should already exist (is part of the repository)
15 cd ${hashcat_deps_dir}
16
17 ## cleanup the directories under the 'hashcat-deps' folder
18 rm -rf {adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
19 mkdir -p {tmp,adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
20 cd tmp/
21
22 if [ $? -ne 0 ]; then
23 echo "! Cannot create hashcat-deps directories."
24 exit 1
25 fi
26
27 ## check dependencies
28 i=0
29 for d in ${DOWNLOAD_DEPS}; do
30 if [ ! -f "${d}" ]; then
31 echo "! ${d} not found."
32 ((i++))
33 fi
34 done
35
36 if [ ${i} -gt 0 ]; then
37 echo "! Please manually download all the above dependencies to the hashcat-deps/tmp/ directory"
38 exit 1
39 fi
40
41 ## installing needed packages
42 for pkg in ${DEPS}; do
43
44 # check if the package is already installed
45 dpkg -s ${pkg} &>/dev/null
46 if [ $? -ne 0 ]; then
47 ## root check
48 if [ $(id -u) -ne 0 ]; then
49 echo "! Must be root to install the required package '${pkg}' with apt-get"
50 exit 1
51 fi
52
53 apt-get -y install ${pkg}
54 if [ $? -ne 0 ]; then
55 echo "! failed to install ${pkg}"
56 exit 1
57 fi
58 fi
59 done
60
61 ## extract ADL SDK
62 unzip ADL_SDK8.zip -d ${hashcat_deps_dir}/adl-sdk-8
63 ret=$?
64
65 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
66 echo "! failed to extract ADL SDK"
67 exit 1
68 fi
69
70 rm -rf ${hashcat_deps_dir}/adl-sdk && ln -s ${hashcat_deps_dir}/adl-sdk-8 ${hashcat_deps_dir}/adl-sdk
71
72 if [ $? -ne 0 ]; then
73 echo "! failed to setup ADL SDK link"
74 exit 1
75 fi
76
77 ## extract NVAPI
78 unzip R352-developer.zip -d ${hashcat_deps_dir}
79 ret=$?
80
81 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
82 echo "! failed to extract NVAPI"
83 exit 1
84 fi
85
86 ## install CUDA SDK
87 chmod +x cuda_7.5.18_linux.run && \
88 ./cuda_7.5.18_linux.run -toolkit -silent -override --toolkitpath=${hashcat_deps_dir}/cuda-7.5
89
90 if [ $? -ne 0 ]; then
91 echo "! failed to install CUDA SDK"
92 exit 1
93 fi
94
95 ## install NVIDIA Driver
96 chmod +x NVIDIA-Linux-x86_64-352.21.run && \
97 ./NVIDIA-Linux-x86_64-352.21.run -x && \
98 mv NVIDIA-Linux-x86_64-352.21 ${hashcat_deps_dir}/ && \
99 cd ${hashcat_deps_dir}/NVIDIA-Linux-x86_64-352.21 && \
100 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
101 ln -s libcuda.so.352.21 libcuda.so && \
102 cd 32 && \
103 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
104 ln -s libcuda.so.352.21 libcuda.so && \
105 cd ${hashcat_deps_dir}/tmp
106
107 if [ $? -ne 0 ]; then
108 echo "! failed to install NVIDIA Driver"
109 exit 1
110 fi
111
112 ## install NVIDIA GPU Deployment Kit
113 chmod +x gdk_linux_amd64_352_55_release.run && \
114 ./gdk_linux_amd64_352_55_release.run --silent --installdir=${hashcat_deps_dir}/nvidia-gdk
115
116 if [ $? -ne 0 ]; then
117 echo "! failed to install NVIDIA GPU Deployment Kit"
118 exit 1
119 fi
120
121 ## extract AMD APP SDK
122 tar xjf AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 && \
123 ./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target ${hashcat_deps_dir}/amd-app-sdk-v3.0.130.135
124
125 if [ $? -ne 0 ]; then
126 echo "! failed to extract AMD APP SDK"
127 exit 1
128 fi
129
130 rm -rf ${hashcat_deps_dir}/amd-app-sdk && ln -s ${hashcat_deps_dir}/amd-app-sdk-v3.0.130.135 ${hashcat_deps_dir}/amd-app-sdk
131
132 if [ $? -ne 0 ]; then
133 echo "! failed to setup ADL SDK link"
134 exit 1
135 fi
136
137 echo "> oclHashcat dependencies have been resolved."