Network/Nikto.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Network/Netbios.pm ↑ Summary Network/Nmap.pm »
1 #
2 # $Id$
3 #
4 # network::nikto Brik
5 #
6 package Metabrik::Network::Nikto;
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::System::Package);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable security scanner vulnerability vuln scan) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 attributes => {
19 datadir => [ qw(datadir) ],
20 uri => [ qw(uri) ],
21 args => [ qw(nikto_arguments) ],
22 output => [ qw(output_file.html) ],
23 },
24 attributes_default => {
25 uri => 'http://127.0.0.1/',
26 args => '-Display V -Format html',
27 output => 'last.html',
28 },
29 commands => {
30 install => [ ], # Inherited
31 start => [ qw(uri|OPTIONAL) ],
32 },
33 require_modules => {
34 'Metabrik::String::Uri' => [ ],
35 },
36 require_binaries => {
37 'nikto' => [ ],
38 },
39 need_packages => {
40 ubuntu => [ qw(nikto) ],
41 debian => [ qw(nikto) ],
42 kali => [ qw(nikto) ],
43 },
44 };
45 }
46  
47 sub _nikto_parse {
48 my $self = shift;
49 my ($cmd, $result) = @_;
50  
51 my $parsed = {};
52  
53 push @{$parsed->{raw}}, $cmd;
54  
55 for (split(/\n/, $result)) {
56 push @{$parsed->{raw}}, $_;
57 }
58  
59 return $parsed;
60 }
61  
62 # nikto -host XXX.com -root /XXX -Display V -port 443 -ssl -Format html -output /root/XXX/outil_nikto/XXX_nikto_https.html 2>&1 | tee /root/XXX/outil_nikto/XXX_nikto_https.txt
63 # nikto -host 127.0.0.1 -port 80 -root /path -Display V -Format html -ssl -output /home/gomor/metabrik/nikto.html
64 sub start {
65 my $self = shift;
66 my ($uri, $output) = @_;
67  
68 $output ||= $self->output;
69 $uri ||= $self->uri;
70 $self->brik_help_run_undef_arg('start', $uri) or return;
71  
72 my $su = Metabrik::String::Uri->new_from_brik_init($self) or return;
73 my $p = $su->parse($uri) or return;
74  
75 my $host = $p->{host};
76 my $port = $p->{port};
77 my $path = $p->{path};
78 my $use_ssl = $su->is_https_scheme($p);
79  
80 my $args = $self->args;
81  
82 my $datadir = $self->datadir;
83
84 my $cmd = "nikto -host $host -port $port -root $path $args";
85 if ($use_ssl) {
86 $cmd .= " -ssl";
87 }
88  
89 $cmd .= " -output $datadir/$output 2>&1 | tee $datadir/$output.txt";
90  
91 my $result = `$cmd`;
92  
93 my $parsed = $self->_nikto_parse($cmd, $result);
94  
95 return $parsed;
96 }
97  
98 1;
99  
100 __END__
« Network/Netbios.pm ↑ Summary Network/Nmap.pm »