| 1 | # | ||
| 2 | # $Id$ | ||
| 3 | # | ||
| 4 | # audit::https Brik | ||
| 5 | # | ||
| 6 | package Metabrik::Audit::Https; | ||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use base qw(Metabrik::Shell::Command); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | sub brik_properties { | ||
| 13 | return { | ||
| 14 | revision => '$Revision$', | ||
| 15 | tags => [ qw(unstable ssl openssl) ], | ||
| 16 | author => 'GomoR <GomoR[at]metabrik.org>', | ||
| 17 | license => 'http://opensource.org/licenses/BSD-3-Clause', | ||
| 18 | attributes => { | ||
| 19 | uri => [ qw(uri) ], | ||
| 20 | }, | ||
| 21 | commands => { | ||
| 22 | check_ssl3_support => [ qw(uri|OPTIONAL) ], | ||
| 23 | }, | ||
| 24 | require_modules => { | ||
| 25 | 'Metabrik::String::Uri' => [ ], | ||
| 26 | }, | ||
| 27 | require_binaries => { | ||
| 28 | 'printf' => [ ], | ||
| 29 | 'openssl' => [ ], | ||
| 30 | }, | ||
| 31 | }; | ||
| 32 | } | ||
| 33 | |||
| 34 | # | ||
| 35 | # Poodle: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | ||
| 36 | # | ||
| 37 | sub check_ssl3_support { | ||
| 38 | my $self = shift; | ||
| 39 | my ($uri) = @_; | ||
| 40 | |||
| 41 | $uri ||= $self->uri; | ||
| 42 | $self->brik_help_run_undef_arg('check_ssl3_support', $uri) or return; | ||
| 43 | |||
| 44 | if ($uri !~ /^https:\/\//) { | ||
| 45 | return $self->log->error("check_ssl3_support: uri [$uri] invalid format"); | ||
| 46 | } | ||
| 47 | |||
| 48 | my $su = Metabrik::String::Uri->new_from_brik_init($self) or return; | ||
| 49 | |||
| 50 | my $hash = $su->parse($uri) or return; | ||
| 51 | |||
| 52 | my $host = $hash->{host}; | ||
| 53 | my $port = $hash->{port}; | ||
| 54 | |||
| 55 | my $cmd = "printf \"GET / HTTP/1.0\r\n\r\n\" | openssl s_client -host $host -port $port -ssl3"; | ||
| 56 | |||
| 57 | $self->as_array(1); | ||
| 58 | $self->as_matrix(0); | ||
| 59 | $self->capture_stderr(1); | ||
| 60 | my $buf = $self->capture($cmd) or return; | ||
| 61 | |||
| 62 | my $check = { | ||
| 63 | ssl_version3_support => 1, | ||
| 64 | cmd => $cmd, | ||
| 65 | raw => $buf, | ||
| 66 | }; | ||
| 67 | for (@$buf) { | ||
| 68 | if (/sslv3 alert handshake failure/s) { | ||
| 69 | $check->{ssl_version3_support} = 0; | ||
| 70 | last; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | return $check; | ||
| 75 | } | ||
| 76 | |||
| 77 | 1; | ||
| 78 | |||
| 79 | __END__ | ||