diff --git a/testssl.sh b/testssl.sh index e36ef80..bc6d9e7 100755 --- a/testssl.sh +++ b/testssl.sh @@ -337,6 +337,8 @@ if [[ "$COLOR" -eq 2 ]]; then green=$(tput setaf 2) brown=$(tput setaf 3) blue=$(tput setaf 4) + magenta=$(tput setaf 5) + cyan=$(tput setaf 6) grey=$(tput setaf 7) yellow=$(tput setaf 3; tput bold) off=$(tput sgr0) @@ -2436,7 +2438,7 @@ renego() { case "$OSSL_VER" in 0.9.8*) # we need this for Mac OSX unfortunately case "$OSSL_VER_APPENDIX" in - [a-l]) pr_magenta "Your $OPENSSL $OSSL_VER cannot test the secure renegotiation vulnerability" + [a-l]) pr_magentaln "Local Problem: $OPENSSL cannot test this secure renegotiation vulnerability" return 3 ;; [m-z]) ;; # all ok esac ;; @@ -2633,31 +2635,40 @@ tls_poodle() { return 7 } +count_ciphers() { + echo "$1" | sed 's/:/\n/g' | wc -l | sed 's/ //g' +} + +actually_supported_ciphers() { + $OPENSSL ciphers "$1" +} + + # Factoring RSA Export Keys: don't use EXPORT RSA ciphers, see https://freakattack.com/ freak() { local ret - local exportrsa_ciphers + local -i no_supported_ciphers=0 + # with correct build it should list these 7 ciphers (plus the two latter as SSLv2 ciphers): + local exportrsa_cipher_list="EXP1024-DES-CBC-SHA:EXP1024-RC4-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-DH-RSA-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC2-CBC-MD5:EXP-RC4-MD5:EXP-RC4-MD5" local addtl_warning="" [ $VULN_COUNT -le $VULN_THRESHLD ] && outln && pr_blue "--> Testing for FREAK attack" && outln "\n" pr_bold " FREAK"; out " (CVE-2015-0204), experimental " - no_exportrsa_ciphers=$($OPENSSL ciphers -v 'ALL:eNULL' | egrep -a "^EXP.*RSA" | wc -l | sed 's/ //g') - exportrsa_ciphers=$($OPENSSL ciphers -v 'ALL:eNULL' | awk '/^EXP.*RSA/ {print $1}' | tr '\n' ':') - debugme echo $exportrsa_ciphers - # with correct build it should list these 7 ciphers (plus the two latter as SSLv2 ciphers): - # EXP1024-DES-CBC-SHA:EXP1024-RC4-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-DH-RSA-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5 - case $no_exportrsa_ciphers in + + no_supported_ciphers=$(count_ciphers $(actually_supported_ciphers $exportrsa_cipher_list)) + + case $no_supported_ciphers in 0) pr_magentaln "Local problem: your $OPENSSL doesn't have any EXPORT RSA ciphers configured" return 3 ;; 1|2|3) - addtl_warning=" (tested only with $no_exportrsa_ciphers out of 9 ciphers)" ;; + addtl_warning=" ($magenta""tested only with $no_supported_ciphers out of 9 ciphers only!$off)" ;; 8|9|10|11) addtl_warning="" ;; 4|5|6|7) - addtl_warning=" (tested with $no_exportrsa_ciphers/9 ciphers)" ;; + addtl_warning=" (tested with $no_supported_ciphers/9 ciphers)" ;; esac - $OPENSSL s_client $STARTTLS -cipher $exportrsa_ciphers -connect $NODEIP:$PORT $SNI &>$TMPFILE $TMPFILE Testing for LOGJAM vulnerability" && outln "\n" pr_bold " LOGJAM"; out " (CVE-2015-4000), experimental " - no_exportdhe_ciphers=$($OPENSSL ciphers "$exportdhe_ciphers" | sed 's/:/ /g' | wc -w | sed 's/ //g') - case $no_exportdhe_ciphers in + + no_supported_ciphers=$(count_ciphers $(actually_supported_ciphers $exportdhe_cipher_list)) + + case $no_supported_ciphers in 0) pr_magentaln "Local problem: your $OPENSSL doesn't have any DHE EXPORT ciphers configured" return 3 ;; - 1|2|3) addtl_warning=" (tested only w/ $no_exportdhe_ciphers/4 ciphers)" ;; + 1|2) addtl_warning=" ($magenta""tested w/ $no_supported_ciphers/4 ciphers only!$off)" ;; + 3) addtl_warning=" (tested w/ $no_supported_ciphers/4 ciphers)" ;; 4) ;; esac - $OPENSSL s_client $STARTTLS -cipher $exportdhe_ciphers -connect $NODEIP:$PORT $SNI &>$TMPFILE $TMPFILE $TMPFILE # -V doesn't work with openssl < 1.0 [ $LONG -eq 0 ] && [ $SHOW_LOC_CIPH -eq 0 ] && echo "local ciphers available for testing RC4:" && echo $(cat $TMPFILE) - $OPENSSL s_client -cipher $($OPENSSL ciphers RC4) $STARTTLS -connect $NODEIP:$PORT $SNI &>/dev/null /dev/null /dev/null + while read hexcode dash rc4_cipher sslvers kx auth enc mac; do + $OPENSSL s_client -cipher $rc4_cipher $STARTTLS -connect $NODEIP:$PORT $SNI /dev/null ret=$? # here we have a fp with openssl < 1.0 if [[ $ret -ne 0 ]] && [[ "$SHOW_EACH_C" -eq 0 ]] ; then continue # no successful connect AND not verbose displaying each cipher fi if [ $LONG -eq 0 ]; then normalize_ciphercode $hexcode - neat_list $HEXC $ciph $kx $enc + neat_list $HEXC $rc4_cipher $kx $enc if [[ "$SHOW_EACH_C" -ne 0 ]]; then if [[ $ret -eq 0 ]]; then pr_litered "available" @@ -2863,7 +2884,7 @@ rc4() { fi outln else - pr_litered "$ciph " + pr_litered "$rc4_cipher " fi done < $TMPFILE # ^^^^^ posix redirect as shopt will either segfault or doesn't work with old bash versions @@ -3717,6 +3738,6 @@ fi exit $ret -# $Id: testssl.sh,v 1.262 2015/05/27 15:04:34 dirkw Exp $ +# $Id: testssl.sh,v 1.263 2015/05/27 21:31:24 dirkw Exp $ # vim:ts=5:sw=5 # ^^^ FYI: use vim and you will see everything beautifully indented with a 5 char tab