Drop -m 190, no reason to keep it
[hashcat.git] / tools / test.sh
index 1651604..d00e8ca 100755 (executable)
@@ -1,15 +1,21 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 ##
-## Authors.....: Gabriele Gristina <matrix@hashcat.net> / Jens Steube <jens.steube@gmail.com>
+## Authors.....: Gabriele Gristina <matrix@hashcat.net>
+##               Jens Steube <jens.steube@gmail.com>
+##               magnum <john.magnum@hushmail.com>
+##
 ## License.....: MIT
 ##
 
 # missing hash types: 5200,6211,6221,6231,6241,6251,6261,6271,6281
 
-HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 130 131 132 140 141 150 160 190 200 300 400 500 900 1000 1100 1400 1410 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 4300 4400 4500 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6300 6400 6500 6600 6700 6800 6900 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12100 12200 12300 12400 12600 12800 12900 13000"
+HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 125 130 131 132 133 140 141 150 160 200 300 400 500 900 1000 1100 1400 1410 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 4300 4400 4500 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6300 6400 6500 6600 6700 6800 6900 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12100 12200 12300 12400 12600 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800"
+
+#ATTACK_MODES="0 1 3 6 7"
+ATTACK_MODES="0 1 3 7"
 
-ATTACK_MODES="0 1 3 6 7"
+VECTOR_WIDTHS="1 2 4 8 16"
 
 MATCH_PASS_ONLY="2500 5300 5400 6600 6800 8200"
 
@@ -17,9 +23,9 @@ HASHFILE_ONLY="2500"
 
 NEVER_CRACK="11600"
 
-SLOW_ALGOS="400 500 501 1600 1800 2100 2500 3200 5200 5800 6211 6221 6231 6241 6251 6261 6271 6281 6300 6400 6500 6600 6700 6800 7100 7200 7400 7900 8200 8800 8900 9000 9100 9200 9300 9400 9500 9600 10000 10300 10500 10700 10900 11300 11600 11900 12000 12100 12200 12300 12400 12500 12800 12900 13000"
+SLOW_ALGOS="400 500 501 1600 1800 2100 2500 3200 5200 5800 6211 6221 6231 6241 6251 6261 6271 6281 6300 6400 6500 6600 6700 6800 7100 7200 7400 7900 8200 8800 8900 9000 9100 9200 9300 9400 9500 9600 10000 10300 10500 10700 10900 11300 11600 11900 12000 12100 12200 12300 12400 12500 12800 12900 13000 13200 13400 13600"
 
-OPTS="--quiet --force --potfile-disable --runtime 200 --gpu-temp-disable --weak-hash-threshold=0 --opencl-device-types 1,2"
+OPTS="--quiet --force --potfile-disable --runtime 200 --gpu-temp-disable --weak-hash-threshold=0"
 
 OUTD="test_$(date +%s)"
 
@@ -294,7 +300,7 @@ function status()
 
         ;;
       *)
-        echo "! unhandled return code ${RET}, cmdline : ${CMD}" $>> ${OUTD}/logfull.txt
+        echo "! unhandled return code ${RET}, cmdline : ${CMD}" &>> ${OUTD}/logfull.txt
         echo "! unhandled return code, see ${OUTD}/logfull.txt for details."
         ((e_nf++))
         ;;
@@ -320,7 +326,7 @@ function attack_0()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, single hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, single hash, device-type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     max=32
 
@@ -403,7 +409,7 @@ function attack_0()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 
@@ -415,7 +421,7 @@ function attack_0()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, multi hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, multi hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     hash_file=${OUTD}/${hash_type}_hashes.txt
 
@@ -488,7 +494,7 @@ function attack_0()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode multi  ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode multi,  Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 }
@@ -511,7 +517,7 @@ function attack_1()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, single hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, single hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
     i=1
     while read -u 9 hash; do
 
@@ -578,7 +584,7 @@ function attack_1()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode single ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode single, Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 
@@ -631,7 +637,7 @@ function attack_1()
 
     CMD="./${BIN} ${OPTS} -a 1 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1 ${OUTD}/${hash_type}_dict2"
 
-    echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, multi hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, multi hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     output=$(./${BIN} ${OPTS} -a 1 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1 ${OUTD}/${hash_type}_dict2 2>&1)
 
@@ -686,7 +692,7 @@ function attack_1()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode multi  ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode multi,  Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 }
@@ -709,7 +715,7 @@ function attack_3()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, single hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, single hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     max=8
     mask_offset=0
@@ -821,7 +827,7 @@ function attack_3()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 
@@ -963,7 +969,7 @@ function attack_3()
 
     CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} --increment --increment-min ${increment_min} --increment-max ${increment_max} ${custom_charsets} ${hash_file} ${mask} "
 
-    echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, multi hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, multi hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     output=$(./${BIN} ${OPTS} -a 3 -m ${hash_type} --increment --increment-min ${increment_min} --increment-max ${increment_max} ${custom_charsets} ${hash_file} ${mask} 2>&1)
 
@@ -1015,7 +1021,7 @@ function attack_3()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode multi  ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode multi,  Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 }
@@ -1038,7 +1044,7 @@ function attack_6()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 6, markov ${MARKOV}, single hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 6, markov ${MARKOV}, single hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     i=1
 
@@ -1127,7 +1133,7 @@ function attack_6()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode single ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode single, Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 
@@ -1241,7 +1247,7 @@ function attack_6()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode multi  ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode multi,  Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 }
@@ -1264,7 +1270,7 @@ function attack_7()
     e_nm=0
     cnt=0
 
-    echo "> Testing hash type $hash_type with attack mode 7, markov ${MARKOV}, single hash." &>> ${OUTD}/logfull.txt
+    echo "> Testing hash type $hash_type with attack mode 7, markov ${MARKOV}, single hash, Device-Type ${TYPE}, vector-width ${VECTOR}." &>> ${OUTD}/logfull.txt
 
     max=8
 
@@ -1369,7 +1375,7 @@ function attack_7()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode single ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode single, Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 
@@ -1512,7 +1518,7 @@ function attack_7()
 
     fi
 
-    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode multi  ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
+    echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode multi,  Device-Type ${TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout"
 
   fi
 }
@@ -1524,6 +1530,18 @@ cat << EOF
 
 OPTIONS:
 
+  -V    OpenCL vector-width (either 1, 2, 4 or 8), overrides value from device query :
+        '1'      => vector-width 1
+        '2'      => vector-width 2 (default)
+        '4'      => vector-width 4
+        '8'      => vector-width 8
+        'all'    => test sequentially vector-width ${VECTOR_WIDTHS}
+
+  -T    OpenCL device-types to use :
+        'gpu'    => gpu devices (default)
+        'cpu'    => cpu devices
+        'all'    => gpu and cpu devices
+
   -t    Select test mode :
         'single' => single hash (default)
         'multi'  => multi hash
@@ -1544,6 +1562,7 @@ OPTIONS:
   -o    Select operating system :
         'win'    => windows operating system (use .exe file extension etc)
         'linux'  => *nix based operating systems (.bin for binaries)
+        'osx'    => mac osx operating systems (.app for binaries)
 
   -c    Disables markov-chains
 
@@ -1559,16 +1578,51 @@ EOF
   exit 1
 }
 
-BIN="oclHashcat"
+BIN="hashcat"
 MARKOV="enabled"
 ATTACK=0
 MODE=0
+TYPE="null"
+VECTOR="default"
 HT=0
 PACKAGE=0
 
-while getopts "t:m:a:b:hcpd:x:o:" opt; do
+while getopts "V:T:t:m:a:b:hcpd:x:o:" opt; do
 
   case ${opt} in
+    "V")
+      if [ ${OPTARG} == "1" ]; then
+        VECTOR=1
+      elif [ ${OPTARG} == "2" ]; then
+        VECTOR=2
+      elif [ ${OPTARG} == "4" ]; then
+        VECTOR=4
+      elif [ ${OPTARG} == "8" ]; then
+        VECTOR=8
+      elif [ ${OPTARG} == "16" ]; then
+        VECTOR=16
+      elif [ ${OPTARG} == "all" ]; then
+        VECTOR="all"
+      else
+        usage
+      fi
+      ;;
+
+    "T")
+      if [ ${OPTARG} == "gpu" ]; then
+        OPTS="${OPTS} --opencl-device-types 2"
+        TYPE="Gpu"
+      elif [ ${OPTARG} == "cpu" ]; then
+        OPTS="${OPTS} --opencl-device-types 1"
+        TYPE="Cpu"
+      elif [ ${OPTARG} == "all" ]; then
+        OPTS="${OPTS} --opencl-device-types 1,2"
+        TYPE="Cpu + Gpu"
+      else
+        usage
+      fi
+      ;;
+
     "t")
       if [ ${OPTARG} == "single" ]; then
         MODE=0
