line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Fast.pm 39 2015-02-21 10:32:40Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Write::Fast; |
5
|
3
|
|
|
3
|
|
10105
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
90
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
79
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
18
|
use base qw(Exporter DynaLoader); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
516
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->bootstrap($VERSION); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
consts => [qw( |
16
|
|
|
|
|
|
|
)], |
17
|
|
|
|
|
|
|
subs => [qw( |
18
|
|
|
|
|
|
|
estimate_runtime |
19
|
|
|
|
|
|
|
runtime_as_string |
20
|
|
|
|
|
|
|
)], |
21
|
|
|
|
|
|
|
vars => [qw( |
22
|
|
|
|
|
|
|
)], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
26
|
|
|
|
|
|
|
@{$EXPORT_TAGS{vars}}, |
27
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
28
|
|
|
|
|
|
|
@{$EXPORT_TAGS{subs}}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
3
|
|
1336
|
use Time::Interval; |
|
3
|
|
|
|
|
3059
|
|
|
3
|
|
|
|
|
1026
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub estimate_runtime { |
34
|
0
|
|
|
0
|
1
|
|
my ($info) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if (! defined($info)) { |
37
|
0
|
|
|
|
|
|
print STDERR "[-] estimate_runtime: give HASHREF\n"; |
38
|
0
|
|
|
|
|
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
0
|
|
|
|
if (! exists($info->{ports}) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
42
|
|
|
|
|
|
|
|| ! exists($info->{targets}) |
43
|
|
|
|
|
|
|
|| ! exists($info->{try}) |
44
|
|
|
|
|
|
|
|| ! exists($info->{pps})) { |
45
|
0
|
|
|
|
|
|
print STDERR "[-] estimate_runtime: info HASHREF not complete\n"; |
46
|
0
|
|
|
|
|
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $nports = scalar(@{$info->{ports}}); |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $nhosts = scalar(@{$info->{targets}}); |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $try = $info->{try}; |
52
|
0
|
|
|
|
|
|
my $pps = $info->{pps}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $estim = Time::Interval::parseInterval( |
55
|
|
|
|
|
|
|
seconds => $try * $nports * $nhosts / $pps, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return { |
59
|
0
|
|
|
|
|
|
days => $estim->{days}, |
60
|
|
|
|
|
|
|
hours => $estim->{hours}, |
61
|
|
|
|
|
|
|
minutes => $estim->{minutes}, |
62
|
|
|
|
|
|
|
seconds => $estim->{seconds}, |
63
|
|
|
|
|
|
|
nhosts => $nhosts, |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub runtime_as_string { |
68
|
0
|
|
|
0
|
1
|
|
my ($info) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if (! defined($info)) { |
71
|
0
|
|
|
|
|
|
print STDERR "[-] runtime_as_string: give HASHREF\n"; |
72
|
0
|
|
|
|
|
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
|
if (! exists($info->{days}) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
76
|
|
|
|
|
|
|
|| ! exists($info->{hours}) |
77
|
|
|
|
|
|
|
|| ! exists($info->{minutes}) |
78
|
|
|
|
|
|
|
|| ! exists($info->{seconds}) |
79
|
|
|
|
|
|
|
|| ! exists($info->{nhosts})) { |
80
|
0
|
|
|
|
|
|
print STDERR "[-] runtime_as_string: info HASHREF not complete\n"; |
81
|
0
|
|
|
|
|
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $string = sprintf( |
85
|
|
|
|
|
|
|
"Estimated runtime: %d day(s) %d hour(s) %d minute(s) %d second(s) for %d host(s)", |
86
|
|
|
|
|
|
|
$info->{days}, |
87
|
|
|
|
|
|
|
$info->{hours}, |
88
|
|
|
|
|
|
|
$info->{minutes}, |
89
|
|
|
|
|
|
|
$info->{seconds}, |
90
|
|
|
|
|
|
|
$info->{nhosts}, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return $string; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |