Skip to content

Commit 246977e

Browse files
David MaloneyDavid Maloney
authored andcommitted
Address openssl sslv2 issues
Debian/Ubuntu ship openssl without sslv2 compiled in. we now check for this ahead of time
1 parent 12201c5 commit 246977e

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/rex/sslscan/result.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
module Rex::SSLScan
66
class Result
77

8+
attr_accessor :sslv2
9+
810
attr_reader :ciphers
911
attr_reader :supported_versions
1012

@@ -197,6 +199,7 @@ def to_s
197199
if @cert
198200
text <<" \n\n #{@cert.to_text}"
199201
end
202+
text << "\n\n *** WARNING: Your OS hates freedom! Your OpenSSL libs are compiled without SSLv2 support!"
200203
text
201204
end
202205
end

lib/rex/sslscan/scanner.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Scanner
1111
attr_accessor :timeout
1212

1313
attr_reader :supported_versions
14+
attr_reader :sslv2
1415

1516
# Initializes the scanner object
1617
# @param host [String] IP address or hostname to scan
@@ -22,7 +23,13 @@ def initialize(host,port = 443,context = {},timeout=5)
2223
@port = port
2324
@timeout = timeout
2425
@context = context
25-
@supported_versions = [:SSLv2, :SSLv3, :TLSv1]
26+
if check_opensslv2
27+
@supported_versions = [:SSLv2, :SSLv3, :TLSv1]
28+
@sslv2 = true
29+
else
30+
@supported_versions = [:SSLv3, :TLSv1]
31+
@sslv2 = false
32+
end
2633
raise StandardError, "The scanner configuration is invalid" unless valid?
2734
end
2835

@@ -44,7 +51,7 @@ def valid?
4451
# @return [Result] object containing the details of the scan
4552
def scan
4653
scan_result = Rex::SSLScan::Result.new
47-
54+
scan_result.sslv2 = sslv2
4855
# If we can't get any SSL connection, then don't bother testing
4956
# individual ciphers.
5057
if test_ssl == :rejected and test_tls == :rejected
@@ -181,5 +188,14 @@ def validate_params(ssl_version, cipher)
181188
end
182189
end
183190

191+
def check_opensslv2
192+
begin
193+
OpenSSL::SSL::SSLContext.new(:SSLv2)
194+
rescue
195+
return false
196+
end
197+
return true
198+
end
199+
184200
end
185201
end

spec/lib/rex/sslscan/result_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,16 @@
456456
end
457457
end
458458

459+
context "when OpenSSL is compiled without SSLv2" do
460+
before(:each) do
461+
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
462+
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
463+
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
464+
subject.sslv2 = false
465+
end
466+
it "should warn the user" do
467+
subject.to_s.should include "*** WARNING: Your OS hates freedom! Your OpenSSL libs are compiled without SSLv2 support!"
468+
end
469+
end
470+
459471
end

0 commit comments

Comments
 (0)