diff --git a/testssl.sh b/testssl.sh index 9788cf2..40322fb 100755 --- a/testssl.sh +++ b/testssl.sh @@ -10300,8 +10300,8 @@ starttls_nntp_dialog() { starttls_postgres_dialog() { debugme echo "=== starting postgres STARTTLS dialog ===" - local init_tls=", x00, x00 ,x00 ,x08 ,x04 ,xD2 ,x16 ,x2F" - socksend "${init_tls}" 0 && debugme echo "initiated STARTTLS" && + local init_tls=", 00, 00 ,00 ,08 ,04 ,D2 ,16 ,2F" + socksend_clienthello "${init_tls}" 0 && debugme echo "initiated STARTTLS" && starttls_io "" S 1 && debugme echo "received ack (="S") for STARTTLS" local ret=$? debugme echo "=== finished postgres STARTTLS dialog with ${ret} ===" @@ -10311,14 +10311,14 @@ starttls_postgres_dialog() { starttls_mysql_dialog() { debugme echo "=== starting mysql STARTTLS dialog ===" local login_request=" - , x20, x00, x00, x01, # payload_length, sequence_id - x85, xae, xff, x00, # capability flags, CLIENT_SSL always set - x00, x00, x00, x01, # max-packet size - x21, # character set - x00, x00, x00, x00, x00, x00, x00, x00, # string[23] reserved (all [0]) - x00, x00, x00, x00, x00, x00, x00, x00, - x00, x00, x00, x00, x00, x00, x00" - socksend "${login_request}" 0 + , 20, 00, 00, 01, # payload_length, sequence_id + 85, ae, ff, 00, # capability flags, CLIENT_SSL always set + 00, 00, 00, 01, # max-packet size + 21, # character set + 00, 00, 00, 00, 00, 00, 00, 00, # string[23] reserved (all [0]) + 00, 00, 00, 00, 00, 00, 00, 00, + 00, 00, 00, 00, 00, 00, 00" + socksend_clienthello "${login_request}" 0 starttls_just_read 1 && debugme echo "read succeeded" # 1 is the timeout value which only MySQL needs. Note, there seems no response whether STARTTLS # succeeded. We could try harder, see https://github.com/openssl/openssl/blob/master/apps/s_client.c @@ -10453,9 +10453,9 @@ send_close_notify() { debugme echo "sending close_notify..." if [[ $detected_tlsversion == 0300 ]]; then - socksend ",x15, x03, x00, x00, x02, x02, x00" 0 + socksend_clienthello ",15, 03, 00, 00, 02, 02, 00" 0 else - socksend ",x15, x03, x01, x00, x02, x02, x00" 0 + socksend_clienthello ",15, 03, 01, 00, 02, 02, 00" 0 fi } @@ -10467,13 +10467,13 @@ send_close_notify() { code2network() { local temp="" line="" - NW_STR=$(while read -r line; do + NW_STR="$(while read -r line; do [[ -z "$line" ]] && continue # blank line temp="${line%%\#*}" # remove comments temp="${temp//,/\\\x}" # comma to \x temp="${temp//[\t ]/}" # blank and tabs printf "%s" "$temp" - done <<< "$1") + done <<< "$1")" } # sockets inspired by http://blog.chris007.de/?p=238 @@ -10497,6 +10497,7 @@ socksend_clienthello() { # ARG1: hexbytes -- preceeded by x -- separated by commas, with a leading comma # ARG2: seconds to sleep +#FIXME: use socksend_clienthello instead. This will be removed soon!! socksend() { local data line @@ -14516,7 +14517,7 @@ resend_if_hello_retry_request() { if [[ "$server_version" == 0304 ]] || [[ 0x$server_version -ge 0x7f16 ]]; then # Send a dummy change cipher spec for middlebox compatibility. debugme echo -en "\nsending dummy change cipher spec... " - socksend ", x14, x03, x03 ,x00, x01, x01" 0 + socksend_clienthello ", 14, 03, 03 ,00, 01, 01" 0 fi debugme echo -en "\nsending second client hello... " second_clienthello="$(modify_clienthello "$original_clienthello" "$new_key_share" "$cookie")" @@ -14824,7 +14825,7 @@ receive_app_data() { read -r tls_version cipher server_key server_iv server_seq client_key client_iv client_seq <<< "$APP_TRAF_KEY_INFO" [[ "${tls_version:0:2}" == 7F ]] && [[ 0x${tls_version:2:2} -lt 25 ]] && include_headers=false - + sleep $USLEEP_REC while true; do len=${#ciphertext} @@ -14906,29 +14907,30 @@ run_heartbleed(){ fi if [[ 0 -eq $(has_server_protocol tls1) ]]; then - tls_hexcode="x03, x01" + tls_hexcode="03,01" elif [[ 0 -eq $(has_server_protocol tls1_1) ]]; then - tls_hexcode="x03, x02" + tls_hexcode="03,02" elif [[ 0 -eq $(has_server_protocol tls1_2) ]]; then - tls_hexcode="x03, x03" + tls_hexcode="03,03" elif [[ 0 -eq $(has_server_protocol ssl3) ]]; then - tls_hexcode="x03, x00" + tls_hexcode="03,00" else # no protocol for some reason defined, determine TLS versions offered with a new handshake $OPENSSL s_client $(s_client_options "$STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY") >$TMPFILE 2>$ERRFILE $TMPFILE 2>$ERRFILE /dev/null | \ hexdump -v -e '16/1 "%02x"')" if [[ -z "$encrypted_pms" ]]; then - if [[ "$DETECTED_TLS_VERSION" == "0300" ]]; then - socksend ",x15, x03, x00, x00, x02, x02, x00" 0 + if [[ "$DETECTED_TLS_VERSION" == 0300 ]]; then + socksend_clienthello ",15, 03, 00, 00, 02, 02, 00" 0 else - socksend ",x15, x03, x01, x00, x02, x02, x00" 0 + socksend_clienthello ",15, 03, 01, 00, 02, 02, 00" 0 fi close_socket prln_fixme "Conversion of public key failed around line $((LINENO - 9))"