line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# network::zmap Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Network::Zmap; |
7
|
1
|
|
|
1
|
|
708
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
551
|
|
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
|
|
|
|
|
|
|
datadir => [ qw(datadir) ], |
20
|
|
|
|
|
|
|
device => [ qw(device) ], |
21
|
|
|
|
|
|
|
bandwidth => [ qw(bps) ], |
22
|
|
|
|
|
|
|
rate => [ qw(pps) ], |
23
|
|
|
|
|
|
|
max_targets => [ qw(count) ], |
24
|
|
|
|
|
|
|
max_results => [ qw(count) ], |
25
|
|
|
|
|
|
|
max_runtime => [ qw(seconds) ], |
26
|
|
|
|
|
|
|
probes => [ qw(count) ], |
27
|
|
|
|
|
|
|
cooldown_time => [ qw(seconds) ], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
attributes_default => { |
30
|
|
|
|
|
|
|
bandwidth => '4M', # 4 Mbps, 512 kBps |
31
|
|
|
|
|
|
|
probes => 1, |
32
|
|
|
|
|
|
|
cooldown_time => 8, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
commands => { |
35
|
|
|
|
|
|
|
install => [ ], # Inherited |
36
|
|
|
|
|
|
|
scan => [ qw(port output|OPTIONAL device|OPTIONAL) ], |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
require_binaries => { |
39
|
|
|
|
|
|
|
zmap => [ ], |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
need_packages => { |
42
|
|
|
|
|
|
|
ubuntu => [ qw(zmap) ], |
43
|
|
|
|
|
|
|
debian => [ qw(zmap) ], |
44
|
|
|
|
|
|
|
kali => [ qw(zmap) ], |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub brik_use_properties { |
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return { |
53
|
0
|
|
0
|
|
|
|
attributes_default => { |
54
|
|
|
|
|
|
|
device => defined($self->global) && $self->global->device || 'eth0', |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub scan { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my ($port, $output, $device) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
0
|
|
|
|
$device ||= $self->device; |
64
|
0
|
|
0
|
|
|
|
$output ||= '-'; |
65
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('scan', $port) or return; |
66
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('scan', $output) or return; |
67
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('scan', $device) or return; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $bandwidth = $self->bandwidth; |
70
|
0
|
|
|
|
|
|
my $rate = $self->rate; |
71
|
0
|
|
|
|
|
|
my $max_targets = $self->max_targets; |
72
|
0
|
|
|
|
|
|
my $max_runtime = $self->max_runtime; |
73
|
0
|
|
|
|
|
|
my $max_results = $self->max_results; |
74
|
0
|
|
|
|
|
|
my $cooldown_time = $self->cooldown_time; |
75
|
0
|
|
|
|
|
|
my $probes = $self->probes; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $cmd = "zmap -p $port -i $device -o \"$output\" -P $probes -c $cooldown_time"; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if (defined($max_targets)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$cmd .= " -n $max_targets"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif (defined($max_results)) { |
83
|
0
|
|
|
|
|
|
$cmd .= " -N $max_results"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif (defined($max_runtime)) { |
86
|
0
|
|
|
|
|
|
$cmd .= " -t $max_runtime"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if (defined($rate)) { |
|
|
0
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$cmd .= " -r $rate"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
elsif (defined($bandwidth)) { |
93
|
0
|
|
|
|
|
|
$cmd .= " -B $bandwidth"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$self->log->verbose("scan: zmap[$cmd]"); |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $self->sudo_system($cmd); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |