» Linux

Enumerating SSL Ciphers with SSLScan

Posted on by Nathan Drier 2 Comments

SSLScan

You’d think that checking your email in a web browser is a simple task. Open up Firefox, plunk in your username and password, and start sending things to the SPAM folder. The truth is, when you load up your web mail in a browser, a flurry of activity takes place behind the scenes. One of the most interesting things that happens is how your web browser interacts with your web mail server (or any SSL-enabled service) to select a encryption protocol to use. While I won’t dive too deep into the mechanics of it all, I will try to explain why it is important.

Before the mail server will send any sensitive information to your browser, they need to agree on how they will encrypt the data. This gets boiled down to your web browser and the server listing their supported ciphers, and the two parties agreeing on the strongest cipher or protocol that they both support. The key here is supported protocols.  This means that your SSL-enabled service supports a wide array of encryption ciphers and protocols so it can play nice with all sorts of different browsers and operating systems.  In a perfect world, all ciphers and protocols are created equal, but like everything else; there is good encryption and there is bad encryption.

This is where a nifty little app called SSLScan steps in. It runs against SSL-enabled services and finds out exactly which protocols and ciphers are supported by the server.  This is handy for identifying potentially weak SSL ciphers or protocols (SSLv2, low-bitstrength ciphers, NULL ciphers, etc).  It also lists preferred ciphers and details about the SSL certificates.   (If all this is nothing new to you, see The Shell Shakespeare’s post on SSL vulnerabilities – that guy could make meatloaf with nothing but emacs and a bash prompt.)

Debian users are lucky -  a version of SSLScan exists in the Squeeze repo (although its a version behind).  For everyone else, it should build easily on common systems.  I know other tools exist to enumerate SSL methods.  Most vulnerability scanners will flag weak ciphers. TSS will show you how to use OpenSSL and Bash to do it.  Does anyone have other favorites?

