| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# SMB Perl library, Copyright (C) 2014 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::SessionSetup; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
use parent 'SMB::v2::Command'; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
5
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init ($) { |
|
24
|
0
|
|
|
0
|
0
|
|
$_[0]->set( |
|
25
|
|
|
|
|
|
|
flags => 0, |
|
26
|
|
|
|
|
|
|
security_mode => 0, |
|
27
|
|
|
|
|
|
|
capabilities => 0, |
|
28
|
|
|
|
|
|
|
prev_session_id => 0, |
|
29
|
|
|
|
|
|
|
security_buffer => undef, |
|
30
|
|
|
|
|
|
|
) |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub parse ($$%) { |
|
34
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
35
|
0
|
|
|
|
|
|
my $parser = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
|
38
|
0
|
|
|
|
|
|
$parser->uint16; # session flags |
|
39
|
0
|
|
|
|
|
|
my $offset = $parser->uint16; |
|
40
|
0
|
|
|
|
|
|
my $length = $parser->uint16; |
|
41
|
0
|
|
|
|
|
|
$self->security_buffer($parser->bytes($length)); |
|
42
|
|
|
|
|
|
|
} else { |
|
43
|
0
|
|
|
|
|
|
$self->flags($parser->uint8); |
|
44
|
0
|
|
|
|
|
|
$self->security_mode($parser->uint8); |
|
45
|
0
|
|
|
|
|
|
$self->capabilities($parser->uint32); |
|
46
|
0
|
|
|
|
|
|
$parser->uint32; # channel |
|
47
|
0
|
|
|
|
|
|
my $offset = $parser->uint16; |
|
48
|
0
|
|
|
|
|
|
my $length = $parser->uint16; |
|
49
|
0
|
|
|
|
|
|
$self->prev_session_id($parser->uint64); |
|
50
|
0
|
|
|
|
|
|
$self->security_buffer($parser->bytes($length)); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub prepare_response ($) { |
|
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->SUPER::prepare_response; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
0
|
|
|
|
my $more_processing = $self->security_buffer && length($self->security_buffer) > 70; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$self->set_status(SMB::STATUS_MORE_PROCESSING_REQUIRED) if $more_processing; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
$self->header->uid(int(rand(999999)) + 1) unless $self->header->uid; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub pack ($$) { |
|
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
my $packer = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $security_buffer = $self->security_buffer; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
|
75
|
0
|
0
|
|
|
|
|
$security_buffer |
|
76
|
|
|
|
|
|
|
or return $self->abort_pack($packer, SMB::STATUS_LOGON_FAILURE); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$packer |
|
79
|
|
|
|
|
|
|
->uint16(0) # session flags |
|
80
|
|
|
|
|
|
|
->uint16($packer->diff('smb-header') + 4) |
|
81
|
|
|
|
|
|
|
->uint16(length $security_buffer) |
|
82
|
|
|
|
|
|
|
->bytes ($security_buffer) |
|
83
|
|
|
|
|
|
|
; |
|
84
|
|
|
|
|
|
|
} else { |
|
85
|
0
|
0
|
|
|
|
|
$security_buffer |
|
86
|
|
|
|
|
|
|
or die "No security_buffer"; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$packer |
|
89
|
|
|
|
|
|
|
->uint8 ($self->flags) |
|
90
|
|
|
|
|
|
|
->uint8 ($self->security_mode) |
|
91
|
|
|
|
|
|
|
->uint32($self->capabilities) |
|
92
|
|
|
|
|
|
|
->uint32(0) # channel |
|
93
|
|
|
|
|
|
|
->uint16($packer->diff('smb-header') + 12) |
|
94
|
|
|
|
|
|
|
->uint16(length $security_buffer) |
|
95
|
|
|
|
|
|
|
->uint64($self->prev_session_id) |
|
96
|
|
|
|
|
|
|
->bytes ($security_buffer) |
|
97
|
|
|
|
|
|
|
; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |