| 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 <http://www.gnu.org/licenses/>. | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | package SMB::v2::Command::SessionSetup; | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | use parent 'SMB::v2::Command'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | sub init ($) { | ||||||||||||||||||||
| 24 | 0 | ▶ | $_[0]->set( | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 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 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 35 | 0 | my $parser = shift; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | if ($self->is_response) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
prepare_response: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | $self->SUPER::prepare_response; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | my $more_processing = $self->security_buffer && length($self->security_buffer) > 70; | ||||||||||||||||||
|
Condition0%0/3
$self->security_buffer && length $self->security_buffer > 70
MC/DC0%0/2
$self->security_buffer && length $self->security_buffer > 70
$self->security_buffer
length $self->security_buffer > 70
Truth table0%0/3
A && B
A= $self->security_bufferB= length $self->security_buffer > 70
| |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | $self->set_status(SMB::STATUS_MORE_PROCESSING_REQUIRED) if $more_processing; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | $self->header->uid(int(rand(999999)) + 1) unless $self->header->uid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | sub pack ($$) { | ||||||||||||||||||||
| 69 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
pack: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 70 | 0 | my $packer = shift; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | my $security_buffer = $self->security_buffer; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | ▶ | if ($self->is_response) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 0 | ▶ | $security_buffer | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 | ▶ | $security_buffer | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 | 1; | |||||||||||||||||||