Skip to content

Instantly share code, notes, and snippets.

@flawedmatrix
Created April 12, 2017 19:43
Show Gist options
  • Save flawedmatrix/1077f5b3a9c7c7eeb0517a8d9b161717 to your computer and use it in GitHub Desktop.
Save flawedmatrix/1077f5b3a9c7c7eeb0517a8d9b161717 to your computer and use it in GitHub Desktop.
Script to test openssl ciphers on a target server
#!/bin/bash
: "${2?'Usage: test-ciphers <host:port> <cipher-file>'}"
SERVER=${1}
IFS=$'\r\n' GLOBIGNORE='*' command eval 'CIPHERS=($(<${2}))'
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 0.1
done
@flawedmatrix
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment