line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Fast.pm 34 2015-02-20 06:16:17Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Write::Fast; |
5
|
3
|
|
|
3
|
|
10551
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
6
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
102
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
25
|
use base qw(Exporter DynaLoader); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
657
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
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
|
|
2276
|
use Time::Interval; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub estimate_runtime { |
34
|
|
|
|
|
|
|
my ($info) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if (! defined($info)) { |
37
|
|
|
|
|
|
|
print STDERR "[-] estimate_runtime: give HASHREF\n"; |
38
|
|
|
|
|
|
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
if (! exists($info->{ports}) |
42
|
|
|
|
|
|
|
|| ! exists($info->{targets}) |
43
|
|
|
|
|
|
|
|| ! exists($info->{try}) |
44
|
|
|
|
|
|
|
|| ! exists($info->{pps})) { |
45
|
|
|
|
|
|
|
print STDERR "[-] estimate_runtime: info HASHREF not complete\n"; |
46
|
|
|
|
|
|
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $nports = scalar(@{$info->{ports}}); |
50
|
|
|
|
|
|
|
my $nhosts = scalar(@{$info->{targets}}); |
51
|
|
|
|
|
|
|
my $try = $info->{try}; |
52
|
|
|
|
|
|
|
my $pps = $info->{pps}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $estim = Time::Interval::parseInterval( |
55
|
|
|
|
|
|
|
seconds => $try * $nports * $nhosts / $pps, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return { |
59
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my ($info) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if (! defined($info)) { |
71
|
|
|
|
|
|
|
print STDERR "[-] runtime_as_string: give HASHREF\n"; |
72
|
|
|
|
|
|
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if (! exists($info->{days}) |
76
|
|
|
|
|
|
|
|| ! exists($info->{hours}) |
77
|
|
|
|
|
|
|
|| ! exists($info->{minutes}) |
78
|
|
|
|
|
|
|
|| ! exists($info->{seconds}) |
79
|
|
|
|
|
|
|
|| ! exists($info->{nhosts})) { |
80
|
|
|
|
|
|
|
print STDERR "[-] runtime_as_string: info HASHREF not complete\n"; |
81
|
|
|
|
|
|
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
return $string; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |