Skip to content

Instantly share code, notes, and snippets.

@nfisher
Created April 23, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfisher/6831070187e943aed6e41095e7a457aa to your computer and use it in GitHub Desktop.
Save nfisher/6831070187e943aed6e41095e7a457aa to your computer and use it in GitHub Desktop.
Probe for valid ciphers (modified from an SO response)
#!/usr/bin/env bash
# OpenSSL requires the port number.
SERVER=$1
PORT=$2
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
for cipher in ${ciphers[@]}
do
echo Testing $cipher
result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER:$PORT 2>&1)
if [[ "$result" =~ ":error:" ]] ; then
error=$(echo -n $result | cut -d':' -f6)
printf "%-50s \e[31mNO (%s)\e[0m\n" "$cipher ..." "$error"
#echo -e
else
if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher :" ]] ; then
printf "%-50s \e[32mYES\e[0m\n" "$cipher ..."
#echo -e "\e[32mYES\e[0m"
else
echo UNKNOWN RESPONSE
echo $result
fi
fi
sleep $DELAY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment