388

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?

4
  • Maybe gnutls-cli? Feb 16, 2010 at 9:55
  • After the title change, this question really isn't asking for a software-rec. Voting to reopen.
    – Bob
    Jun 8, 2015 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, 2015 at 17:45
  • @Bob: I'm ecstatic. :-) Voting to reopen.
    – fixer1234
    Jun 8, 2015 at 18:37

23 Answers 23

336

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

16
  • 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' Jul 20, 2011 at 7:40
  • 13
    There is another, very sophisticated shell script available that uses sslscan and openssl: TLSSLed
    – Robert
    Oct 2, 2012 at 9:21
  • 2
    I've listed below another script which only requires OpenSSL called CipherScan Sep 16, 2014 at 11:36
  • 2
    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, 2018 at 21:50
  • 6
    This won't work with recent OpenSSL versions that use TLS 1.3 by default, because s_client wants -ciphersuites instead of -cipher. I changed the script accordingly (with some other tweaks)
    – Jakob
    Oct 18, 2019 at 13:07
290

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
14
  • 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, 2014 at 9:17
  • 1
    The Debian nmap package appears to include the ssl-enum-ciphers script. :+1: Dec 15, 2015 at 21:02
  • 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 Jan 11, 2016 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. Sep 19, 2016 at 15:20
  • 10
    Caution: this script seems to be outdated, with no support for TLSv1.3!
    – Yan Foto
    Feb 10, 2020 at 16:35
134
+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)

6
  • This is exactly what I was looking for! Thanks a lot! Feb 25, 2010 at 18:48
  • 15
    Unfortunately it does support only HTTPS on standard port, can't use it to check POP3S, IMAPS or IMAP with TLS Jul 20, 2011 at 8:35
  • 1
    And while it only supports HTTPS, it even lacks support for SNI. Jun 8, 2012 at 21:21
  • 16
    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, 2015 at 13:30
  • Note that it requires a FQDN; it won't test IP addresses. It seems you have to make an account for that...
    – FreeText
    Mar 5, 2020 at 17:04
94

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
10
  • 2
    yum install sslscan works on CentOS 6.
    – a coder
    Aug 18, 2015 at 19:23
  • 1
    sudo dnf install sslscan on Fedora 22 as well. Sep 28, 2015 at 9:45
  • 7
    brew install sslscan on OSX
    – Xiao
    Apr 18, 2016 at 6:31
  • 3
    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, 2016 at 22:58
  • 1
    As of Mar 2020, the sslscan version is 1.11.5 from the Ubuntu repositories, which includes support for TLS v1.1. and 1.2, but not TLS v1.3 because it is still using OpenSSL 1.0.2n (7 Dec 2017). I believe OpenSSL added TLS 1.3 support in v1.1.1.
    – FreeText
    Mar 5, 2020 at 17:06
17

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.

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

https://github.com/iSECPartners/sslyze

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

9

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.

9

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.

0
8

This answer summarizes best given answers sofar and argues why to choose an alternative (or not!).


To find the best solution, we should first answer 'why do we want to enumerate all supported ciphers?'. Here the focus is on the security aspect, i.e., to find out if a server is vulnerable or not. The next question to answer is if the output should be machine readable, e.g., to be further used in a script, or not.

  1. testssl.sh

  • CLI (Bash)
  • TLSv1.3
  • Checks for known vulnerabilities
  • Self-contained (not installation needed)
  • Supports 370 ciphers (as of version 3.1) including deprecated ciphers (not included in newer openSSL versions)
  • Produces machine-readable results (CSV and JSON)
  • (parallelized) batch processing
  • Slow

