How can I retrieve a list of the SSL/TLS cipher suites a particular website offers?

I've tried openssl, but if you examine the output:

$ echo -n | openssl s_client -connect www.google.com:443 
CONNECTED(00000003)
depth=1 /C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
   i:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
 1 s:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDITCCAoqgAwIBAgIQL9+89q6RUm0PmqPfQDQ+mjANBgkqhkiG9w0BAQUFADBM
MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTEyMTgwMDAwMDBaFw0x
MTEyMTgyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw
FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
gYEA6PmGD5D6htffvXImttdEAoN4c9kCKO+IRTn7EOh8rqk41XXGOOsKFQebg+jN
gtXj9xVoRaELGYW84u+E593y17iYwqG7tcFR39SDAqc9BkJb4SLD3muFXxzW2k6L
05vuuWciKh0R73mkszeK9P4Y/bz5RiNQl/Os/CRGK1w7t0UCAwEAAaOB5zCB5DAM
BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl
LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF
BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw
Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0
ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF
AAOBgQCfQ89bxFApsb/isJr/aiEdLRLDLE5a+RLizrmCUi3nHX4adpaQedEkUjh5
u2ONgJd8IyAPkU0Wueru9G2Jysa9zCRo1kNbzipYvzwY4OA8Ys+WAi0oR1A04Se6
z5nRUP8pJcA2NhUzUnC+MY+f6H/nEQyNv4SgQhqAibAxWEEHXw==
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
issuer=/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
---
No client certificate CA names sent
---
SSL handshake has read 1777 bytes and written 316 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID: 748E2B5FEFF9EA065DA2F04A06FBF456502F3E64DF1B4FF054F54817C473270C
    Session-ID-ctx: 
    Master-Key: C4284AE7D76421F782A822B3780FA9677A726A25E1258160CA30D346D65C5F4049DA3D10A41F3FA4816DD9606197FAE5
    Key-Arg   : None
    Start Time: 1266259321
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---

it just shows that the cipher suite is something with AES256-SHA. I know I could grep through the hex dump of the conversation, but I was hoping for something a little more elegant.

I would prefer to do this on Linux, but Windows (or other) would be fine. This question is motivated by the security testing I do for PCI and general penetration testing.

Update:

GregS points out below that the SSL server picks from the cipher suites of the client. So it seems I would need to test all cipher suites one at a time. I think I can hack something together, but is there a simpler, more future-proof (e.g. new ciphers) way to do this?

  • Maybe gnutls-cli? – grawity Feb 16 '10 at 9:55
  • After the title change, this question really isn't asking for a software-rec. Voting to reopen. – Bob Jun 8 '15 at 13:25
  • @fixer1234 If it makes you happier, I've removed any occurrence of the word "tool". The core question is asking how to accomplish a specific task anyway; it's a minor rephrase and far from more open-ended "list of software" type questions. – Bob Jun 8 '15 at 17:45
  • @Bob: I'm ecstatic. :-) Voting to reopen. – fixer1234 Jun 8 '15 at 18:37

20 Answers 20

up vote 206 down vote accepted

I wrote a bash script to test cipher suites. It gets a list of supported cipher suites from OpenSSL and tries to connect using each one. If the handshake is successful, it prints YES. If the handshake isn't successful, it prints NO, followed by the OpenSSL error text.

#!/usr/bin/env bash

# OpenSSL requires the port number.
SERVER=$1
DELAY=1
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

Here's sample output showing 3 unsupported ciphers, and 1 supported cipher:

[@linux ~]$ ./test_ciphers 192.168.1.11:443
Obtaining cipher list from OpenSSL 0.9.8k 25 Mar 2009.
Testing ADH-AES256-SHA...NO (sslv3 alert handshake failure)
Testing DHE-RSA-AES256-SHA...NO (sslv3 alert handshake failure)
Testing DHE-DSS-AES256-SHA...NO (sslv3 alert handshake failure)
Testing AES256-SHA...YES