# ./sslscan 10.0.0.45
 _
 ___ ___| |___  ___ __ _ _ __
 / __/ __| / __|/ __/ _` | '_ \
 \__ \__ \ \__ \ (_| (_| | | | |
 |___/___/_|___/\___\__,_|_| |_|

 Version 1.8.0

http://www.titania.co.uk

 Copyright Ian Ventura-Whiting 2009

Testing SSL server 10.0.0.45 on port 443

 Supported Server Cipher(s):
 Rejected  N/A              SSLv2  168 bits  DES-CBC3-MD5
 Rejected  N/A              SSLv2  56 bits   DES-CBC-MD5
 Rejected  N/A              SSLv2  40 bits   EXP-RC2-CBC-MD5
 Rejected  N/A              SSLv2  128 bits  RC2-CBC-MD5
 Rejected  N/A              SSLv2  40 bits   EXP-RC4-MD5
 Rejected  N/A              SSLv2  128 bits  RC4-MD5
 Rejected  N/A              SSLv3  256 bits  ADH-AES256-SHA
 Accepted  SSLv3  256 bits  DHE-RSA-AES256-SHA
 Rejected  N/A              SSLv3  256 bits  DHE-DSS-AES256-SHA
 Accepted  SSLv3  256 bits  AES256-SHA
 Rejected  N/A              SSLv3  128 bits  ADH-AES128-SHA
 Accepted  SSLv3  128 bits  DHE-RSA-AES128-SHA
 Rejected  N/A              SSLv3  128 bits  DHE-DSS-AES128-SHA
 Accepted  SSLv3  128 bits  AES128-SHA
 Rejected  N/A              SSLv3  168 bits  ADH-DES-CBC3-SHA
 Rejected  N/A              SSLv3  56 bits   ADH-DES-CBC-SHA
 Rejected  N/A              SSLv3  40 bits   EXP-ADH-DES-CBC-SHA
 Rejected  N/A              SSLv3  128 bits  ADH-RC4-MD5
 Rejected  N/A              SSLv3  40 bits   EXP-ADH-RC4-MD5
 Accepted  SSLv3  168 bits  EDH-RSA-DES-CBC3-SHA
 Rejected  N/A              SSLv3  56 bits   EDH-RSA-DES-CBC-SHA
 Rejected  N/A              SSLv3  40 bits   EXP-EDH-RSA-DES-CBC-SHA
 Rejected  N/A              SSLv3  168 bits  EDH-DSS-DES-CBC3-SHA
 Rejected  N/A              SSLv3  56 bits   EDH-DSS-DES-CBC-SHA
 Rejected  N/A              SSLv3  40 bits   EXP-EDH-DSS-DES-CBC-SHA
 Accepted  SSLv3  168 bits  DES-CBC3-SHA
 Rejected  N/A              SSLv3  56 bits   DES-CBC-SHA
 Rejected  N/A              SSLv3  40 bits   EXP-DES-CBC-SHA
 Rejected  N/A              SSLv3  40 bits   EXP-RC2-CBC-MD5
 Accepted  SSLv3  128 bits  RC4-SHA
 Accepted  SSLv3  128 bits  RC4-MD5
 Rejected  N/A              SSLv3  40 bits   EXP-RC4-MD5
 Rejected  N/A              SSLv3  0 bits    NULL-SHA
 Rejected  N/A              SSLv3  0 bits    NULL-MD5
 Rejected  N/A              TLSv1  256 bits  ADH-AES256-SHA
 Accepted  TLSv1  256 bits  DHE-RSA-AES256-SHA
 Rejected  N/A              TLSv1  256 bits  DHE-DSS-AES256-SHA
 Accepted  TLSv1  256 bits  AES256-SHA
 Rejected  N/A              TLSv1  128 bits  ADH-AES128-SHA
 Accepted  TLSv1  128 bits  DHE-RSA-AES128-SHA
 Rejected  N/A              TLSv1  128 bits  DHE-DSS-AES128-SHA
 Accepted  TLSv1  128 bits  AES128-SHA
 Rejected  N/A              TLSv1  168 bits  ADH-DES-CBC3-SHA
 Rejected  N/A              TLSv1  56 bits   ADH-DES-CBC-SHA
 Rejected  N/A              TLSv1  40 bits   EXP-ADH-DES-CBC-SHA
 Rejected  N/A              TLSv1  128 bits  ADH-RC4-MD5
 Rejected  N/A              TLSv1  40 bits   EXP-ADH-RC4-MD5
 Accepted  TLSv1  168 bits  EDH-RSA-DES-CBC3-SHA
 Rejected  N/A              TLSv1  56 bits   EDH-RSA-DES-CBC-SHA
 Rejected  N/A              TLSv1  40 bits   EXP-EDH-RSA-DES-CBC-SHA
 Rejected  N/A              TLSv1  168 bits  EDH-DSS-DES-CBC3-SHA
 Rejected  N/A              TLSv1  56 bits   EDH-DSS-DES-CBC-SHA
 Rejected  N/A              TLSv1  40 bits   EXP-EDH-DSS-DES-CBC-SHA
 Accepted  TLSv1  168 bits  DES-CBC3-SHA
 Rejected  N/A              TLSv1  56 bits   DES-CBC-SHA
 Rejected  N/A              TLSv1  40 bits   EXP-DES-CBC-SHA
 Rejected  N/A              TLSv1  40 bits   EXP-RC2-CBC-MD5
 Accepted  TLSv1  128 bits  RC4-SHA
 Accepted  TLSv1  128 bits  RC4-MD5
 Rejected  N/A              TLSv1  40 bits   EXP-RC4-MD5
 Rejected  N/A              TLSv1  0 bits    NULL-SHA
 Rejected  N/A              TLSv1  0 bits    NULL-MD5

 Prefered Server Cipher(s):
 SSLv3  256 bits  DHE-RSA-AES256-SHA
 TLSv1  256 bits  DHE-RSA-AES256-SHA
...

Simple Network Management Protocol – SNMPv3

Posted on by Nathan Drier 1 Comment

SNMP, or Simple Network Management Protocol, has been the go-to management protocol of choice for years. As its name declares, it is a simple and efficient way to monitor hosts. Most everything is SNMP capable these days, from servers to switches, and from firewalls to routers. Even most UPS’s and A/C units have it built in. Most installs of SNMP default to SNMPv2, which is dated technology. In 2004, SNMPv3 was introduced as a replacement for v2, touting increased security and better remote configuration. In an SNMPv2 setup, community strings (passwords) and data float by in plain text, allowing anyone in the right spot on the network to capture them. Once you have the community strings, you can query devices for information (and possibly make configuration changes!). SNMPv3 solves this problem by protecting the authentication handshake, and then encrypting all the SNMP data as it crosses the network.

In this quick how-to, I’ll show you how to setup SNMPv3 on a generic Debian Linux machine.

First, grab the snmpd package from apt:

 aptitude install snmpd

Right after SNMPD pulls down its dependencies and installs, stop the daemon:

 /etc/init.d/snmpd stop

Then we need to make a few configuration changes. For security reasons, SNMP only listens on the localhost interface by default. In order to monitor this Linux box remotely, we need to open that up. Crack open /etc/defaults/snmpd and edit the following line:

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

to read

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'

Now we need to disable the default SNMPv2, and create a SNMPv3 user. Open up /etc/snmp/snmpd.conf and scroll down and comment out all the lines starting with com2sec in this section:

#       sec.name  source          community
#com2sec paranoid  default         public
#com2sec readonly  default         public
#com2sec readwrite default         private

Since we just ‘disabled’ SNMPv2, we need to enable v3 and create a user. Use the command line utility, net-snmp-config to help to create a SNMPv3 user:

net-snmp-config --create-snmpv3-user -ro -A sadWFqeq3421 -X fferlGq5247 -a SHA -x  AES snmpv3user
 
-ro is read-only user
-A sadWFqeq3421 is the authentication passphrase
-X fferlGq5247 is the privacy passphrase
-a SHA is how the authentication passphrase will be stored (MD5 or SHA)
-x MD5 is how the SNMP data will be encrypted during transit (DES or AES)
snmpv3user is the name of our new user

And if the command went ok, the output should look like this:

adding the following line to /var/lib/snmp/snmpd.conf:
createUser snmpv3user SHA "sadWFqeq3421" AES fferlGq5247
adding the following line to /usr/share/snmp/snmpd.conf:
rouser snmpv3user

Lets start up the SNMPD service again:

/etc/init.d/snmpd start

Lets do a quick test to make sure it all worked ok. From another machine with SNMP installed, we can issue a command like the following to query the remote Debian machine, with our new SNMPv3 user, to check the amount of ram installed:

snmpget -v 3 -u snmpv3user -l AuthPriv -x AES -a SHA -X fferlGq5247 -A sadWFqeq3421 10.0.0.45 1.3.6.1.4.1.2021.4.5.0
 
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 516528 kB

Looks like it all went well! The output of the last command shows that the machine has 516,528 kB of RAM. For some added security, you can ACL the SNMP service to your query server with some quick iptables rules. These allow ssh from anywhere, SNMP from 10.0.0.42 (your query server) and established connections. Everything else gets dropped:

iptables -I INPUT 1 -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 10.0.0.42/32 -p udp -m udp --dport 161 -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -j DROP

With a SNMPv3 setup, the authentication process and PDU’s (SNMP data) should be encrypted. No more ‘public’ community strings floating by in plain text. The best way to query those SNMP clients is to use a network management application (Cacti is free and a Redspin favorite).

Cacti-Graph
Happy Graphing!