line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Parser.pm 302 2009-11-21 02:31:24Z jabra $ |
2
|
|
|
|
|
|
|
package Fierce::Parser; |
3
|
|
|
|
|
|
|
{ |
4
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
5
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
6
|
|
|
|
|
|
|
|
7
|
12
|
|
|
12
|
|
73925
|
use Object::InsideOut; |
|
12
|
|
|
|
|
1126115
|
|
|
12
|
|
|
|
|
90
|
|
8
|
12
|
|
|
12
|
|
14309
|
use Fierce::Parser::Session; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @session : Field : Arg(session) : Get(session) : |
10
|
|
|
|
|
|
|
Type(Fierce::Parser::Session); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# parse_file |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Input: |
15
|
|
|
|
|
|
|
# argument - self obj - |
16
|
|
|
|
|
|
|
# argument - xml scalar |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# Ouptut: |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
sub parse_file { |
21
|
|
|
|
|
|
|
my ( $self, $file ) = @_; |
22
|
|
|
|
|
|
|
my $parser = XML::LibXML->new(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $doc = $parser->parse_file($file); |
25
|
|
|
|
|
|
|
return Fierce::Parser->new( |
26
|
|
|
|
|
|
|
session => Fierce::Parser::Session->parse( $parser, $doc ) ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub parse_scan { |
30
|
|
|
|
|
|
|
my ( $self, $args, @domains ) = @_; |
31
|
|
|
|
|
|
|
my $FH; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ( $args =~ /-format/i ) { |
34
|
|
|
|
|
|
|
die |
35
|
|
|
|
|
|
|
"[Fierce::Parser] Cannot pass option '-format ' to parse_scan()"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ( $args =~ /-output/i ) { |
39
|
|
|
|
|
|
|
die |
40
|
|
|
|
|
|
|
"[Fierce::Parser] Cannot pass option '-output ' to parse_scan()"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $cmd = "fierce -format xml $args -dns " . ( join ',', @domains ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#print "$cmd\n"; |
46
|
|
|
|
|
|
|
open $FH, "$cmd |" |
47
|
|
|
|
|
|
|
|| die "[Fierce::Parser] Could not perform nikto scan - $!"; |
48
|
|
|
|
|
|
|
my $p = XML::LibXML->new(); |
49
|
|
|
|
|
|
|
my $doc = $p->parse_fh($FH); |
50
|
|
|
|
|
|
|
my $parser = Fierce::Parser->new( |
51
|
|
|
|
|
|
|
session => Fierce::Parser::Session->parse( $p, $doc ) ); |
52
|
|
|
|
|
|
|
close $FH; |
53
|
|
|
|
|
|
|
return $parser; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_session { |
57
|
|
|
|
|
|
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
return $self->session; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_node { |
62
|
|
|
|
|
|
|
my ( $self, $domain ) = @_; |
63
|
|
|
|
|
|
|
return $self->session->domainscandetails->get_host_hostname($domain); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_all_nodes { |
67
|
|
|
|
|
|
|
my ($self) = @_; |
68
|
|
|
|
|
|
|
my @all_hosts = $self->session->domainscandetails->all_hosts(); |
69
|
|
|
|
|
|
|
return @all_hosts; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|