How do I list the SSL/TLS cipher suites a particular website offers?

276

154

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?

Jeremy Powell

Posted 2010-02-15T18:47:18.380

Reputation: 5 419

Maybe gnutls-cli? – user1686 – 2010-02-16T09:55:28.737

After the title change, this question really isn't asking for a software-rec. Voting to reopen. – Bob – 2015-06-08T13:25:30.533

@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 – 2015-06-08T17:45:09.740

@Bob: I'm ecstatic. :-) Voting to reopen. – fixer1234 – 2015-06-08T18:37:25.747

Answers

246

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

indiv

Posted 2010-02-15T18:47:18.380

Reputation: 3 325

2

I've listed below another script which only requires OpenSSL called CipherScan

– Olivier - interfaSys – 2014-09-16T11:36:00.613

@indiv I created test_ciphers file with the script in your answer and am trying to run the script in openSSL console on Windows as openSSL>test_ciphers but am getting openssl:Error: 'test_ciphers' is an invalid command. Can you tell me how to run your script in windows? – RanPaul – 2015-06-23T16:32:47.123

@RanPaul: You can install cygwin or msys to get the bash shell and then run this script as a bash script. I tried to write a native Windows script but there's a bug in openssl s_client that causes it to hang until a keypress, so that's not going to be possible. – indiv – 2015-07-14T18:11:53.907

@indiv this is awesome! I added a couple of tweaks for my usage, how can I best make those available for everyone? – insaner – 2016-02-03T08:55:38.857

@insaner: If they're substantial, I'd say to post them in a new answer. I don't have a good answer for what to do. – indiv – 2016-02-04T05:24:07.027

@indiv, here it is: http://superuser.com/a/1035879/316396

– insaner – 2016-02-05T00:56:23.470

1

Note that this script probably won't tell you if a server supports cipher suites that OpenSSL doesn't support.

– sampablokuper – 2016-09-19T14:33:12.563

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 – 2018-01-24T21:50:52.880

Some Bash corrections, https://gist.github.com/ilatypov/488b4f35990a003052e422b4c108608f

– eel ghEEz – 2019-01-23T04:10:15.383

A word of caution - this script does not work if the server expects a client side certificate. – karafior – 2019-06-14T12:52:58.063

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 – 2019-10-18T13:07:31.760

This is fantastic. It's even more exactly what I was looking for. – Jeremy Powell – 2010-12-21T17:42:52.813

7openssl 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 – 2011-07-20T07:40:03.687

10

There is another, very sophisticated shell script available that uses sslscan and openssl: TLSSLed

– Robert – 2012-10-02T09:21:17.170

@HubertKario - later versions of openssl do not support the -ssl2 flag (although it is still listed in the help) – Steven – 2013-08-21T02:45:34.053

170

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

Clint Pachl

Posted 2010-02-15T18:47:18.380

Reputation: 1 822

2Is 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 – 2014-07-11T09:17:37.973

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 – 2015-01-20T11:46:57.647

... and it would need some hacking to work with IMAP STARTTLS, FTPS AUTH TLS etc, but it's possible. – slim – 2015-01-20T11:47:30.310

The Debian nmap package appears to include the ssl-enum-ciphers script. :+1: – ThorSummoner – 2015-12-15T21:02:13.660

1One 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 – 2016-01-11T23:52:51.720

3In 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 – 2016-09-19T15:20:39.153

Sorry but Nmap's ssl cipher enum script shows some ciphers which openssl can't proceed with when connecting to imap.mail.yahoo.com:993. – eel ghEEz – 2019-01-23T04:11:34.827

@eelghEEz Works fine on OpenBSD 6.4 running nmap-7.70 compiled with openssl-2.8.2 (which is LibreSSL 2.8.2 on OpenBSD). Check nmap -V on your system. Maybe you have old libraries or disabled ciphers. To check the Yahoo IMAP server, skip host discovery with the -Pn option. – Clint Pachl – 2019-01-24T08:42:06.127

@ClintPachl The nmap script shows ciphers such as TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA but running openssl s_client -cipher EDH-RSA-DES-CBC3-SHA -connect imap.mail.yahoo.com:993 -no_ign_eof < /dev/null ; echo $? shows sslv3 alert handshake failure. Using openssl shows only 12 ciphers allowed by Yahoo IMAP on port 993: https://gist.github.com/ilatypov/488b4f35990a003052e422b4c108608f

– eel ghEEz – 2019-01-24T11:16:58.920

A word of caution.. This could cause poorly written applications to crash. Read this document before you proceed using this tool https://nmap.org/book/legal-issues.html