@@ -1635,6 +1689,8 @@ while getopts "t:m:a:b:hcpd:x:o:" opt; do
         EXTENSION="exe"
       elif [ ${OPTARG} == "linux" ]; then
         EXTENSION="bin"
+      elif [ ${OPTARG} == "osx" ]; then
+        EXTENSION="app"
       else
         usage
       fi
@@ -1651,15 +1707,20 @@ while getopts "t:m:a:b:hcpd:x:o:" opt; do
 
 done
 
+if [ "${TYPE}" == "null" ]; then
+   TYPE="Gpu"
+   OPTS="${OPTS} --opencl-device-types 2"
+fi
+
 if [ -n "${ARCHITECTURE}" ]; then
 
-  BIN=$( echo ${BIN} | sed "s!64!${ARCHITECTURE}!" )
+  BIN="${BIN}${ARCHITECTURE}"
 
 fi
 
 if [ -n "${EXTENSION}" ]; then
 
-  BIN=$( echo ${BIN} | sed "s!\.bin!\.${EXTENSION}!" )
+  BIN="${BIN}.${EXTENSION}"
 
 fi
 
@@ -1760,34 +1821,55 @@ if [ "${PACKAGE}" -eq 0 -o -z "${PACKAGE_FOLDER}" ]; then
          IS_SLOW=0
       fi
 
-      if [[ ${IS_SLOW} -eq 1 ]]; then
+      OPTS_OLD=${OPTS}
+      VECTOR_OLD=${VECTOR}
+      for CUR_WIDTH in $(echo $VECTOR_WIDTHS); do
 
-        # run attack mode 0 (stdin)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 0 ]]; then attack_0; fi
+        if [ "${VECTOR_OLD}" == "all" ] || [ "${VECTOR_OLD}" == "default" ] || [ "${VECTOR_OLD}" == "${CUR_WIDTH}" ]; then
 
-      else
-        # run attack mode 0 (stdin)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 0 ]]; then attack_0; fi
+          if [ "${VECTOR_OLD}" == "default" ] && \
+             [ "${CUR_WIDTH}" != "1" ] && \
+             [ "${CUR_WIDTH}" != "4" ]; then
 
-        # run attack mode 1 (combinator)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 1 ]]; then attack_1; fi
+             continue
+          fi
 
-        # run attack mode 3 (bruteforce)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 3 ]]; then attack_3; fi
+          VECTOR=${CUR_WIDTH}
+          OPTS="${OPTS_OLD} --opencl-vector-width ${VECTOR}"
 
-        # run attack mode 6 (dict+mask)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 6 ]]; then attack_6; fi
+          if [[ ${IS_SLOW} -eq 1 ]]; then
 
-        # run attack mode 7 (mask+dict)
-        if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 7 ]]; then attack_7; fi
-      fi
-    fi
+            # run attack mode 0 (stdin)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 0 ]]; then attack_0; fi
+
+          else
+
+            # run attack mode 0 (stdin)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 0 ]]; then attack_0; fi
 
+            # run attack mode 1 (combinator)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 1 ]]; then attack_1; fi
+
+            # run attack mode 3 (bruteforce)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 3 ]]; then attack_3; fi
+
+            # run attack mode 6 (dict+mask)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 6 ]]; then attack_6; fi
+
+            # run attack mode 7 (mask+dict)
+            if [[ ${ATTACK} -eq 65535 ]] || [[ ${ATTACK} -eq 7 ]]; then attack_7; fi
+
+          fi
+        fi
+      done
+      OPTS="${OPTS_OLD}"
+      VECTOR="${VECTOR_OLD}"
+    fi
   done
 
 else
 
-    OUTD=${PACKAGE_FOLDER}
+  OUTD=${PACKAGE_FOLDER}
 
 fi