line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# SMB-Perl library, Copyright (C) 2014-2018 Mikhael Goikhman, migo@cpan.org |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
5
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
6
|
|
|
|
|
|
|
# (at your option) any later version. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11
|
|
|
|
|
|
|
# GNU General Public License for more details. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
14
|
|
|
|
|
|
|
# along with this program. If not, see . |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package SMB::v2::Command; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
1430
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
19
|
2
|
|
|
2
|
|
27
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
556
|
use parent 'SMB::Command'; |
|
2
|
|
|
|
|
369
|
|
|
2
|
|
|
|
|
10
|
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
578
|
use SMB::v2::Header; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
13
|
use if (1 << 32 == 1), 'bigint'; # support native uint64 on 32-bit platforms |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new ($$%) { |
28
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
29
|
0
|
|
0
|
|
|
0
|
my $header = shift || ''; |
30
|
0
|
|
|
|
|
0
|
my %options = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
0
|
die "Invalid sub-class $class, should be SMB::v2::Command::*" |
33
|
|
|
|
|
|
|
unless $class =~ /^SMB::v2::Command::(\w+)/; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
0
|
die "Invalid header '$header', should be isa SMB::v2::Header" |
36
|
|
|
|
|
|
|
unless $header && $header->isa('SMB::v2::Header'); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new( |
39
|
|
|
|
|
|
|
2, $1, $header, |
40
|
|
|
|
|
|
|
%options, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub abort_pack ($$) { |
47
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
48
|
0
|
|
|
|
|
0
|
my $packer = shift; |
49
|
0
|
|
|
|
|
0
|
my $status = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
$self->set_status($status); |
52
|
0
|
|
|
|
|
0
|
$packer |
53
|
|
|
|
|
|
|
->jump('status')->uint32($status) |
54
|
|
|
|
|
|
|
->jump('command-start')->uint16(9) |
55
|
|
|
|
|
|
|
; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub prepare_response ($) { |
61
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
$self->header->{flags} |= SMB::v2::Header::FLAGS_RESPONSE; |
64
|
0
|
0
|
|
|
|
0
|
$self->header->{flags} |= SMB::v2::Header::FLAGS_ASYNC_COMMAND if $self->header->aid; |
65
|
0
|
0
|
|
|
|
0
|
$self->header->credits(31) if $self->header->credits > 31; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub has_next_in_chain ($) { |
69
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
0
|
return $self->header->chain_offset ? 1 : 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub is_valid_fid ($) { |
75
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
76
|
0
|
|
|
|
|
0
|
my $fid = shift; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
0
|
|
|
0
|
return ref($fid) eq 'ARRAY' && @$fid == 2 |
79
|
|
|
|
|
|
|
&& defined $fid->[0] && $fid->[0] =~ /^\d+$/ |
80
|
|
|
|
|
|
|
&& defined $fid->[1] && $fid->[1] =~ /^\d+$/; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub is_fid_filled ($$$) { |
84
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
85
|
6
|
|
|
|
|
8
|
my $fid = shift; |
86
|
6
|
|
|
|
|
10
|
my $pattern32 = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return |
89
|
6
|
|
66
|
|
|
70
|
($fid->[0] & 0xffffffff) == $pattern32 && |
90
|
|
|
|
|
|
|
($fid->[0] >> 32) == $pattern32 && |
91
|
|
|
|
|
|
|
($fid->[1] & 0xffffffff) == $pattern32 && |
92
|
|
|
|
|
|
|
($fid->[1] >> 32) == $pattern32; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub is_fid_unset ($$) { |
96
|
3
|
|
|
3
|
0
|
18
|
my $self = shift; |
97
|
3
|
|
|
|
|
5
|
my $fid = shift; |
98
|
|
|
|
|
|
|
|
99
|
3
|
|
|
|
|
10
|
return $self->is_fid_filled($fid, 0xffffffff); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub is_fid_null ($$) { |
103
|
3
|
|
|
3
|
0
|
32
|
my $self = shift; |
104
|
3
|
|
|
|
|
6
|
my $fid = shift; |
105
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
8
|
return $self->is_fid_filled($fid, 0); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |