Skip to content

Instantly share code, notes, and snippets.

@anzz1
Last active September 3, 2025 18:14
Show Gist options
  • Select an option

  • Save anzz1/149a9f1a615f91b46c3af5ecedafa830 to your computer and use it in GitHub Desktop.

Select an option

Save anzz1/149a9f1a615f91b46c3af5ecedafa830 to your computer and use it in GitHub Desktop.
test_ciphers.sh
#!/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
#!/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
#!/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