From 4c22d50f0c523d35d013cd2a2633139f93e65648 Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Sat, 12 Jul 2014 14:54:33 +0200 Subject: [PATCH] few less forks in the script again, we can use arrays and a bit advanced awk syntax to reduce the number of forks necessary to run the script --- cipherscan | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cipherscan b/cipherscan index ddf4667..9bae63d 100755 --- a/cipherscan +++ b/cipherscan @@ -192,7 +192,7 @@ test_cipher_on_target() { /-----BEGIN CERTIFICATE-----/ { output=1 } output==1 { if (n==i) print } /-----END CERTIFICATE-----/ { output=0; n++ }' <<<"$tmp") - # put the output to an array instead awk '{print $1}' + # put the output to an array instead running awk '{print $1}' local cksum=($(cksum <<<"$cert")) # compare the values not just checksums so that eventual collision # doesn't mess up results @@ -348,7 +348,7 @@ get_cipher_pref() { if [ $success -eq 0 ]; then cipherspref=("${cipherspref[@]}" "$result") ciphercertificates=("${ciphercertificates[@]}" "$certificates") - pciph=$(echo $result|awk '{print $1}') + pciph=($(echo $result)) get_cipher_pref "!$pciph:$ciphersuite" return 0 fi @@ -365,7 +365,7 @@ display_results_in_terminal() { local different=False echo "Target: $TARGET"; echo for cipher in "${cipherspref[@]}"; do - pciph=$(echo $cipher|awk '{print $1}') + pciph=($(echo $cipher)) if [ $DOBENCHMARK -eq 1 ]; then bench_cipher "$pciph" r="$ctr $cipher $cipherbenchms" @@ -419,7 +419,7 @@ display_results_in_terminal() { echo $result|grep -v '(NONE)' else # prints priority, ciphersuite, protocols and pfs_keysize - echo $result|grep -v '(NONE)'|awk '{print $1 " " $2 " " $3 " " $9}' + awk '!/(NONE)/{print $1 " " $2 " " $3 " " $9}' <<<"$result" fi done|column -t echo