deps.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #!/bin/bash
  2. # Author: Gabriele Gristina <matrix@hashcat.net>
  3. # Revision: 1.0
  4. ## global vars
  5. DEPS="git lzip gcc-multilib make m4 mingw-w64"
  6. GMP_VER="gmp-6.1.0"
  7. ## enter the deps directory
  8. cur_directory=$(dirname ${0})
  9. script_directory=$(cd ${cur_directory} && pwd -P)
  10. deps_dir=${script_directory}/../deps
  11. mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
  12. cd ${deps_dir}
  13. ## root check
  14. if [ $(id -u) -ne 0 ]; then
  15. echo "! Must be root"
  16. exit 1
  17. fi
  18. ## make a fresh "deps" directories
  19. rm -rf tmp/gmp* gmp/{linux32,linux64,win32,win64,osx64} && \
  20. mkdir -p gmp/{linux32,linux64,win32,win64,osx64} tmp && \
  21. cd tmp
  22. if [ $? -ne 0 ]; then
  23. echo "! Cannot create the deps directories."
  24. exit 1
  25. fi
  26. ## install osx cross stuff
  27. if [ ! -d "apple-pkgs" ]; then
  28. mkdir -p apple-pkgs
  29. fi
  30. cd apple-pkgs
  31. if [ ! -f "libssl0.9.8_0.9.8o-4squeeze14_amd64.deb" ]; then
  32. wget -c http://http.us.debian.org/debian/pool/main/o/openssl/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
  33. if [ $? -ne 0 ]; then
  34. echo "! failed to download libssl0.9.8 debian package"
  35. exit 1
  36. fi
  37. fi
  38. dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
  39. if [ $? -ne 0 ]; then
  40. echo "! failed to install libssl0.9.8"
  41. exit 1
  42. fi
  43. if [ ! -f "apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb" ]; then
  44. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb
  45. if [ $? -ne 0 ]; then
  46. echo "! failed to download apple-uni-sdk-10.5 debian package"
  47. exit 1
  48. fi
  49. fi
  50. dpkg -i apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb
  51. if [ $? -ne 0 ]; then
  52. echo "! failed to install apple-uni-sdk-10.5"
  53. exit 1
  54. fi
  55. if [ ! -f "apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb" ]; then
  56. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb
  57. if [ $? -ne 0 ]; then
  58. echo "! failed to download apple-uni-sdk-10.6 debian package"
  59. exit 1
  60. fi
  61. fi
  62. dpkg -i apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb
  63. if [ $? -ne 0 ]; then
  64. echo "! failed to install apple-uni-sdk-10.6"
  65. exit 1
  66. fi
  67. if [ ! -f "apple-x86-odcctools_758.159-0flosoft11_amd64.deb" ]; then
  68. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-x86-odcctools_758.159-0flosoft11_amd64.deb
  69. if [ $? -ne 0 ]; then
  70. echo "! failed to download apple-x86-odcctools debian package"
  71. exit 1
  72. fi
  73. fi
  74. dpkg -i apple-x86-odcctools_758.159-0flosoft11_amd64.deb
  75. if [ $? -ne 0 ]; then
  76. echo "! failed to install apple-x86-odcctools"
  77. exit 1
  78. fi
  79. if [ ! -f "apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb" ]; then
  80. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb
  81. if [ $? -ne 0 ]; then
  82. echo "! failed to download apple-x86-gcc debian package"
  83. exit 1
  84. fi
  85. fi
  86. dpkg -i apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb
  87. if [ $? -ne 0 ]; then
  88. echo "! failed to install apple-x86-gcc"
  89. exit 1
  90. fi
  91. cd ..
  92. ## installing needed packages
  93. for pkg in ${DEPS}; do
  94. apt-get -y install ${pkg}
  95. if [ $? -ne 0 ]; then
  96. echo "! failed to install ${pkg}"
  97. exit 1
  98. fi
  99. done
  100. ## download gmp source code
  101. wget -c https://gmplib.org/download/gmp/${GMP_VER}.tar.lz
  102. if [ $? -ne 0 ]; then
  103. echo "! failed to download GMP source code"
  104. exit 1
  105. fi
  106. tar xf ${GMP_VER}.tar.lz
  107. if [ $? -ne 0 ]; then
  108. echo "! failed to extract GMP source code"
  109. exit 1
  110. fi
  111. newDir=$(tar tvf ${GMP_VER}.tar.lz | head -n1 | awk '{print $6}' | sed -e 's/\///g')
  112. if [ "${newDir}" != "${GMP_VER}" ]; then
  113. mv ${newDir} ${GMP_VER}
  114. fi
  115. ## build gmp lib for linux32
  116. cp -af ${GMP_VER} ${GMP_VER}-linux32
  117. cd ${GMP_VER}-linux32 && \
  118. ./configure --host=i386-pc-linux-gnu --prefix=${deps_dir}/gmp/linux32 --disable-shared && \
  119. sudo make install && \
  120. cd .. && \
  121. rm -rf ${GMP_VER}-linux32
  122. if [ $? -ne 0 ]; then
  123. echo "! failed to build linux32 gmp lib."
  124. exit 1
  125. fi
  126. ## build gmp lib for linux64
  127. cp -af ${GMP_VER} ${GMP_VER}-linux64
  128. cd ${GMP_VER}-linux64 && \
  129. ./configure --host=x86_64-pc-linux-gnu --prefix=${deps_dir}/gmp/linux64 --disable-shared && \
  130. sudo make install && \
  131. cd .. && \
  132. rm -rf ${GMP_VER}-linux64
  133. if [ $? -ne 0 ]; then
  134. echo "! failed to build linux64 gmp lib."
  135. exit 1
  136. fi
  137. ## build gmp lib for win32
  138. cp -af ${GMP_VER} ${GMP_VER}-win32
  139. cd ${GMP_VER}-win32 && \
  140. ./configure --host=i686-w64-mingw32 --prefix=${deps_dir}/gmp/win32 --disable-shared && \
  141. sudo make install && \
  142. cd .. && \
  143. rm -rf ${GMP_VER}-win32
  144. if [ $? -ne 0 ]; then
  145. echo "! failed to build win32 gmp lib."
  146. exit 1
  147. fi
  148. ## build gmp lib for win64
  149. cp -af ${GMP_VER} ${GMP_VER}-win64
  150. cd ${GMP_VER}-win64 && \
  151. ./configure --host=x86_64-w64-mingw32 --prefix=${deps_dir}/gmp/win64 --disable-shared && \
  152. sudo make install && \
  153. cd .. && \
  154. rm -rf ${GMP_VER}-win64
  155. if [ $? -ne 0 ]; then
  156. echo "! failed to build win64 gmp lib."
  157. exit 1
  158. fi
  159. ## build gmp lib for osx64
  160. cp -af ${GMP_VER} ${GMP_VER}-osx64
  161. cd ${GMP_VER}-osx64 && \
  162. sed -i 's/\(i686.*\)$/\1\n\tabilist=64/' configure && \
  163. ABI=64 ./configure --host=i686-apple-darwin10 --prefix=${deps_dir}/gmp/osx64 --disable-shared --disable-assembly && \
  164. sudo make install && \
  165. cd .. && \
  166. rm -rf ${GMP_VER}-osx64
  167. if [ $? -ne 0 ]; then
  168. echo "! failed to build osx64 gmp lib."
  169. exit 1
  170. fi
  171. echo
  172. echo "> Successfully resolved all dependencies for hashcat."