Quantcast
Channel: hashcat Forum - All Forums
Viewing all articles
Browse latest Browse all 7673

csv output for benchmarking

$
0
0
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

if [[ $# -eq 0 ]];then
echo ' '
echo 'Error: no benchmark output specified'
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
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

if [[ $# -eq 0 ]];then
echo ' '
echo 'Error: no benchmark output specified'
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
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

Viewing all articles
Browse latest Browse all 7673

Trending Articles