2013-07-17 20:49:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2014-01-09 17:52:43 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
# Author: Julien Vehent [:ulfr] - 2013
|
|
|
|
|
2013-08-04 04:07:13 +02:00
|
|
|
DOBENCHMARK=0
|
2013-07-19 15:45:06 +02:00
|
|
|
BENCHMARKITER=30
|
2014-01-09 17:52:43 +01:00
|
|
|
OPENSSLBIN="$(dirname $0)/openssl"
|
2014-04-05 19:36:51 +02:00
|
|
|
CACERTS=${CACERTS:-/etc/pki/tls/certs/ca-bundle.crt}
|
|
|
|
if [ ! -e "$CACERTS" ]; then
|
|
|
|
echo "Warning: CA Certificates not found at $CACERTS, export CACERTS variable with location of your trust anchors" 1>&2
|
|
|
|
fi
|
2013-11-20 16:30:14 +01:00
|
|
|
CIPHERSUITE="ALL:COMPLEMENTOFALL"
|
2014-02-08 18:37:30 +01:00
|
|
|
DEBUG=0
|
2013-12-09 16:40:23 +01:00
|
|
|
VERBOSE=0
|
2014-02-18 02:05:26 +01:00
|
|
|
DELAY=0
|
2013-12-09 16:40:23 +01:00
|
|
|
ALLCIPHERS=0
|
|
|
|
OUTPUTFORMAT="terminal"
|
2013-07-17 20:49:22 +02:00
|
|
|
|
|
|
|
|
2013-12-09 16:40:23 +01:00
|
|
|
usage() {
|
2014-02-18 02:05:26 +01:00
|
|
|
echo -e "usage: $0 [-a|--allciphers] [-b|--benchmark] [-d|--delay seconds] [-D|--debug] [-j|--json] [-v|--verbose] [-o|--openssl file] [openssl s_client args] <target:port>
|
2014-02-06 23:26:19 +01:00
|
|
|
usage: $0 -h|--help
|
2013-12-09 16:40:23 +01:00
|
|
|
|
|
|
|
$0 attempts to connect to a target site using all the ciphersuites it knowns.
|
|
|
|
Julien Vehent [:ulfr] - https://github.com/jvehent/cipherscan
|
|
|
|
|
2014-02-02 15:41:16 +01:00
|
|
|
Port defaults to 443
|
|
|
|
|
2013-12-09 17:01:30 +01:00
|
|
|
example: $ $0 www.google.com:443
|
2013-12-09 16:40:23 +01:00
|
|
|
|
2014-02-06 23:26:19 +01:00
|
|
|
Use one of the options below:
|
|
|
|
|
|
|
|
-a | --allciphers Test all known ciphers individually at the end.
|
|
|
|
-b | --benchmark Activate benchmark mode.
|
2014-02-18 02:05:26 +01:00
|
|
|
-d | --delay Pause for n seconds between connections
|
|
|
|
-D | --debug Output ALL the information.
|
2014-02-06 23:26:19 +01:00
|
|
|
-h | --help Shows this help text.
|
|
|
|
-j | --json Output results in JSON format.
|
|
|
|
-o | --openssl path/to/your/openssl binary you want to use.
|
|
|
|
-v | --verbose Increase verbosity.
|
2013-12-09 16:40:23 +01:00
|
|
|
|
2014-02-02 15:41:16 +01:00
|
|
|
The rest of the arguments will be interpreted as openssl s_client argument.
|
|
|
|
This enables checking smtp/imap/pop3/ftp/xmpp via -starttls
|
|
|
|
|
2014-02-06 23:26:19 +01:00
|
|
|
EXAMPLES: $0 -starttls xmpp jabber.ccc.de:5222
|
2013-12-09 16:40:23 +01:00
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-17 20:49:22 +02:00
|
|
|
verbose() {
|
2014-02-08 18:37:30 +01:00
|
|
|
if [ $VERBOSE != 0 ]; then
|
2014-02-18 02:05:26 +01:00
|
|
|
echo "$@" >&2
|
2013-07-17 20:49:22 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-02-08 18:37:30 +01:00
|
|
|
debug(){
|
|
|
|
if [ $DEBUG == 1 ]; then
|
2014-02-18 02:05:26 +01:00
|
|
|
echo Debug: "$@" >&2
|
2014-02-08 18:37:30 +01:00
|
|
|
fi
|
|
|
|
}
|
2013-07-17 20:49:22 +02:00
|
|
|
|
|
|
|
# Connect to a target host with the selected ciphersuite
|
|
|
|
test_cipher_on_target() {
|
|
|
|
local sslcommand=$@
|
2013-11-20 16:30:45 +01:00
|
|
|
cipher=""
|
|
|
|
protocols=""
|
|
|
|
pfs=""
|
Correctly report TLSv1.2 only ciphers as negotiable with TLSv1.2
Previously scan would report:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
Now it correctly reports:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2014-04-03 23:37:46 +02:00
|
|
|
previous_cipher=""
|
2013-11-20 16:30:45 +01:00
|
|
|
for tls_version in "-ssl2" "-ssl3" "-tls1" "-tls1_1" "-tls1_2"
|
|
|
|
do
|
2014-04-05 02:46:40 +02:00
|
|
|
debug echo \"quit\\n\" \| $sslcommand $tls_version
|
|
|
|
local tmp=$(echo "quit\n" | $sslcommand $tls_version 1>/dev/stdout 2>/dev/null)
|
2014-02-07 00:56:31 +01:00
|
|
|
current_cipher=$(grep "New, " <<<"$tmp"|awk '{print $5}')
|
|
|
|
current_pfs=$(grep 'Server Temp Key' <<<"$tmp"|awk '{print $4$5$6$7}')
|
2014-02-08 01:14:40 +01:00
|
|
|
current_protocol=$(egrep "^\s+Protocol\s+:" <<<"$tmp"|awk '{print $3}')
|
report key size used in server's certificate
Extend the report to show also server certificate key size:
prio ciphersuite protocols pubkey_size pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
4 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
5 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 RSA,512bits
2014-04-05 19:09:05 +02:00
|
|
|
current_pubkey=$(grep 'Server public key is ' <<<"$tmp"|awk '{print $5}')
|
|
|
|
if [ -z $current_pubkey ]; then
|
|
|
|
current_pubkey=0
|
|
|
|
fi
|
Report the signature type used on server certificate
Parse the certificate used by server and report the signature used:
prio ciphersuite protocols pubkey_size signature_algorithm pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 sha1WithRSAEncryption ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ecdsa-with-SHA512 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
4 AECDH-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 0 None ECDH,P-256,256bits
5 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
6 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption RSA,512bits
2014-04-05 19:21:59 +02:00
|
|
|
current_sigalg=$(openssl x509 -noout -text 2>/dev/null <<<"$tmp"|grep Signature\ Algorithm | head -n 1 | awk '{print $3}') || current_sigalg="None"
|
2014-04-05 19:36:51 +02:00
|
|
|
grep 'Verify return code: 0 ' <<<"$tmp" >/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
current_trusted="True"
|
|
|
|
else
|
|
|
|
current_trusted="False"
|
|
|
|
fi
|
Report the signature type used on server certificate
Parse the certificate used by server and report the signature used:
prio ciphersuite protocols pubkey_size signature_algorithm pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 sha1WithRSAEncryption ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ecdsa-with-SHA512 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
4 AECDH-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 0 None ECDH,P-256,256bits
5 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
6 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption RSA,512bits
2014-04-05 19:21:59 +02:00
|
|
|
if [ -z $current_sigalg ]; then
|
|
|
|
current_sigalg=None
|
|
|
|
fi
|
2013-11-20 16:30:45 +01:00
|
|
|
if [[ -z "$current_protocol" || "$current_cipher" == '(NONE)' ]]; then
|
|
|
|
# connection failed, try again with next TLS version
|
|
|
|
continue
|
Correctly report TLSv1.2 only ciphers as negotiable with TLSv1.2
Previously scan would report:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
Now it correctly reports:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2014-04-03 23:37:46 +02:00
|
|
|
else
|
|
|
|
verbose "connection successful; protocol: $current_protocol, cipher: $current_cipher, previous cipher: $previous_cipher"
|
|
|
|
fi
|
|
|
|
# handling of TLSv1.2 only cipher suites
|
|
|
|
if [ ! -z "$previous_cipher" ] && [ "$previous_cipher" != "$current_cipher" ] && [ "$current_cipher" != "0000" ]; then
|
|
|
|
unset protocols
|
2013-11-20 16:30:45 +01:00
|
|
|
fi
|
Correctly report TLSv1.2 only ciphers as negotiable with TLSv1.2
Previously scan would report:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
Now it correctly reports:
prio ciphersuite protocols pfs_keysize
1 ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 ECDH,P-256,256bits
2 ECDHE-RSA-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 ECDH,P-256,256bits
2014-04-03 23:37:46 +02:00
|
|
|
previous_cipher=$current_cipher
|
|
|
|
|
2013-11-20 16:30:45 +01:00
|
|
|
# connection succeeded, add TLS version to positive results
|
|
|
|
if [ -z "$protocols" ]; then
|
|
|
|
protocols=$current_protocol
|
|
|
|
else
|
|
|
|
protocols="$protocols,$current_protocol"
|
|
|
|
fi
|
|
|
|
cipher=$current_cipher
|
|
|
|
pfs=$current_pfs
|
report key size used in server's certificate
Extend the report to show also server certificate key size:
prio ciphersuite protocols pubkey_size pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
4 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
5 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 RSA,512bits
2014-04-05 19:09:05 +02:00
|
|
|
pubkey=$current_pubkey
|
Report the signature type used on server certificate
Parse the certificate used by server and report the signature used:
prio ciphersuite protocols pubkey_size signature_algorithm pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 sha1WithRSAEncryption ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ecdsa-with-SHA512 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
4 AECDH-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 0 None ECDH,P-256,256bits
5 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
6 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption RSA,512bits
2014-04-05 19:21:59 +02:00
|
|
|
sigalg=$current_sigalg
|
2014-04-05 19:36:51 +02:00
|
|
|
trusted=$current_trusted
|
2013-11-20 16:30:45 +01:00
|
|
|
# grab the cipher and PFS key size
|
|
|
|
done
|
|
|
|
# if cipher is empty, that means none of the TLS version worked with
|
|
|
|
# the current cipher
|
|
|
|
if [ -z "$cipher" ]; then
|
2013-08-04 04:07:13 +02:00
|
|
|
verbose "handshake failed, no ciphersuite was returned"
|
|
|
|
result='ConnectionFailure'
|
|
|
|
return 2
|
2013-11-20 16:30:45 +01:00
|
|
|
|
|
|
|
# if cipher contains NONE, the cipher wasn't accepted
|
|
|
|
elif [ "$cipher" == '(NONE) ' ]; then
|
2014-04-05 19:36:51 +02:00
|
|
|
result="$cipher $protocols $pubkey $sigalg $trusted $pfs"
|
2013-07-17 20:49:22 +02:00
|
|
|
verbose "handshake failed, server returned ciphersuite '$result'"
|
|
|
|
return 1
|
2013-11-20 16:30:45 +01:00
|
|
|
|
|
|
|
# the connection succeeded
|
2013-07-17 20:49:22 +02:00
|
|
|
else
|
2014-04-05 19:36:51 +02:00
|
|
|
result="$cipher $protocols $pubkey $sigalg $trusted $pfs"
|
2013-07-17 20:49:22 +02:00
|
|
|
verbose "handshake succeeded, server returned ciphersuite '$result'"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate the average handshake time for a specific ciphersuite
|
|
|
|
bench_cipher() {
|
|
|
|
local ciphersuite="$1"
|
2014-04-05 02:46:40 +02:00
|
|
|
local sslcommand="$OPENSSLBIN s_client $SCLIENTARGS -connect $TARGET -cipher $ciphersuite"
|
2013-07-17 20:49:22 +02:00
|
|
|
local t="$(date +%s%N)"
|
|
|
|
verbose "Benchmarking handshake on '$TARGET' with ciphersuite '$ciphersuite'"
|
|
|
|
for i in $(seq 1 $BENCHMARKITER); do
|
2014-04-05 02:46:40 +02:00
|
|
|
debug Connection $i
|
|
|
|
(echo "quit\n" | $sslcommand 2>/dev/null 1>/dev/null)
|
2013-08-04 04:07:13 +02:00
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
break
|
|
|
|
fi
|
2013-07-17 20:49:22 +02:00
|
|
|
done
|
|
|
|
# Time interval in nanoseconds
|
|
|
|
local t="$(($(date +%s%N) - t))"
|
|
|
|
verbose "Benchmarking done in $t nanoseconds"
|
2013-07-19 15:45:06 +02:00
|
|
|
# Microseconds
|
|
|
|
cipherbenchms="$((t/1000/$BENCHMARKITER))"
|
2013-07-17 20:49:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Connect to the target and retrieve the chosen cipher
|
2013-11-20 16:30:45 +01:00
|
|
|
# recursively until the connection fails
|
2013-07-17 20:49:22 +02:00
|
|
|
get_cipher_pref() {
|
2014-04-05 02:46:40 +02:00
|
|
|
[ "$OUTPUTFORMAT" == "terminal" ] && [ $DEBUG -lt 1 ] && echo -n '.'
|
2013-07-17 20:49:22 +02:00
|
|
|
local ciphersuite="$1"
|
2014-04-05 19:36:51 +02:00
|
|
|
if [ -e $CACERTS ]; then
|
|
|
|
local sslcommand="$OPENSSLBIN s_client -CAfile $CACERTS $SCLIENTARGS -connect $TARGET -cipher $ciphersuite"
|
|
|
|
else
|
|
|
|
local sslcommand="$OPENSSLBIN s_client $SCLIENTARGS -connect $TARGET -cipher $ciphersuite"
|
|
|
|
fi
|
2013-07-17 20:49:22 +02:00
|
|
|
verbose "Connecting to '$TARGET' with ciphersuite '$ciphersuite'"
|
|
|
|
test_cipher_on_target "$sslcommand"
|
|
|
|
local success=$?
|
|
|
|
# If the connection succeeded with the current cipher, benchmark and store
|
|
|
|
if [ $success -eq 0 ]; then
|
2013-11-20 16:30:45 +01:00
|
|
|
cipherspref=("${cipherspref[@]}" "$result")
|
2013-08-07 16:40:03 +02:00
|
|
|
pciph=$(echo $result|awk '{print $1}')
|
|
|
|
get_cipher_pref "!$pciph:$ciphersuite"
|
2013-07-17 20:49:22 +02:00
|
|
|
return 0
|
|
|
|
fi
|
2014-02-18 02:05:26 +01:00
|
|
|
sleep $DELAY
|
2013-07-17 20:49:22 +02:00
|
|
|
}
|
|
|
|
|
2013-12-09 16:40:23 +01:00
|
|
|
|
2013-12-09 16:16:45 +01:00
|
|
|
display_results_in_terminal() {
|
|
|
|
# Display the results
|
|
|
|
ctr=1
|
|
|
|
for cipher in "${cipherspref[@]}"; do
|
|
|
|
pciph=$(echo $cipher|awk '{print $1}')
|
|
|
|
if [ $DOBENCHMARK -eq 1 ]; then
|
|
|
|
bench_cipher "$pciph"
|
|
|
|
r="$ctr $cipher $cipherbenchms"
|
|
|
|
else
|
|
|
|
r="$ctr $cipher"
|
|
|
|
fi
|
|
|
|
results=("${results[@]}" "$r")
|
|
|
|
ctr=$((ctr+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $DOBENCHMARK -eq 1 ]; then
|
2014-04-05 19:36:51 +02:00
|
|
|
header="prio ciphersuite protocols pubkey_size signature_algoritm trusted pfs_keysize avg_handshake_microsec"
|
2013-12-09 16:16:45 +01:00
|
|
|
else
|
2014-04-05 19:36:51 +02:00
|
|
|
header="prio ciphersuite protocols pubkey_size signature_algorithm trusted pfs_keysize"
|
2013-12-09 16:16:45 +01:00
|
|
|
fi
|
|
|
|
ctr=0
|
|
|
|
for result in "${results[@]}"; do
|
|
|
|
if [ $ctr -eq 0 ]; then
|
|
|
|
echo $header
|
|
|
|
ctr=$((ctr+1))
|
|
|
|
fi
|
|
|
|
echo $result|grep -v '(NONE)'
|
|
|
|
done|column -t
|
|
|
|
}
|
|
|
|
|
2013-12-09 16:40:23 +01:00
|
|
|
|
2013-12-09 16:16:45 +01:00
|
|
|
display_results_in_json() {
|
|
|
|
# Display the results in json
|
|
|
|
ctr=0
|
|
|
|
echo -n "{\"target\":\"$TARGET\",\"date\":\"$(date -R)\",\"ciphersuite\": ["
|
|
|
|
for cipher in "${cipherspref[@]}"; do
|
|
|
|
[ $ctr -gt 0 ] && echo -n ','
|
|
|
|
echo -n "{\"cipher\":\"$(echo $cipher|awk '{print $1}')\","
|
|
|
|
echo -n "\"protocols\":[\"$(echo $cipher|awk '{print $2}'|sed 's/,/","/g')\"],"
|
report key size used in server's certificate
Extend the report to show also server certificate key size:
prio ciphersuite protocols pubkey_size pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
4 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048
5 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 RSA,512bits
2014-04-05 19:09:05 +02:00
|
|
|
echo -n "\"pubkey\":[\"$(echo $cipher|awk '{print $3}'|sed 's/,/","/g')\"],"
|
Report the signature type used on server certificate
Parse the certificate used by server and report the signature used:
prio ciphersuite protocols pubkey_size signature_algorithm pfs_keysize
1 ECDHE-RSA-AES128-SHA256 TLSv1.2 2048 sha1WithRSAEncryption ECDH,P-256,256bits
2 ECDHE-ECDSA-AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 256 ecdsa-with-SHA512 ECDH,P-256,256bits
3 AES128-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
4 AECDH-RC4-SHA SSLv3,TLSv1,TLSv1.1,TLSv1.2 0 None ECDH,P-256,256bits
5 RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption
6 EXP-RC4-MD5 SSLv3,TLSv1,TLSv1.1,TLSv1.2 2048 sha1WithRSAEncryption RSA,512bits
2014-04-05 19:21:59 +02:00
|
|
|
echo -n "\"sigalg\":[\"$(echo $cipher|awk '{print $4}'|sed 's/,/","/g')\"],"
|
2014-04-05 19:36:51 +02:00
|
|
|
echo -n "\"trusted\":\"$(echo $cipher|awk '{print $5}'|sed 's/,/","/g')\","
|
|
|
|
pfs=$(echo $cipher|awk '{print $6}')
|
2013-12-09 16:16:45 +01:00
|
|
|
[ "$pfs" == "" ] && pfs="None"
|
|
|
|
echo -n "\"pfs\":\"$pfs\"}"
|
|
|
|
ctr=$((ctr+1))
|
|
|
|
done
|
|
|
|
echo ']}'
|
|
|
|
}
|
|
|
|
|
2014-02-06 23:26:19 +01:00
|
|
|
# UNKNOWNOPTIONS=""
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
case $1 in
|
|
|
|
-h | --help | -\?)
|
|
|
|
usage
|
|
|
|
exit 0 # This is not an error, User asked help. Don't do "exit 1"
|
|
|
|
;;
|
|
|
|
-o | --openssl)
|
|
|
|
OPENSSLBIN=$2 # You might want to check if you really got FILE
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-a | --allciphers)
|
|
|
|
ALLCIPHERS=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v | --verbose)
|
|
|
|
# Each instance of -v adds 1 to verbosity
|
|
|
|
VERBOSE=$((VERBOSE+1))
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-j | -json | --json | --JSON)
|
|
|
|
OUTPUTFORMAT="json"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-b | --benchmark)
|
|
|
|
DOBENCHMARK=1
|
|
|
|
shift
|
|
|
|
;;
|
2014-02-18 02:05:26 +01:00
|
|
|
-D | --debug)
|
2014-02-08 18:37:30 +01:00
|
|
|
DEBUG=1
|
|
|
|
shift
|
|
|
|
;;
|
2014-02-18 02:05:26 +01:00
|
|
|
-d | --delay)
|
|
|
|
DELAY=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2014-02-06 23:26:19 +01:00
|
|
|
--) # End of all options
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
# -*)
|
|
|
|
# UNKNOWNOPTIONS=$((UNKNOWNOPTIONS+$1))
|
|
|
|
# # echo "WARN: Unknown option (ignored): $1" >&2
|
|
|
|
# shift
|
|
|
|
# ;;
|
|
|
|
*) # no more options we understand.
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2013-07-17 20:49:22 +02:00
|
|
|
|
2014-02-14 20:44:15 +01:00
|
|
|
if [ $VERBOSE != 0 ] ; then
|
2014-02-06 23:26:19 +01:00
|
|
|
echo "Loading $($OPENSSLBIN ciphers -v $CIPHERSUITE 2>/dev/null|grep Kx|wc -l) ciphersuites from $(echo -n $($OPENSSLBIN version 2>/dev/null))"
|
|
|
|
$OPENSSLBIN ciphers ALL 2>/dev/null
|
2013-07-17 20:49:22 +02:00
|
|
|
fi
|
|
|
|
|
2014-02-06 23:26:19 +01:00
|
|
|
# echo paramters left: $@
|
|
|
|
|
|
|
|
TEMPTARGET=$(sed -e 's/^.* //'<<<"${@}")
|
2014-02-06 23:32:12 +01:00
|
|
|
HOST=$(sed -e 's/:.*//'<<<"${TEMPTARGET}")
|
|
|
|
PORT=$(sed -e 's/.*://'<<<"${TEMPTARGET}")
|
2014-02-06 23:26:19 +01:00
|
|
|
|
|
|
|
# Default to https if no port given
|
|
|
|
if [ "$HOST" = "$PORT" ]; then
|
|
|
|
PORT=443
|
|
|
|
fi
|
|
|
|
|
2014-02-08 18:37:30 +01:00
|
|
|
debug "host: $HOST"
|
|
|
|
debug "Port: $PORT"
|
2014-02-06 23:26:19 +01:00
|
|
|
|
|
|
|
TARGET=$HOST:$PORT
|
2014-02-08 18:37:30 +01:00
|
|
|
debug "target: $TARGET"
|
2014-02-06 23:26:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
SCLIENTARGS=$(sed -e s,${TEMPTARGET},,<<<"${@}")
|
2014-02-08 18:37:30 +01:00
|
|
|
debug "sclientargs: $SCLIENTARGS"
|
2014-02-06 23:26:19 +01:00
|
|
|
|
|
|
|
|
2013-07-17 20:49:22 +02:00
|
|
|
cipherspref=();
|
|
|
|
results=()
|
2013-11-20 16:30:14 +01:00
|
|
|
|
|
|
|
# Call to the recursive loop that retrieves the cipher preferences
|
|
|
|
get_cipher_pref $CIPHERSUITE
|
2013-07-17 20:49:22 +02:00
|
|
|
|
2013-12-09 16:16:45 +01:00
|
|
|
if [ "$OUTPUTFORMAT" == "json" ]; then
|
|
|
|
display_results_in_json
|
2013-07-19 15:45:06 +02:00
|
|
|
else
|
2013-12-09 16:16:45 +01:00
|
|
|
echo
|
|
|
|
display_results_in_terminal
|
2013-07-19 15:45:06 +02:00
|
|
|
fi
|
2013-08-04 04:07:13 +02:00
|
|
|
|
2013-11-20 16:47:59 +01:00
|
|
|
# If asked, test every single cipher individually
|
2013-08-04 04:07:13 +02:00
|
|
|
if [ $ALLCIPHERS -gt 0 ]; then
|
|
|
|
echo; echo "All accepted ciphersuites"
|
2013-11-20 16:47:59 +01:00
|
|
|
for c in $($OPENSSLBIN ciphers -v ALL:COMPLEMENTOFALL 2>/dev/null |awk '{print $1}'|sort|uniq); do
|
|
|
|
r="fail"
|
2014-04-05 02:46:40 +02:00
|
|
|
osslcommand="$OPENSSLBIN s_client $SCLIENTARGS -connect $TARGET -cipher $c"
|
2013-08-04 04:07:13 +02:00
|
|
|
test_cipher_on_target "$osslcommand"
|
2013-11-20 16:47:59 +01:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
r="pass"
|
2013-08-04 04:07:13 +02:00
|
|
|
fi
|
2013-11-20 16:47:59 +01:00
|
|
|
echo "$c $r"|awk '{printf "%-35s %s\n",$1,$2}'
|
2014-02-18 02:05:26 +01:00
|
|
|
debug "Sleeping for $DELAY."
|
|
|
|
sleep $DELAY
|
2013-08-04 04:07:13 +02:00
|
|
|
done
|
|
|
|
fi
|