EDIT: Add flexibility as host and port are provided as parameter to the script

  • 7
    openssl 1.0 needs a change: if [[ "$result" =~ "Cipher :" ]] ; then instead of if [[ "$result" =~ "Cipher is " ]] ; then I also test for SSL2 and secure renegotiation: echo -n Testing ssl2... result=$(echo -n | openssl s_client -ssl2 -connect $SERVER 2>&1) if [[ "$result" =~ "Cipher :" ]] ; then echo supported. INSECURE! else echo no support, OK fi echo -n Testing SSL secure renegotiation... echo -n "" | openssl s_client -connect $SERVER 2>&1 | grep 'Secure Renegotiation' – Hubert Kario Jul 20 '11 at 7:40
  • 7
    There is another, very sophisticated shell script available that uses sslscan and openssl: TLSSLed – Robert Oct 2 '12 at 9:21
  • 2
    I've listed below another script which only requires OpenSSL called CipherScan – Olivier - interfaSys Sep 16 '14 at 11:36
  • 1
    Note that this script probably won't tell you if a server supports cipher suites that OpenSSL doesn't support. – sampablokuper Sep 19 '16 at 14:33
  • 1
    The suggestion from @Robert for TLSSLed was fantastic. It has been updated to 1.3 and has a lot more functionality. I have been using for security testing and must say that I am impressed. – John Yeary Jan 24 at 21:50

Nmap with ssl-enum-ciphers

There is no better or faster way to get a list of available ciphers from a network service. Plus, nmap will provide a strength rating of strong, weak, or unknown for each available cipher.

First, download the ssl-enum-ciphers.nse nmap script (explanation here). Then from the same directory as the script, run nmap as follows:

List ciphers supported by an HTTP server

$ nmap --script ssl-enum-ciphers -p 443 www.example.com

List ciphers supported by an IMAP server

$ nmap --script ssl-enum-ciphers -p 993 mail.example.com

Here is a snippet of output from a Dovecot IMAP server:

993/tcp open  imaps
| ssl-enum-ciphers:
|   SSLv3:
|     ciphers:
|       TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - strong
|       TLS_DHE_RSA_WITH_AES_128_CBC_SHA - strong
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA - strong
|       TLS_RSA_WITH_IDEA_CBC_SHA - weak
...
|   TLSv1.0:
|     ciphers:
|       TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - strong
|       TLS_DHE_RSA_WITH_AES_128_CBC_SHA - strong
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA - strong
|       TLS_RSA_WITH_IDEA_CBC_SHA - weak
...
|_  least strength: weak

Nmap done: 1 IP address (1 host up) scanned in 1.03 seconds
  • 2
    Is there any way to use this script on IMAP with STARTTLS? STARTTLS on SMTP seems to work, but on IMAP the script doesn't even appear to run. – Giel Jul 11 '14 at 9:17
  • Couple of things: you might be running the script in your nmap distro, rather than the one you downloaded. Check by renaming yours. Then check the "portrule" which in some versions checks for commonly used port numbers. Replace with portrule = function() \n return true \n end – slim Jan 20 '15 at 11:46
  • ... and it would need some hacking to work with IMAP STARTTLS, FTPS AUTH TLS etc, but it's possible. – slim Jan 20 '15 at 11:47
  • 1
    One caveat is that older scripts, which may be included in your distro/package, list ciphers in alphabetical order, not server (or client) preferred order. See the above comment from @slim – Clint Pachl Jan 11 '16 at 23:52
  • 3
    In the 2 years since this answer was written, Nmap has added support for STARTTLS over FTP, NNTP, IMAP, LDAP, POP3, PostgreSQL, SMTP, XMPP, VNC, and MS SQL, as well as many other improvements beyond simply listing supported ciphers. – bonsaiviking Sep 19 '16 at 15:20
up vote 97 down vote
+100

Is there a tool that can test what SSL/TLS cipher suites a particular website offers?

Yes, you could use the online tool on SSL Labs' website to query the Public SSL Server Database.

Here is a snippet of information that it provides:

alt text

(screenshot from results of google.com)

  • cool, thanks for find that. – James K Polk Feb 21 '10 at 0:09
  • This is exactly what I was looking for! Thanks a lot! – Jeremy Powell Feb 25 '10 at 18:48
  • 11
    Unfortunately it does support only HTTPS on standard port, can't use it to check POP3S, IMAPS or IMAP with TLS – Hubert Kario Jul 20 '11 at 8:35
  • 1
    And while it only supports HTTPS, it even lacks support for SNI. – Gurken Papst Jun 8 '12 at 21:21
  • 12
    And while it's great for public-facing sites, you can't use it for sites on networks that are isolated from the Internet. – Iszi May 21 '15 at 13:30

