Created
April 12, 2017 19:43
-
-
Save flawedmatrix/1077f5b3a9c7c7eeb0517a8d9b161717 to your computer and use it in GitHub Desktop.
Script to test openssl ciphers on a target server
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from https://superuser.com/a/224263