Maybe the most important advantage of testssl.sh over the following alternatives is the usage of a set of binaries which are tailored for vulnerability testing (read developer's explanation here).

  1. cipherscan

  • CLI (python)
  • No TLSv1.3
  • Self-contained
  • Limited cipher suites (hard-coded)
  • Produces machine-readable results (JSON)
  • Fast
  1. nmap ssl-enum-ciphers

  • CLI (nmap script)
  • No TLSv1.3 (newer versions do support this!)
  • Self-contained
  • Limited cipher suites (hard-coded)
  • Checks for known vulnerabilities
  • No machine-readable results

For an exhaustive overview of available tools see sslLabs Assessment Tools.

1
  • 1
    nmap 7.92 supports TLSv1.3
    – Kobi T
    May 3, 2022 at 13:30
3

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

0
2

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

2

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
2

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.

2

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";
4
  • 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, 2016 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, 2016 at 9:30
  • Note that this script probably won't tell you if a server supports cipher suites that OpenSSL doesn't support.
    – user11574
    Sep 19, 2016 at 14:31
  • OpenSSL 1.1.1 does include TLS 1.1, 1.2 and 1.3 support. The parameters are -tls1_1, -tls1_2 and -tls1_3. However, -tls1_2, for example, returns more than you would expect. Try from your command line: openssl ciphers -v -tls1_2
    – FreeText
    Mar 5, 2020 at 17:11
1

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

1
  • 1
    Your answer was earlier, but Clint Pachl's answer explains ssl-enum-ciphers much more comprehensively.
    – user11574
    Sep 19, 2016 at 14:28
1

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.

1

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.

1

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.

1

This is a variation of the accepted answer, tweaked to work with some improvements from the comments.

also includes colorization for legibility

# if you want to test https://www.google.com/ call the script with www.google.com:443 as the parameter. Do not include the protocol or any symbols after the hostname

# OpenSSL requires the port number.
SERVER=$1
#PORT=443
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
# for colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m' 
NC='\033[0m' # No Color

ALL_CIPHERS_FILE="scans/${SERVER}_ALL_CIPHERS.txt"
SUPPORTED_CIPHERS_FILE="scans/${SERVER}_SUPPORTED_CIPHERS.txt"

touch $ALL_CIPHERS_FILE
touch $SUPPORTED_CIPHERS_FILE

echo Obtaining cipher list from $(openssl version).

for PROTO in "1_1" "1_2" "1_3" ; do
  for cipher in ${ciphers[@]}
  do
    echo -ne "\t\tTesting\tTLS $PROTO : $cipher...\t"
    echo -ne "TLS $PROTO\t$cipher\n" >> $ALL_CIPHERS_FILE
    CIPHERSWITCH="-cipher $cipher"
    if [ $PROTO == "1_3" ]; then
      CIPHERSWITCH="-ciphersuites $cipher"
    fi
    result=$(echo -n | openssl s_client $CIPHERSWITCH -tls$PROTO -connect $SERVER 2>&1)
    if [[ "$result" =~ ":error:" ]] ; then
      error=$(echo -n $result | cut -d':' -f6)
      echo -e "${RED}NO${NC}\t" \($error\) # reason(1868) is a communication error #TODO: make script stop if we get these?
    else
      if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher    :" ]] ; then
        echo -e "${GREEN}YES${NC}\t"
        echo -ne "TLS $PROTO\t$cipher\n" >> $SUPPORTED_CIPHERS_FILE
      else
        echo -e "${YELLOW}UNKNOWN RESPONSE${NC}\t"
        echo $result
      fi
    fi
    sleep $DELAY
  done
done

sample output

0

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.

1
  • Oh yeah... for some reason I was thinking it was the other way around. Maybe I can find a pre-cobbled tool... :) Feb 16, 2010 at 16:50
0

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.

0

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)

0

hello_tls

It's a fast, pure-Python library/CLI application that enumerates cipher suites and groups by making its own TLS handshake packets.

  • Doesn't require OpenSSL*.
  • Gives per-protocol results, supporting SSLv3 to TLS 1.3.
  • Scans hundreds of cipher suites and dozens of groups, since it doesn't need to actually implement any of them.
  • Fast, since it scans by sending only unencrypted Client Hello packets, and in parallel (default: 6 connections). A full scan usually takes less than 300 milliseconds.
  • Supports http proxies.
  • Runs on Windows, Linux, and any system with Python 3.9+.
  • Available on PyPI: pip install hello_tls; python -m hello_tls boppreh.com

* OpenSSL is still required if you want to list certificates, which is enabled by default. Disable it with scan_server(..., fetch_cert_chain=False) or --no-certs. You'll never need an old OpenSSL version, though, since the cipher suite scan is in pure Python.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .