line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# identify::ssh Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Identify::Ssh; |
7
|
1
|
|
|
1
|
|
505
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
528
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
banner => [ qw(string) ], |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
commands => { |
22
|
|
|
|
|
|
|
parsebanner => [ qw(banner|OPTIONAL) ], |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub parsebanner { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
|
|
|
|
|
my ($banner) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
0
|
|
|
|
$banner ||= $self->banner; |
32
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('parsebanner', $banner) or return; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# From most specific to less specific |
35
|
0
|
|
|
|
|
|
my $data = [ |
36
|
|
|
|
|
|
|
[ |
37
|
|
|
|
|
|
|
'^SSH-(\d+\.\d+)-OpenSSH_(\d+\.\d+\.\d+)(p\d+) Ubuntu-(2ubuntu2)$' => { |
38
|
|
|
|
|
|
|
ssh_protocol_version => '$1', |
39
|
|
|
|
|
|
|
ssh_product_version => '$2', |
40
|
|
|
|
|
|
|
ssh_product_feature_portable => '$3', |
41
|
|
|
|
|
|
|
ssh_os_distribution_version => '$4', |
42
|
|
|
|
|
|
|
ssh_product => 'OpenSSH', |
43
|
|
|
|
|
|
|
ssh_os => 'Linux', |
44
|
|
|
|
|
|
|
ssh_os_distribution => 'Ubuntu', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
], |
47
|
|
|
|
|
|
|
[ |
48
|
|
|
|
|
|
|
'^SSH-(\d+\.\d+)-OpenSSH_(\d+\.\d+)_(\S+) (\S+)$' => { |
49
|
|
|
|
|
|
|
ssh_protocol_version => '$1', |
50
|
|
|
|
|
|
|
ssh_product_version => '$2', |
51
|
|
|
|
|
|
|
ssh_product_feature_portable => '$3', |
52
|
|
|
|
|
|
|
ssh_product => 'OpenSSH', |
53
|
|
|
|
|
|
|
ssh_extra => '$4', |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
], |
56
|
|
|
|
|
|
|
[ |
57
|
|
|
|
|
|
|
'^SSH-(\d+\.\d+)(.*)$' => { |
58
|
|
|
|
|
|
|
ssh_protocol_version => '$1', |
59
|
|
|
|
|
|
|
ssh_product => 'undef', |
60
|
|
|
|
|
|
|
ssh_extra => '$2', |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
], |
63
|
|
|
|
|
|
|
]; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $result = {}; |
66
|
0
|
|
|
|
|
|
for my $elt (@$data) { |
67
|
0
|
|
|
|
|
|
my $re = $elt->[0]; |
68
|
0
|
|
|
|
|
|
my $info = $elt->[1]; |
69
|
0
|
0
|
|
|
|
|
if ($banner =~ /$re/) { |
70
|
0
|
|
|
|
|
|
for my $k (keys %$info) { |
71
|
0
|
|
0
|
|
|
|
$result->{$k} = eval($info->{$k}) || $info->{$k}; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
|
last; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $result; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |