Created
March 14, 2017 10:38
-
-
Save agustik/dd4a5b5bc77546a9b893d3c255af4eaf to your computer and use it in GitHub Desktop.
Get all supported ciphers for tls/ssl connection
This file contains hidden or 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/bash | |
| # OpenSSL requires the port number. | |
| HOST=$1 | |
| PORT=$2 | |
| if [ -z "$PORT" ]; then | |
| PORT="443" | |
| fi | |
| SERVER="${HOST}:${PORT}" | |
| DELAY=1 | |
| ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') | |
| version=$(openssl version); | |
| echo "Obtaining cipher list from ${version} on server: $SERVER". | |
| function sizeOf(){ | |
| local _i=0; | |
| for cipher in ${ciphers[@]}; do | |
| _i=$(($_i + 1)); | |
| done | |
| echo $_i | |
| } | |
| totalCiphers=$(sizeOf $ciphers) | |
| i=0; | |
| for cipher in ${ciphers[@]}; do | |
| echo -n "Testing $cipher $i/$totalCiphers - " | |
| result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1) | |
| if [[ "$result" =~ ":error:" ]] ; then | |
| error=$(echo -n $result | cut -d':' -f6) | |
| echo NO \($error\) | |
| else | |
| if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher :" ]] ; then | |
| echo YES | |
| else | |
| echo UNKNOWN RESPONSE | |
| echo $result | |
| fi | |
| fi | |
| i=$(($i + 1)); | |
| sleep $DELAY | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment