From d8d8318f6d108ae950332d771518e1f8d8e4fa91 Mon Sep 17 00:00:00 2001 From: Dirk Date: Mon, 9 Mar 2015 08:07:45 +0100 Subject: [PATCH] FIX for #71 (proper workaround for lastpipe in rc4, pfs, and cbc) --- testssl.sh | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/testssl.sh b/testssl.sh index 9cc1f74..356d3da 100755 --- a/testssl.sh +++ b/testssl.sh @@ -1235,6 +1235,11 @@ server_defaults() { # http://www.heise.de/security/artikel/Forward-Secrecy-testen-und-einrichten-1932806.html pfs() { + local ret + local none + local number_pfs + local hexcode n ciph sslvers kx auth enc mac + outln pr_blue "--> Testing (Perfect) Forward Secrecy (P)FS)"; outln " -- omitting 3DES, RC4 and Null Encryption here" # https://community.qualys.com/blogs/securitylabs/2013/08/05/configuring-apache-nginx-and-openssl-for-forward-secrecy @@ -1268,42 +1273,45 @@ pfs() { outln "(it depends on the browser/client whether one of them will be used)\n" none=0 neat_header - $OPENSSL ciphers -V "$PFSOK" | while read hexcode n ciph sslvers kx auth enc mac; do + while read hexcode n ciph sslvers kx auth enc mac; do $OPENSSL s_client -cipher $ciph $STARTTLS -connect $NODEIP:$PORT $SNI &>/dev/null Checking RC4 Ciphers" ; outln $OPENSSL ciphers -V 'RC4:@STRENGTH' >$TMPFILE @@ -1314,7 +1322,7 @@ rc4() { outln "(for legacy support e.g. IE6 rather consider x13 or x0a)\n" bad=1 neat_header - cat $TMPFILE | while read hexcode n ciph sslvers kx auth enc mac; do + while read hexcode n ciph sslvers kx auth enc mac; do $OPENSSL s_client -cipher $ciph $STARTTLS -connect $NODEIP:$PORT $SNI /dev/null ret=$? if [ $ret -ne 0 ] && [ "$SHOW_EACH_C" -eq 0 ] ; then @@ -1333,9 +1341,8 @@ rc4() { out fi outln - done - # https://en.wikipedia.org/wiki/Transport_Layer_Security#RC4_attacks - # http://blog.cryptographyengineering.com/2013/03/attack-of-week-rc4-is-kind-of-broken-in.html + done < $TMPFILE + # ^^^^^ posix redirect as shopt will either segfault or doesn't work with old bash versions outln else outln @@ -1343,9 +1350,6 @@ rc4() { bad=0 fi -# shopt -u lastpipe # othwise for some reason it segfaults -# FIXME: still segfaults: see https://www.mail-archive.com/bug-bash@gnu.org/msg14428.html | -# maybe use @PIPESTATUS as a workaround tmpfile_handle $FUNCNAME.txt return $bad } @@ -2242,7 +2246,6 @@ freak() { #in a nutshell: don't use CBC Ciphers in SSLv3 TLSv1.0 # Browser Exploit Against SSL/TLS beast(){ - shopt -s lastpipe # otherwise it's more tricky to access variables in a while loop local hexcode dash cbc_cipher sslvers kx auth enc mac export local detected_proto local detected_cbc_cipher="" @@ -2258,14 +2261,16 @@ beast(){ if [ $? -ne 0 ]; then continue # protocol no supported, so we do not need to check each cipher with that protocol fi - $OPENSSL ciphers -V 'ALL:eNULL' | grep CBC | while read hexcode dash cbc_cipher sslvers kx auth enc mac export ; do + while read hexcode dash cbc_cipher sslvers kx auth enc mac export ; do $OPENSSL s_client -cipher "$cbc_cipher" -"$proto" $STARTTLS -connect $NODEIP:$PORT $SNI >$TMPFILE 2>/dev/null