Merge pull request #149 from gm4tr1x/md5crypt_warnings
[hashcat.git] / tools / deps.sh
index 5f0b556..026db51 100755 (executable)
@@ -1,26 +1,27 @@
 #!/bin/bash
 # Author: Gabriele Gristina <matrix@hashcat.net>
-# Revision: 1.01
+# Revision: 1.03
 
 ## global vars
-DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip"
-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"
+DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip opencl-headers ocl-icd-libopencl1"
+DEPS_AMD_DEV="ocl-icd-opencl-dev"
+DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip gdk_linux_amd64_352_55_release.run"
 
-## enter the hashcat-deps directory
+## enter the deps directory
 cur_directory=$(dirname ${0})
 script_directory=$(cd ${cur_directory} && pwd -P)
-hashcat_deps_dir=${script_directory}/../hashcat-deps
+deps_dir=${script_directory}/../deps
 
-mkdir -p ${hashcat_deps_dir} # but it should already exist (is part of the repository)
-cd ${hashcat_deps_dir}
+mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
+cd ${deps_dir}
 
-## cleanup the directories under the 'hashcat-deps' folder
-rm -rf {adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
-mkdir -p {tmp,adl-sdk,cuda-7.5,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
+## cleanup the directories under the 'deps' folder
+rm -rf {adl-sdk*,nvidia-gdk,R352-developer} && \
+mkdir -p {tmp,adl-sdk,nvidia-gdk,R352-developer} && \
 cd tmp/
 
 if [ $? -ne 0 ]; then
-  echo "! Cannot create hashcat-deps directories."
+  echo "! Cannot create deps directories."
   exit 1
 fi
 
@@ -34,7 +35,7 @@ for d in ${DOWNLOAD_DEPS}; do
 done
 
 if [ ${i} -gt 0 ]; then
-  echo "! Please manually download all the above dependencies to the hashcat-deps/tmp/ directory"
+  echo "! Please manually download all the above dependencies to the deps/tmp/ directory"
   exit 1
 fi
 
@@ -59,7 +60,7 @@ for pkg in ${DEPS}; do
 done
 
 ## extract ADL SDK
-unzip ADL_SDK8.zip -d ${hashcat_deps_dir}/adl-sdk-8
+unzip ADL_SDK8.zip -d ${deps_dir}/adl-sdk-8
 ret=$?
 
 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
@@ -67,7 +68,7 @@ if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
   exit 1
 fi
 
-rm -rf ${hashcat_deps_dir}/adl-sdk && ln -s ${hashcat_deps_dir}/adl-sdk-8 ${hashcat_deps_dir}/adl-sdk
+rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-8 ${deps_dir}/adl-sdk
 
 if [ $? -ne 0 ]; then
   echo "! failed to setup ADL SDK link"
@@ -75,7 +76,7 @@ if [ $? -ne 0 ]; then
 fi
 
 ## extract NVAPI
-unzip R352-developer.zip -d ${hashcat_deps_dir}
+unzip R352-developer.zip -d ${deps_dir}
 ret=$?
 
 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
@@ -83,55 +84,31 @@ if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
   exit 1
 fi
 
-## install CUDA SDK
-chmod +x cuda_7.5.18_linux.run && \
-./cuda_7.5.18_linux.run -toolkit -silent -override --toolkitpath=${hashcat_deps_dir}/cuda-7.5
-
-if [ $? -ne 0 ]; then
-  echo "! failed to install CUDA SDK"
-  exit 1
-fi
-
-## install NVIDIA Driver
-chmod +x NVIDIA-Linux-x86_64-352.21.run && \
-./NVIDIA-Linux-x86_64-352.21.run -x && \
-mv NVIDIA-Linux-x86_64-352.21 ${hashcat_deps_dir}/ && \
-cd ${hashcat_deps_dir}/NVIDIA-Linux-x86_64-352.21 && \
-ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
-ln -s libcuda.so.352.21 libcuda.so && \
-cd 32 && \
-ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
-ln -s libcuda.so.352.21 libcuda.so && \
-cd ${hashcat_deps_dir}/tmp
-
-if [ $? -ne 0 ]; then
-  echo "! failed to install NVIDIA Driver"
-  exit 1
-fi
-
 ## install NVIDIA GPU Deployment Kit
 chmod +x gdk_linux_amd64_352_55_release.run && \
-./gdk_linux_amd64_352_55_release.run --silent --installdir=${hashcat_deps_dir}/nvidia-gdk
+./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
 
 if [ $? -ne 0 ]; then
   echo "! failed to install NVIDIA GPU Deployment Kit"
   exit 1
 fi
 
-## extract AMD APP SDK
-tar xjf AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 && \
-./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target ${hashcat_deps_dir}/amd-app-sdk-v3.0.130.135
+## check if libOpenCL.so is available (and if not install DEPS_AMD_DEV)
 
-if [ $? -ne 0 ]; then
-  echo "! failed to extract AMD APP SDK"
-  exit 1
-fi
-
-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
+ls /usr/lib/*/libOpenCL.so &> /dev/null
 
 if [ $? -ne 0 ]; then
-  echo "! failed to setup ADL SDK link"
-  exit 1
+  ## root check
+  if [ $(id -u) -ne 0 ]; then
+    echo "! Must be root to install '${DEPS_AMD_DEV}'"
+    exit 1
+  fi
+
+  apt-get -y install ${DEPS_AMD_DEV}
+  if [ $? -ne 0 ]; then
+    echo "! failed to install ${DEPS_AMD_DEV}"
+    exit 1
+  fi
 fi
 
 echo "> oclHashcat dependencies have been resolved."