– rakpan – 2019-03-08T14:25:07.813

Caution: this script seems to be outdated, with no support for TLSv1.3! – Yan Foto – 2020-02-10T16:35:15.430

106

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)

Kez

Posted 2010-02-15T18:47:18.380

Reputation: 15 359

This is exactly what I was looking for! Thanks a lot! – Jeremy Powell – 2010-02-25T18:48:00.703

13And while it's great for public-facing sites, you can't use it for sites on networks that are isolated from the Internet. – Iszi – 2015-05-21T13:30:02.373

11Unfortunately it does support only HTTPS on standard port, can't use it to check POP3S, IMAPS or IMAP with TLS – Hubert Kario – 2011-07-20T08:35:09.823

1And while it only supports HTTPS, it even lacks support for SNI. – Gurken Papst – 2012-06-08T21:21:11.183

57

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

indiv

Posted 2010-02-15T18:47:18.380

Reputation: 3 325

2yum install sslscan works on CentOS 6. – a coder – 2015-08-18T19:23:35.367

1sudo dnf install sslscan on Fedora 22 as well. – Zayne S Halsall – 2015-09-28T09:45:21.553

2brew install sslscan on OSX – Xiao – 2016-04-18T06:31:24.500

sudo apt-get install sslscan on Ubuntu (12.04 – so all later versions should be fine). – balu – 2016-06-12T22:05:10.480

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 https://bugs.launchpad.net/ubuntu/+source/sslscan/+bug/1372741. One should therefore use the version on GitHub that the OP linked to.

– balu – 2016-06-12T22:58:59.733

The version packaged with Debian 9 uses an older OpenSSL package, but that version doesn't support SSL2 or SSL3. – garethTheRed – 2019-06-13T06:08:33.140

'sslscan' seems to not work when behind a proxy. – nobar – 2019-06-26T02:02:36.500

This is great utility. nmap is just terrible for new users. It doesn't want to scan localhost, it has problems with custom ports. – Zergatul – 2020-01-31T12:34:55.270

15

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.

Olivier - interfaSys

Posted 2010-02-15T18:47:18.380

Reputation: 271

"big-SSLv3 config not supported, connection failed" – a coder – 2015-08-18T19:30:37.147

13

https://github.com/iSECPartners/sslyze

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

Scott

Posted 2010-02-15T18:47:18.380

Reputation: 131

8

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.

fluxtendu

Posted 2010-02-15T18:47:18.380

Reputation: 6 701

6

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.

Dirk

Posted 2010-02-15T18:47:18.380

Reputation: 141

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

insaner

Posted 2010-02-15T18:47:18.380

Reputation: 306

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.

sampablokuper

Posted 2010-02-15T18:47:18.380

Reputation: 2 389

2

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

Dwayne

Posted 2010-02-15T18:47:18.380

Reputation: 21

2

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

Pi3cH

Posted 2010-02-15T18:47:18.380

Reputation: 51

2

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

bonsaiviking

Posted 2010-02-15T18:47:18.380

Reputation: 1 563

1

Your answer was earlier, but Clint Pachl's answer explains ssl-enum-ciphers much more comprehensively.

– sampablokuper – 2016-09-19T14:28:46.300

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";

hackajar

Posted 2010-02-15T18:47:18.380

Reputation: 121

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 – 2016-06-15T09:19:33.250

(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 – 2016-06-15T09:30:07.813

Note that this script probably won't tell you if a server supports cipher suites that OpenSSL doesn't support.

– sampablokuper – 2016-09-19T14:31:21.293

1

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).

2. cipherscan

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

3. nmap ssl-enum-ciphers

  • CLI (nmap script)
  • No TLSv1.3
  • 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.

Yan Foto

Posted 2010-02-15T18:47:18.380

Reputation: 129

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.

Ayrx

Posted 2010-02-15T18:47:18.380

Reputation: 195

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.

CBHacking

Posted 2010-02-15T18:47:18.380

Reputation: 5 045

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)

mstrap

Posted 2010-02-15T18:47:18.380

Reputation: 113

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.

President James Moveon Polk

Posted 2010-02-15T18:47:18.380

Reputation: 187

Oh yeah... for some reason I was thinking it was the other way around. Maybe I can find a pre-cobbled tool... :) – Jeremy Powell – 2010-02-16T16:50:04.480

0

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.

philippe lhardy

Posted 2010-02-15T18:47:18.380

Reputation: 151

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.

Daniel B

Posted 2010-02-15T18:47:18.380

Reputation: 40 502