Last active
September 3, 2025 18:14
-
-
Save anzz1/149a9f1a615f91b46c3af5ecedafa830 to your computer and use it in GitHub Desktop.
test_ciphers.sh
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/env bash | |
| # OpenSSL requires the port number. | |
| SERVER=$1 | |
| DELAY=1 | |
| if [ -z "$SERVER" ]; then | |
| echo Usage: $0 IP:PORT | |
| exit 1 | |
| fi | |
| echo Obtaining cipher list from $(openssl version). | |
| # TLS 1.2 and below ciphers | |
| ciphers_tls12=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') | |
| # TLS 1.3 ciphers (only available in OpenSSL >= 1.1.1) | |
| ciphers_tls13=$(openssl ciphers -s -tls1_3 2>/dev/null | sed -e 's/:/ /g') | |
| echo "Testing TLS 1.2 and below ciphers..." | |
| for cipher in ${ciphers_tls12[@]} | |
| do | |
| echo -n Testing $cipher... | |
| result=$(echo -n | openssl s_client -tls1_2 -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 | |
| sleep $DELAY | |
| done | |
| echo "Testing TLS 1.3 ciphers..." | |
| for cipher in ${ciphers_tls13[@]} | |
| do | |
| echo -n Testing $cipher... | |
| result=$(echo -n | openssl s_client -tls1_3 -ciphersuites "$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 | |
| sleep $DELAY | |
| done |
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/env bash | |
| # OpenSSL requires the port number. | |
| SERVER=$1 | |
| DELAY=1 | |
| if [ -z "$SERVER" ]; then | |
| echo Usage: $0 IP:PORT | |
| exit 1 | |
| fi | |
| ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') | |
| echo Obtaining cipher list from $(openssl version). | |
| for cipher in ${ciphers[@]} | |
| do | |
| echo -n Testing $cipher... | |
| 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 | |
| sleep $DELAY | |
| done |
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/env bash | |
| # OpenSSL requires the port number. | |
| SERVER=$1 | |
| DELAY=1 | |
| if [ -z "$SERVER" ]; then | |
| echo Usage: $0 IP:PORT | |
| exit 1 | |
| fi | |
| for n in 0 1 2 3; | |
| do | |
| if [ $n == "0" ]; then | |
| tls1="tls1" | |
| else | |
| tls1="tls1_${n}" | |
| fi | |
| tls2="TLSv1.${n}" | |
| echo -n Testing ${tls2}... | |
| result=$(echo -n | openssl s_client -${tls1} -connect $SERVER 2>&1) | |
| if [[ "$result" =~ ":error:" ]] ; then | |
| error=$(echo -n $result | cut -d':' -f6) | |
| echo NO \($error\) | |
| else | |
| if [[ "$result" =~ "New, ${tls2}" || "$result" =~ "Cipher :" ]] ; then | |
| echo YES | |
| 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