deps.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #!/bin/bash
  2. # Author: Gabriele Gristina <matrix@hashcat.net>
  3. # Revision: 1.1
  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. mkdir -p apple-pkgs
  28. cd apple-pkgs
  29. dpkg -l | grep libssl0.9.8 | grep ^ii &>/dev/null
  30. if [ $? -ne 0 ]; then
  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. fi
  44. dpkg -l | grep apple-uni-sdk-10.5 | grep ^ii &>/dev/null
  45. if [ $? -ne 0 ]; then
  46. if [ ! -f "apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb" ]; then
  47. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb
  48. if [ $? -ne 0 ]; then
  49. echo "! failed to download apple-uni-sdk-10.5 debian package"
  50. exit 1
  51. fi
  52. fi
  53. dpkg -i apple-uni-sdk-10.5_20110407-0.flosoft1_amd64.deb
  54. if [ $? -ne 0 ]; then
  55. echo "! failed to install apple-uni-sdk-10.5"
  56. exit 1
  57. fi
  58. fi
  59. dpkg -l | grep apple-uni-sdk-10.6 | grep ^ii &>/dev/null
  60. if [ $? -ne 0 ]; then
  61. if [ ! -f "apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb" ]; then
  62. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb
  63. if [ $? -ne 0 ]; then
  64. echo "! failed to download apple-uni-sdk-10.6 debian package"
  65. exit 1
  66. fi
  67. fi
  68. dpkg -i apple-uni-sdk-10.6_20110407-0.flosoft1_amd64.deb
  69. if [ $? -ne 0 ]; then
  70. echo "! failed to install apple-uni-sdk-10.6"
  71. exit 1
  72. fi
  73. fi
  74. dpkg -l | grep apple-x86-odcctools | grep ^ii &>/dev/null
  75. if [ $? -ne 0 ]; then
  76. if [ ! -f "apple-x86-odcctools_758.159-0flosoft11_amd64.deb" ]; then
  77. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-x86-odcctools_758.159-0flosoft11_amd64.deb
  78. if [ $? -ne 0 ]; then
  79. echo "! failed to download apple-x86-odcctools debian package"
  80. exit 1
  81. fi
  82. fi
  83. dpkg -i apple-x86-odcctools_758.159-0flosoft11_amd64.deb
  84. if [ $? -ne 0 ]; then
  85. echo "! failed to install apple-x86-odcctools"
  86. exit 1
  87. fi
  88. fi
  89. dpkg -l | grep apple-x86-gcc | grep ^ii &>/dev/null
  90. if [ $? -ne 0 ]; then
  91. if [ ! -f "apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb" ]; then
  92. wget -c https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+files/apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb
  93. if [ $? -ne 0 ]; then
  94. echo "! failed to download apple-x86-gcc debian package"
  95. exit 1
  96. fi
  97. fi
  98. dpkg -i apple-x86-gcc_4.2.1~5646.1flosoft2_amd64.deb
  99. if [ $? -ne 0 ]; then
  100. echo "! failed to install apple-x86-gcc"
  101. exit 1
  102. fi
  103. fi
  104. cd ..
  105. ## installing needed packages
  106. apt-get -y install ${DEPS}
  107. if [ $? -ne 0 ]; then
  108. echo "! failed to install deps packages"
  109. exit 1
  110. fi
  111. ## download gmp source code
  112. wget -c https://gmplib.org/download/gmp/${GMP_VER}.tar.lz
  113. if [ $? -ne 0 ]; then
  114. echo "! failed to download GMP source code"
  115. exit 1
  116. fi
  117. tar xf ${GMP_VER}.tar.lz
  118. if [ $? -ne 0 ]; then
  119. echo "! failed to extract GMP source code"
  120. exit 1
  121. fi
  122. newDir=$(tar tvf ${GMP_VER}.tar.lz | head -n1 | awk '{print $6}' | sed -e 's/\///g')
  123. if [ "${newDir}" != "${GMP_VER}" ]; then
  124. mv ${newDir} ${GMP_VER}
  125. fi
  126. ## build gmp lib for linux32
  127. cp -af ${GMP_VER} ${GMP_VER}-linux32
  128. cd ${GMP_VER}-linux32 && \
  129. ./configure --host=i386-pc-linux-gnu --prefix=${deps_dir}/gmp/linux32 --disable-shared && \
  130. sudo make install && \
  131. cd .. && \
  132. rm -rf ${GMP_VER}-linux32
  133. if [ $? -ne 0 ]; then
  134. echo "! failed to build linux32 gmp lib."
  135. exit 1
  136. fi
  137. ## build gmp lib for linux64
  138. cp -af ${GMP_VER} ${GMP_VER}-linux64
  139. cd ${GMP_VER}-linux64 && \
  140. ./configure --host=x86_64-pc-linux-gnu --prefix=${deps_dir}/gmp/linux64 --disable-shared && \
  141. sudo make install && \
  142. cd .. && \
  143. rm -rf ${GMP_VER}-linux64
  144. if [ $? -ne 0 ]; then
  145. echo "! failed to build linux64 gmp lib."
  146. exit 1
  147. fi
  148. ## build gmp lib for win32
  149. cp -af ${GMP_VER} ${GMP_VER}-win32
  150. cd ${GMP_VER}-win32 && \
  151. ./configure --host=i686-w64-mingw32 --prefix=${deps_dir}/gmp/win32 --disable-shared && \
  152. sudo make install && \
  153. cd .. && \
  154. rm -rf ${GMP_VER}-win32
  155. if [ $? -ne 0 ]; then
  156. echo "! failed to build win32 gmp lib."
  157. exit 1
  158. fi
  159. ## build gmp lib for win64
  160. cp -af ${GMP_VER} ${GMP_VER}-win64
  161. cd ${GMP_VER}-win64 && \
  162. ./configure --host=x86_64-w64-mingw32 --prefix=${deps_dir}/gmp/win64 --disable-shared && \
  163. sudo make install && \
  164. cd .. && \
  165. rm -rf ${GMP_VER}-win64
  166. if [ $? -ne 0 ]; then
  167. echo "! failed to build win64 gmp lib."
  168. exit 1
  169. fi
  170. ## build gmp lib for osx64
  171. cp -af ${GMP_VER} ${GMP_VER}-osx64
  172. cd ${GMP_VER}-osx64 && \
  173. sed -i 's/\(i686.*\)$/\1\n\tabilist=64/' configure && \
  174. ABI=64 ./configure --host=i686-apple-darwin10 --prefix=${deps_dir}/gmp/osx64 --disable-shared --disable-assembly && \
  175. sudo make install && \
  176. cd .. && \
  177. rm -rf ${GMP_VER}-osx64
  178. if [ $? -ne 0 ]; then
  179. echo "! failed to build osx64 gmp lib."
  180. exit 1
  181. fi
  182. echo
  183. echo "> Successfully resolved all dependencies for hashcat."