| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: ScanDetails.pm 134 2009-10-16 18:21:38Z jabra $ |
|
2
|
|
|
|
|
|
|
package Sslscan::Parser::ScanDetails; |
|
3
|
|
|
|
|
|
|
{ |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
5
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2764
|
use Object::InsideOut; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
1
|
|
|
1
|
|
544
|
use XML::LibXML; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Sslscan::Parser::Host; |
|
10
|
|
|
|
|
|
|
use Sslscan::Parser::Host::Port; |
|
11
|
|
|
|
|
|
|
use Sslscan::Parser::Host::Port::Cipher; |
|
12
|
|
|
|
|
|
|
my @hosts : Field : Arg(hosts) : Get(hosts) : Type(List(Sslscan::Parser::Host)); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
|
15
|
|
|
|
|
|
|
my ( $self, $parser, $doc ) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $xpc = XML::LibXML::XPathContext->new($doc); |
|
18
|
|
|
|
|
|
|
my @hosts; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
foreach my $h ( $xpc->findnodes('//document/ssltest') ) { |
|
21
|
|
|
|
|
|
|
my $ip = $h->getAttribute('host'); |
|
22
|
|
|
|
|
|
|
my @ports; |
|
23
|
|
|
|
|
|
|
my $host = Sslscan::Parser::Host->new( |
|
24
|
|
|
|
|
|
|
ip => $ip, |
|
25
|
|
|
|
|
|
|
ports => \@ports, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
foreach my $scandetail ( |
|
29
|
|
|
|
|
|
|
$xpc->findnodes( |
|
30
|
|
|
|
|
|
|
'//document/ssltest[@host="' . $ip . '"]' |
|
31
|
|
|
|
|
|
|
) |
|
32
|
|
|
|
|
|
|
) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
|
|
|
|
|
|
my $port = $scandetail->getAttribute('port'); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @ciphers; |
|
37
|
|
|
|
|
|
|
#my @default_ciphers; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
foreach my $i ( $doc->getElementsByTagName('cipher') ) { |
|
40
|
|
|
|
|
|
|
my $status = $i->getAttribute('status'); |
|
41
|
|
|
|
|
|
|
my $sslversion = $i->getAttribute('sslversion'); |
|
42
|
|
|
|
|
|
|
my $bits = $i->getAttribute('bits'); |
|
43
|
|
|
|
|
|
|
my $cipher = $i->getAttribute('cipher'); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $cipher_obj = Sslscan::Parser::Host::Port::Cipher->new( |
|
46
|
|
|
|
|
|
|
status => $status, |
|
47
|
|
|
|
|
|
|
sslversion => $sslversion, |
|
48
|
|
|
|
|
|
|
bits => $bits, |
|
49
|
|
|
|
|
|
|
cipher => $cipher, |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
push( @ciphers, $cipher_obj ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $objport = Sslscan::Parser::Host::Port->new( |
|
56
|
|
|
|
|
|
|
port => $port, |
|
57
|
|
|
|
|
|
|
ciphers => \@ciphers, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
push( @ports, $objport ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$host->ports( \@ports ); |
|
63
|
|
|
|
|
|
|
push( @hosts, $host ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return Sslscan::Parser::ScanDetails->new( hosts => \@hosts ); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get_host_ip { |
|
70
|
|
|
|
|
|
|
my ( $self, $ip ) = @_; |
|
71
|
|
|
|
|
|
|
my @hosts = grep( $_->ip eq $ip, @{ $self->hosts } ); |
|
72
|
|
|
|
|
|
|
return $hosts[0]; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_host_hostname { |
|
76
|
|
|
|
|
|
|
my ( $self, $hostname ) = @_; |
|
77
|
|
|
|
|
|
|
my @hosts = grep( $_->hostname eq $hostname, @{ $self->hosts } ); |
|
78
|
|
|
|
|
|
|
return $hosts[0]; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub all_hosts { |
|
82
|
|
|
|
|
|
|
my ($self) = @_; |
|
83
|
|
|
|
|
|
|
my @hosts = @{ $self->hosts }; |
|
84
|
|
|
|
|
|
|
return @hosts; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub print_hosts { |
|
88
|
|
|
|
|
|
|
my ($self) = @_; |
|
89
|
|
|
|
|
|
|
foreach my $host ( @{ $self->hosts } ) { |
|
90
|
|
|
|
|
|
|
print "IP: " . $host->ip . "\n"; |
|
91
|
|
|
|
|
|
|
print "Hostname: " . $host->hostname . "\n"; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
1; |