sslscan is a nice little utility.

It tests connecting with TLS and SSL (and the build script can link with its own copy of OpenSSL so that obsolete SSL versions are checked as well) and reports about the server's cipher suites and certificate.

Example output for google.com (trimmed down for readability):

$ sslscan google.com
Testing SSL server google.com on port 443

 TLS renegotiation:
Secure session renegotiation supported

  TLS Compression:
Compression disabled

  Heartbleed:
TLS 1.2 not vulnerable to heartbleed
TLS 1.1 not vulnerable to heartbleed
TLS 1.0 not vulnerable to heartbleed

  Supported Server Cipher(s):
Preferred TLSv1.2  128 bits  ECDHE-RSA-AES128-GCM-SHA256   Curve P-256 DHE 256
Accepted  TLSv1.2  128 bits  ECDHE-RSA-AES128-SHA          Curve P-256 DHE 256
Accepted  TLSv1.2  128 bits  ECDHE-RSA-RC4-SHA             Curve P-256 DHE 256
Accepted  TLSv1.2  128 bits  AES128-GCM-SHA256
Accepted  TLSv1.2  128 bits  AES128-SHA
<snip>
Preferred TLSv1.1  128 bits  ECDHE-RSA-AES128-SHA          Curve P-256 DHE 256
Accepted  TLSv1.1  128 bits  ECDHE-RSA-RC4-SHA             Curve P-256 DHE 256
Accepted  TLSv1.1  128 bits  AES128-SHA
<snip>
Preferred TLSv1.0  128 bits  ECDHE-RSA-AES128-SHA          Curve P-256 DHE 256
Accepted  TLSv1.0  128 bits  ECDHE-RSA-RC4-SHA             Curve P-256 DHE 256
Accepted  TLSv1.0  128 bits  AES128-SHA
<snip>
Preferred SSLv3    128 bits  RC4-SHA
Accepted  SSLv3    128 bits  RC4-MD5
<snip>

  SSL Certificate:
Signature Algorithm: sha256WithRSAEncryption
RSA Key Strength:    2048

Subject:  *.google.com
Altnames: DNS:*.google.com, DNS:*.android.com, <snip>
Issuer:   Google Internet Authority G2

Not valid before: Apr  7 08:24:31 2016 GMT
Not valid after:  Jun 30 08:20:00 2016 GMT
  • 1
    yum install sslscan works on CentOS 6. – a coder Aug 18 '15 at 19:23
  • 1
    sudo dnf install sslscan on Fedora 22 as well. – Zayne S Halsall Sep 28 '15 at 9:45
  • 2
    brew install sslscan on OSX – Xiao Apr 18 '16 at 6:31
  • sudo apt-get install sslscan on Ubuntu (12.04 – so all later versions should be fine). – balu Jun 12 '16 at 22:05
  • 2
    Update: It should be noted that the official version of sslscan found in the Debian and Ubuntu repositories (currently 1.8.2 from 2009) does not support TLS v1.1 and 1.2, see bugs.launchpad.net/ubuntu/+source/sslscan/+bug/1372741. One should therefore use the version on GitHub that the OP linked to. – balu Jun 12 '16 at 22:58

Since this is such a great reference thread for SSL scanning tools, I'll list CipherScan which was created a year ago and can also identify problems with key exchange ciphers. https://github.com/jvehent/cipherscan

If you want my fork which supports SNI and FreeBSD, the URL is https://github.com/oparoz/cipherscan

It's a script which calls openssl s_client and supports using your own OpenSSL binary so that you can test upcoming features or new ciphers (chacha20+poly1305 per example).

It also lets you connect to any port you want and use starttlss.

Here is a typical output

# ./cipherscan -o ./openssl api.mycompany.com:443
...................
prio  ciphersuite                  protocols              pfs_keysize
1     DHE-RSA-AES256-GCM-SHA384    TLSv1.2                DH,4096bits
2     DHE-RSA-AES256-SHA256        TLSv1.2                DH,4096bits
3     ECDHE-RSA-AES256-GCM-SHA384  TLSv1.2                ECDH,P-384,384bits
4     ECDHE-RSA-AES256-SHA384      TLSv1.2                ECDH,P-384,384bits
5     DHE-RSA-AES128-GCM-SHA256    TLSv1.2                DH,4096bits
6     DHE-RSA-AES128-SHA256        TLSv1.2                DH,4096bits
7     ECDHE-RSA-AES128-GCM-SHA256  TLSv1.2                ECDH,P-384,384bits
8     ECDHE-RSA-AES128-SHA256      TLSv1.2                ECDH,P-384,384bits
9     DHE-RSA-CAMELLIA256-SHA      TLSv1,TLSv1.1,TLSv1.2  DH,4096bits
10    DHE-RSA-AES256-SHA           TLSv1,TLSv1.1,TLSv1.2  DH,4096bits
11    ECDHE-RSA-AES256-SHA         TLSv1,TLSv1.1,TLSv1.2  ECDH,P-384,384bits
12    DHE-RSA-CAMELLIA128-SHA      TLSv1,TLSv1.1,TLSv1.2  DH,4096bits
13    DHE-RSA-AES128-SHA           TLSv1,TLSv1.1,TLSv1.2  DH,4096bits
14    ECDHE-RSA-AES128-SHA         TLSv1,TLSv1.1,TLSv1.2  ECDH,P-384,384bits
15    CAMELLIA256-SHA              TLSv1,TLSv1.1,TLSv1.2
16    AES256-SHA                   TLSv1,TLSv1.1,TLSv1.2
17    CAMELLIA128-SHA              TLSv1,TLSv1.1,TLSv1.2
18    AES128-SHA                   TLSv1,TLSv1.1,TLSv1.2

Certificate: trusted, 4096 bit, sha256WithRSAEncryption signature
TLS ticket lifetime hint: 300
OCSP stapling: supported

And here are a list of options

-a | --allciphers   Test all known ciphers individually at the end.
-b | --benchmark    Activate benchmark mode.
-d | --delay        Pause for n seconds between connections
-D | --debug        Output ALL the information.
-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.

The json output is useful if you're calling this from other scripts.

  • "big-SSLv3 config not supported, connection failed" – a coder Aug 18 '15 at 19:30

https://github.com/iSECPartners/sslyze

This one is Python based, works in Linux/Mac/Windows from command line.

After a little googling I found this Testing for SSL-TLS (OWASP-CM-001):

The nmap scanner, via the “–sV” scan option, is able to identify SSL services. Vulnerability Scanners, in addition to performing service discovery, may include checks against weak ciphers (for example, the Nessus scanner has the capability of checking SSL services on arbitrary ports, and will report weak ciphers).

and also: Foundstone SSL Digger is a tool to assess the strength of SSL servers by testing the ciphers supported. Some of these ciphers are known to be insecure.

I am using for most of the SSL tests testssl.sh (see https://testssl.sh / devel version @ https://github.com/drwetter/testssl.sh. It tests for vulnerabilities, ciphers, protocols etc.

SSLScan is great; a new tool SSLDiagnos works for Windows, or you can just write a script using the openssl s_client.

Nmap's ssl-enum-ciphers script can list the supported ciphers and SSL/TLS versions, as well as the supported compressors.

If you want a nice grepable output (and support for checking all SSL/TLS versions)

Usage: ./script.sh www.url.com

#!/usr/bin/env bash
ciphers2=$(openssl ciphers -ssl2 'ALL:eNULL' | sed -e 's/:/ /g')
ciphers3=$(openssl ciphers -ssl3 'ALL:eNULL' | sed -e 's/:/ /g')
cipherst1=$(openssl ciphers -tls1 'ALL:eNULL' | sed -e 's/:/ /g')
cipherst11=$(openssl ciphers -tls1.1 'ALL:eNULL' | sed -e 's/:/ /g')
cipherst12=$(openssl ciphers -tls1.2 'ALL:eNULL' | sed -e 's/:/ /g')

SSL2="SSL2("
for cipher in ${ciphers2[@]}
do
result=$(echo -n | openssl s_client -ssl2 -cipher "$cipher" -connect $1:443 2>&1)
if [[ "$result" =~ "Cipher is ${cipher}" ]] ; then
  SSL2="${SSL2}${cipher}:"
fi
done
SSL2=$(echo "${SSL2})" | sed -e 's/:)/)/g')

SSL3="SSL3("
for cipher in ${ciphers3[@]}
do
result=$(echo -n | openssl s_client -ssl3 -cipher "$cipher" -connect $1:443 2>&1)
if [[ "$result" =~ "Cipher is ${cipher}" ]] ; then
  SSL3="${SSL3}${cipher}:"
fi
done
SSL3=$(echo "${SSL3})" | sed -e 's/:)/)/g')
TLS1="TLS1("
for cipher in ${cipherst1[@]}
do
result=$(echo -n | openssl s_client -tls1 -cipher "$cipher" -connect $1:443 2>&1)
if [[ "$result" =~ "Cipher is ${cipher}" ]] ; then
  TLS1="${TLS1}${cipher}:"
fi
done
TLS1=$(echo "${TLS1})" | sed -e 's/:)/)/g')

TLS11="TLS1.1("
for cipher in ${cipherst11[@]}
do
result=$(echo -n | openssl s_client -tls1_1 -cipher "$cipher" -connect $1:443 2>&1)
if [[ "$result" =~ "Cipher is ${cipher}" ]] ; then
  TLS11="${TLS11}${cipher}:"
fi
done
TLS11=$(echo "${TLS11})" | sed -e 's/:)/)/g')

TLS12="TLS1.2("
for cipher in ${cipherst12[@]}
do
result=$(echo -n | openssl s_client -tls1_2 -cipher "$cipher" -connect $1:443 2>&1)
if [[ "$result" =~ "Cipher is ${cipher}" ]] ; then
  TLS12="${TLS12}${cipher}:"
fi
done
TLS12=$(echo "${TLS12})" | sed -e 's/:)/)/g')

echo "$1,$SSL2,$SSL3,$TLS1,$TLS11,$TLS12";
  • You are performing openssl ciphers -tls1.1 and openssl ciphers -tls1.2 however those params don't seem to exist... There is only -tls1 (at least on the platforms I have tried). – Marki Jun 15 '16 at 9:19
  • (There seem to be additional options in the form of tls1_1 and tls1_2 but they are only shown on the master version of openssl and not even in 1.0.2 ....) – Marki Jun 15 '16 at 9:30
  • Note that this script probably won't tell you if a server supports cipher suites that OpenSSL doesn't support. – sampablokuper Sep 19 '16 at 14:31

There is a nice little script at pentesterscripting.com to utilise both SSLScan and OpenSSL to check for:

  • SSL v2;
  • Week ciphers suits;
  • MD5; and
  • TLS Renegotiation vulnerability

http://www.pentesterscripting.com/discovery/ssl_tests (via the Internet Archive Wayback Machine)

Duplicated here for futureproofing as the main site is now dead:

#!/usr/bin/env bash

# Description:
#       Script to extract the most security relevant details from a 
#       target SSL/TLS implementation by using sslscan.
# Author:  Raul Siles (raul _AT_ taddong _DOT_ com)
#          Taddong (www.taddong.com)
# Date:    2011-05-27
# Version: 1.0
#
# - Current SSL/TLS tests: 
#   SSLv2, NULL cipher, weak ciphers -key length-, strong 
#   ciphers -AES-, MD5 signed cert, SSL/TLS renegotiation
#
# Requires: 
# - sslscan
# https://sourceforge.net/projects/sslscan/
#
# Credits: Based on ssl_test.sh by Aung Khant, http://yehg.net.
# 

#
# /**************************************************************************
# *   Copyright 2011 by Taddong (Raul Siles)                                *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU General Public License as published by  *
# *   the Free Software Foundation; either version 3 of the License, or     *
# *   (at your option) any later version.                                   *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU General Public License for more details.                          *
# *                                                                         *
# *   You should have received a copy of the GNU General Public License     *
# *   along with this program. If not, see <http://www.gnu.org/licenses/>.  *
# *                                                                         *
# **************************************************************************/
#

VERSION=1.0

OPENSSLVERSION=$(openssl version)
SSLSCANVERSION=$(sslscan --version | grep version | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")

echo ------------------------------------------------------
echo " TLSSLed - ($VERSION) based on sslscan and openssl"
echo " by Raul Siles (www.taddong.com)"
echo " ( inspired by ssl_test.sh by Aung Khant )"
echo ------------------------------------------------------
echo + openssl version: $OPENSSLVERSION
echo + $SSLSCANVERSION
echo ------------------------------------------------------
echo

if [ $# -ne 2 ]; then 
   echo Usage: $0 IP PORT
   exit
fi

HOST=$1
PORT=$2

echo  [*] Analyzing SSL/TLS on $HOST:$PORT ...
echo 

# Run sslcan once, store the results to a log file and
# analyze that file for all the different tests:
DATE=$(date +%F_%R:%S)
TARGET=$HOST:$PORT
LOGFILE=sslscan\_$TARGET\_$DATE.log
ERRFILE=sslscan\_$TARGET\_$DATE.err

echo [*] Running sslscan on $HOST:$PORT...
sslscan $HOST:$PORT > $LOGFILE 2> $ERRFILE

echo
echo [*] Testing for SSLv2 ...
cat $LOGFILE | grep "Accepted  SSLv2"
echo
echo [*] Testing for NULL cipher ...
cat $LOGFILE | grep "NULL" | grep Accepted
echo
echo [*] Testing for weak ciphers \(based on key length\) ...
cat $LOGFILE | grep " 40 bits" | grep Accepted
echo 
cat $LOGFILE | grep " 56 bits" | grep Accepted
echo
echo [*] Testing for strong ciphers \(AES\) ...
cat $LOGFILE | grep "AES" | grep Accepted

echo 
echo [*] Testing for MD5 signed certificate ...
#cat $LOGFILE | grep -E 'MD5WithRSAEncryption|md5WithRSAEncryption'
cat $LOGFILE | grep -i 'MD5WithRSAEncryption'

echo 
echo [*] Checking preferred server ciphers ...
cat $LOGFILE | sed '/Prefered Server Cipher(s):/,/^$/!d' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

echo
echo [*] Testing for SSLv3/TLSv1 renegotiation vuln. \(CVE-2009-3555\) ...
#echo [*] echo R \| openssl s_client -connect $HOST:$PORT \| grep "DONE"
#
# Renegotiation details go to stderr (2>)
#
# if $OPENSSLVERSION is updated (version?) it supports RFC5746 and will print:
# Secure Renegotiation IS NOT supported
# Secure Renegotiation IS supported
#

echo R | openssl s_client -connect $HOST:$PORT | grep -E "Secure Renegotiation IS|DONE"

echo
echo [*] New files created:
ls -l $LOGFILE
if [ ! -s $ERRFILE ]; then
        # Error file is empty
        rm $ERRFILE
else
        ls -l $ERRFILE
fi

echo
echo 
echo [*] done
echo

Usage: ./ssltest.sh HOST PORT

Based on @indiv's answer and suggestion to post it as its own answer, I am providing my tweaked version of @indiv's script. You can provide a host as the first argument, and it will output the same results as the original script, but a little more formatted:

#!/usr/bin/env bash
# adapted from https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers

# OpenSSL requires the port number.
# SERVER=192.168.1.1:443
SERVER=$1
if [[ -z "$SERVER" ]]; then echo "ERROR: no server specified"; exit 1; fi;

## Set up colors, if possible
if [[ $(tput colors) ]];then
  COLOR_BOLD="$(tput bold)"     # "\e[1;32m"
  COLOR_GREEN="$(tput setaf 2)" # "\e[1;32m"
  COLOR_RESET="$(tput sgr0)"    # "\e[0m"
fi


SERVER=$1:443
echo Server is ${COLOR_BOLD}"$SERVER"${COLOR_RESET}

DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')

echo Obtaining cipher list from $(openssl version).

for cipher in ${ciphers[@]}
  do
  printf "%-42s" "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 ${COLOR_BOLD}${COLOR_GREEN}YES${COLOR_RESET}
    else
      echo UNKNOWN RESPONSE
      echo $result
    fi
  fi
  sleep $DELAY
done

I wrote a tool that does exactly this. It's called tlsenum and it's available on GitHub.

[ayrx@division tlsenum]$ ./tlsenum.py twitter.com 443
TLS Versions supported by server: 3.0, 1.0, 1.1, 1.2
Supported Cipher suites in order of priority:
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_RC4_128_SHA
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_GCM_SHA256
TLS_RSA_WITH_RC4_128_SHA
TLS_RSA_WITH_RC4_128_MD5
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA

Here is an example output of the tool against twitter.com.

It's similar to what SSL Lab's does but I find that having a command line tool that you can automate and parse is much more useful.

The (free of charge) OpenSSL Cookbook by Ivan Ristić, who developed the SSL Labs online tool noted in Kez's answer, states:

If you want to determine all suites supported by a particular server, start by invoking openssl ciphers ALL to obtain a list of all suites supported by your version of OpenSSL. Then submit them to the server one by one to test them individually. I am not suggesting that you do this manually; this is a situation in which a little automation goes a long way. In fact, this is a situation in which looking around for a good tool might be appropriate.

There is a disadvantage to testing this way, however. You can only test the suites that OpenSSL supports. ...

No single SSL/TLS library supports all cipher suites, and that makes comprehensive testing difficult. For SSL Labs, I resorted to using partial handshakes for this purpose, with a custom client that pretends to support arbitrary suites. It actually can’t negotiate even a single suite, but just proposing to negotiate is enough for servers to tell you if they support a suite or not. Not only can you test all the suites this way, but you can also do it very efficiently.

(My emphasis.)

One tool I haven't seen mentioned in other answers is Stephen Bradshaw's SSLTest, which, among other things, is intended to compare "the detected ciphers and protocols against compliance standards such as DSD ISM and PCI-DSS."

So, try this or one of the tools mentioned in the other answers, or else build your own and consider using Ristić's approach of partial handshakes.

The only thing you can do is try them all, one at a time, and see which ones are accepted. I am not aware of a tool to do this, though it should not be hard to cobble one together from scripting tools and openssl s_client.

While the client advertises which ciphersuites it will accept, the server simply picks one and uses it or fails the connection if it finds nothing it likes.

  • Oh yeah... for some reason I was thinking it was the other way around. Maybe I can find a pre-cobbled tool... :) – Jeremy Powell Feb 16 '10 at 16:50

All those answers are fine. One part of the answer could explain why do we need a tool to discover list of server and not ask directly in TLS that server gives all its supported cipher suites just like TLS client does when it connects to a server.

Answer is that server does not send a list ever, it just select in client cipher list the cipher it wants to use, this is the way SSL/TLS protocol is written : http://wiki.opensslfoundation.com/index.php/SSL_and_TLS_Protocols#Cipher_Suites

That's why client has to enumerate ciphers to be able to find those supported by server and for that to do at least one new start handshake (ClientHello) for each cipher suite.

While looking for something that does AUTH TLS on FTP, I discovered this tool: ssl-cipher-suite-enum

It’s a perl script that basically does what hackajar’s shell script does, only more sophisticated.

It also offers a basic evaluation of offered ciphers and protocols. It’s somewhat like SSL Labs tools, only for home use. :)

By default, it only supports AUTH SSL on FTP, but a simple search and replace can fix that. As a bonus, it also claims to support SMTP with STARTTLS and RDP.

SSLyze, originally at https://github.com/iSECPartners/sslyze, is now at https://github.com/nabla-c0d3/sslyze. It was mentioned in another answer, but without much detail.

SSLyze is Python based, and works on Linux/Mac/Windows from command line. It uses OpenSSL, and on Windows, it comes with a bundled copy of OpenSSL.

Lists protocols, cipher suites, and key details, plus tests for some common vulnerabilities. It's possible to enable or disable particular checks, to get more data or speed up the scan.

TestSSLServer is a purely Java-based solution. Advantages:

  • it's working very low-level, just on plain Sockets, so it's independent of possible unavailable ciphers from JDK or OpenSSL.

  • it doesn't require any additional ports (like ICMP for ping) to be opened

  • it's working with client certificates present

Disadvantages:

  • as of 2016, the list of ciphers might be outdated (though I'm no expert here to judge this)

My personal experience: given a tight-laced server with just a single HTTPS port open (no other port), client certificates required and iptables being active, it was still able to list available ciphers, while top-voted solutions were not (I was trying small shell script, SSL Labs, NMap, sslscan)

protected by Raystafarian Apr 15 '16 at 14:41

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.