hashcat Forum
csv output for benchmarking - Printable Version

+- hashcat Forum (https://hashcat.net/forum)
+-- Forum: Misc (https://hashcat.net/forum/forum-15.html)
+--- Forum: User Contributions (https://hashcat.net/forum/forum-25.html)
+--- Thread: csv output for benchmarking (/thread-6314.html)



csv output for benchmarking - devilsadvocate - 02-19-2017

In viewing the various Google sheets that exist that contain hashcat benchmarks, I decided to script something to get csv output after running a benchmark.  Manually copying values from "./hashcat64.bin --benchmark" takes too long.

I hope you guys find this useful.


#!/bin/bash

#set -x

function usage
{
echo ' '
echo 'Usage: print_columnar_benchmark_values.sh hashcat_benchmark_logfile_from_tee.log'
echo ' '
echo 'Obtain the hashcat benchmark output by executing:'
echo '/path/to/hashcat/hashcat64.bin --benchmark | tee hashcat_benchmark_logfile_from_tee.log'
echo ' '
echo 'Optional: output this to a csv file by executing:'
echo 'print_columnar_benchmark_values.sh hashcat_benchmark_logfile_from_tee.log | tee benchmark_output.csv'
echo ' '
echo 'This script was made for hashcat-3.30 under Linux and may need to be updated in the future.'
echo ' '
exit 1
}

if [[ $# -eq 0 ]];then
        echo 'Error: no benchmark output specified'
        usage
fi

if [[ ! -f $1 ]]; then
        echo 'Input file not found'
        usage
fi

cat $1 | sed '/^$/d' | paste -s -d",\n" | grep 'Hashtype:' | grep -v 'hashcat' | grep -v 'Stopped' | grep -v 'Started' | grep -v 'OpenCL' | grep -v '===' | while read hashtype_line
do
        hashtype=$(echo $hashtype_line | cut -d ':' -f 2 | cut -d ',' -f 1 | xargs)
        unparsed_speed=$(echo $hashtype_line | cut -d ':' -f 3 | cut -d '(' -f 1 | cut -f 1 | xargs)
        # split unparsed_speed into two parts
        speed_number=$(echo $unparsed_speed | cut -d ' ' -f 1)
        speed_multiplier=$(echo $unparsed_speed | cut -d ' ' -f 2)
        hashes_per_second_detect=$(echo $speed_multiplier | grep -i 'h/s' | grep -v -i 'k' | grep -v -i 'm')
        kilohashes_per_second_detect=$(echo $speed_multiplier | grep -i 'kh/s')
        millionhashes_per_second_detect=$(echo $speed_multiplier | grep -i 'mh/s')
        # multiply base number by detected multiplier
        if [[ $hashes_per_second_detect != "" ]]; then
                echo "$hashtype,$speed_number"
        fi
        if [[ $kilohashes_per_second_detect != "" ]];then
                speed_number_k=$(perl -e "print $speed_number * 1000")
                echo "$hashtype,$speed_number_k"
        fi
        if [[ $millionhashes_per_second_detect != "" ]];then
                speed_number_m=$(perl -e "print $speed_number * 1000000")
                echo "$hashtype,$speed_number_m"
        fi
done

Code:
#!/bin/bash

#set -x

function usage
{
echo ' '
echo 'Usage: print_columnar_benchmark_values.sh hashcat_benchmark_logfile_from_tee.log'
echo ' '
echo 'Obtain the hashcat benchmark output by executing:'
echo '/path/to/hashcat/hashcat64.bin --benchmark | tee hashcat_benchmark_logfile_from_tee.log'
echo ' '
echo 'Optional: output this to a csv file by executing:'
echo 'print_columnar_benchmark_values.sh hashcat_benchmark_logfile_from_tee.log | tee benchmark_output.csv'
echo ' '
echo 'This script was made for hashcat-3.30 under Linux and may need to be updated in the future.'
echo ' '
exit 1
}

if [[ $# -eq 0 ]];then
       echo 'Error: no benchmark output specified'
       usage
fi

if [[ ! -f $1 ]]; then
       echo 'Input file not found'
       usage
fi

cat $1 | sed '/^$/d' | paste -s -d",\n" | grep 'Hashtype:' | grep -v 'hashcat' | grep -v 'Stopped' | grep -v 'Started' | grep -v 'OpenCL' | grep -v '===' | while read hashtype_line
do
       hashtype=$(echo $hashtype_line | cut -d ':' -f 2 | cut -d ',' -f 1 | xargs)
       unparsed_speed=$(echo $hashtype_line | cut -d ':' -f 3 | cut -d '(' -f 1 | cut -f 1 | xargs)
       # split unparsed_speed into two parts
       speed_number=$(echo $unparsed_speed | cut -d ' ' -f 1)
       speed_multiplier=$(echo $unparsed_speed | cut -d ' ' -f 2)
       hashes_per_second_detect=$(echo $speed_multiplier | grep -i 'h/s' | grep -v -i 'k' | grep -v -i 'm')
       kilohashes_per_second_detect=$(echo $speed_multiplier | grep -i 'kh/s')
       millionhashes_per_second_detect=$(echo $speed_multiplier | grep -i 'mh/s')
       # multiply base number by detected multiplier
       if [[ $hashes_per_second_detect != "" ]]; then
               echo "$hashtype,$speed_number"
       fi
       if [[ $kilohashes_per_second_detect != "" ]];then
               speed_number_k=$(perl -e "print $speed_number * 1000")
               echo "$hashtype,$speed_number_k"
       fi
       if [[ $millionhashes_per_second_detect != "" ]];then
               speed_number_m=$(perl -e "print $speed_number * 1000000")
               echo "$hashtype,$speed_number_m"
       fi
done



RE: csv output for benchmarking - royce - 02-19-2017

There is also:

hashcat -b --machine-readable