Initial commit
[hashcat.git] / tools / deps.sh
1 #!/bin/bash
2 # Author: Gabriele Gristina <matrix@hashcat.net>
3 # Revision: 1.0
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 AMDAPPSDK-3.0-linux64.tar.bz2"
8
9 ## root check
10 if [ $(id -u) -ne 0 ]; then
11 echo "! Must be root"
12 exit 1
13 fi
14
15 ## cleanup 'hashcat-deps' directories
16 rm -rf /opt/hashcat-deps/{adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
17 mkdir -p /opt/hashcat-deps/{tmp,adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
18 cd /opt/hashcat-deps/tmp
19
20 if [ $? -ne 0 ]; then
21 echo "! Cannot create hashcat-deps directories."
22 exit 1
23 fi
24
25 ## check dependencies
26 i=0
27 for d in ${DOWNLOAD_DEPS}; do
28 if [ ! -f "${d}" ]; then
29 echo "! ${d} not found."
30 ((i++))
31 fi
32 done
33
34 if [ ${i} -gt 0 ]; then
35 echo "! Please download manually into the directory /opt/hashcat-deps/tmp"
36 exit 1
37 fi
38
39 ## installing needed packages
40 for pkg in ${DEPS}; do
41 apt-get -y install ${pkg}
42 if [ $? -ne 0 ]; then
43 echo "! failed to install ${pkg}"
44 exit 1
45 fi
46 done
47
48 ## extract ADL SDK
49 unzip ADL_SDK8.zip -d /opt/hashcat-deps/adl-sdk-8
50 ret=$?
51
52 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
53 echo "! failed to extract ADL SDK"
54 exit 1
55 fi
56
57 rm -rf /opt/hashcat-deps/adl-sdk && ln -s /opt/hashcat-deps/adl-sdk-8 /opt/hashcat-deps/adl-sdk
58
59 if [ $? -ne 0 ]; then
60 echo "! failed to setup ADL SDK link"
61 exit 1
62 fi
63
64 ## extract NVAPI
65 unzip R352-developer.zip -d /opt/hashcat-deps/
66 ret=$?
67
68 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
69 echo "! failed to extract NVAPI"
70 exit 1
71 fi
72
73 ## install CUDA SDK
74 chmod +x cuda_7.5.18_linux.run && \
75 ./cuda_7.5.18_linux.run -toolkit -silent -override --toolkitpath=/opt/hashcat-deps/cuda-7.5
76
77 if [ $? -ne 0 ]; then
78 echo "! failed to install CUDA SDK"
79 exit 1
80 fi
81
82 ## install NVIDIA Driver
83 chmod +x NVIDIA-Linux-x86_64-352.21.run && \
84 ./NVIDIA-Linux-x86_64-352.21.run -x && \
85 mv NVIDIA-Linux-x86_64-352.21 /opt/hashcat-deps/ && \
86 cd /opt/hashcat-deps/NVIDIA-Linux-x86_64-352.21 && \
87 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
88 ln -s libcuda.so.352.21 libcuda.so && \
89 cd 32 && \
90 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
91 ln -s libcuda.so.352.21 libcuda.so && \
92 cd /opt/hashcat-deps/tmp
93
94 if [ $? -ne 0 ]; then
95 echo "! failed to install NVIDIA Driver"
96 exit 1
97 fi
98
99 ## install NVIDIA GPU Deployment Kit
100 chmod +x gdk_linux_amd64_352_55_release.run && \
101 ./gdk_linux_amd64_352_55_release.run --silent --installdir=/opt/hashcat-deps/nvidia-gdk
102
103 if [ $? -ne 0 ]; then
104 echo "! failed to install NVIDIA GPU Deployment Kit"
105 exit 1
106 fi
107
108 ## extract AMD APP SDK
109 tar xjf AMDAPPSDK-3.0-linux64.tar.bz2 && \
110 ./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target /opt/hashcat-deps/amd-app-sdk-v3.0.130.135
111
112 if [ $? -ne 0 ]; then
113 echo "! failed to extract AMD APP SDK"
114 exit 1
115 fi
116
117 rm -rf /opt/hashcat-deps/amd-app-sdk && ln -s /opt/hashcat-deps/amd-app-sdk-v3.0.130.135 /opt/hashcat-deps/amd-app-sdk
118
119 if [ $? -ne 0 ]; then
120 echo "! failed to setup ADL SDK link"
121 exit 1
122 fi
123
124 echo "> oclHashcat dependencies have been resolved."