Nmap Development mailing list archives

[NSE] HUGE ssl-enum-ciphers speed improvement


From: Daniel Miller <bonsaiviking () gmail com>
Date: Thu, 12 Jul 2012 16:37:56 -0500

List,

I've found a way to vastly improve the speed and efficiency of the ssl-enum-ciphers by letting the server choose ciphers instead of trying every single one. First, the numbers, based on a scan of nmap.org, port 443. Before: 858 Client Hello messages, 9.56s NSE time. After: 24 Client Hello messages, 3.07s NSE time.

Previously, the script took this algorithm: For each of the 4 protocol versions (SSLv3, TLSv1.0, TLSv1.1, TLSv1.2), start 213 threads, one for each Cipher Suite. When all threads for one protocol have finished, process them. If the protocol was not supported, discard results. If at least one Cipher Suite was supported, do the same thing for the 3 compressors. Besides the primary improvement, this means 212 extra connections per unsupported protocol (since support for the protocol should be detectable in one connection).

The SSL protocol allows clients to specify up to 2^16-1 cipher suites in one Client Hello, and the server must choose one that it supports. I chose to reimplement the script to remove the one suite chosen by the server and retry. If the server supports 7 cipher suites, then the 8th Client Hello will be rejected, and the script can stop trying. To retain some of the multithreading benefits, I chose to implement each protocol in a separate thread, retaining a linear execution within each protocol. This lets me evaluate after each Hello whether to keep trying or to finish.

One oddity popped up with this method: https://nmap.org/ appears to support the DEFLATE compressor, but the existing ssl-enum-ciphers doesn't detect it. Wireshark clearly shows the server responding with the DEFLATE method chosen. A possible explanation is this line from RFC 6101 (SSLv3): "All implementations must support CompressionMethod.null." If a Client Hello is sent with only DEFLATE or LZS, then it is not compliant, and is rejected (speculation!).

New script and patch attached. Testing appreciated!

Dan

Attachment: ssl-enum-ciphers.patch
Description:

Attachment: ssl-enum-ciphers.nse
Description:

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: