Created
April 23, 2020 14:58
-
-
Save nfisher/6831070187e943aed6e41095e7a457aa to your computer and use it in GitHub Desktop.
Probe for valid ciphers (modified from an SO response)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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