-
Notifications
You must be signed in to change notification settings - Fork 4
/
session_setup_response.go
70 lines (54 loc) · 1.85 KB
/
session_setup_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package simba
import (
"encoding/binary"
)
// MS-SMB2 2.2.6 SMB2 SESSION_SETUP Response
type SessionSetupResponse []byte
type SessionSetupSessionFlags uint16
const (
// MS-SMB2 - v20211006 page 57/481
// MS-SMB2 - v20230920 page 59/488
SMB2_SESSION_FLAG_IS_GUEST SessionSetupSessionFlags = 0x0001
SMB2_SESSION_FLAG_IS_NULL SessionSetupSessionFlags = 0x0002
SMB2_SESSION_FLAG_ENCRYPT_DATA SessionSetupSessionFlags = 0x0004
)
func (p SessionSetupResponse) IsInvalid() bool {
// MS-SMB2, MUST be set to 8
if len(p) < 8 {
return true
}
return false
}
func (p SessionSetupResponse) StructureSize() uint16 {
return binary.LittleEndian.Uint16(p[0:2])
}
func (p SessionSetupResponse) SetStructureSize() {
binary.LittleEndian.PutUint16(p[0:2], 9)
}
func (p SessionSetupResponse) SessionFlags() SessionSetupSessionFlags {
return SessionSetupSessionFlags(binary.LittleEndian.Uint16(p[2:4]))
}
func (p SessionSetupResponse) SetSessionFlags(v SessionSetupSessionFlags) {
binary.LittleEndian.PutUint16(p[2:4], uint16(v))
}
func (p SessionSetupResponse) SecurityBufferOffset() uint16 {
return binary.LittleEndian.Uint16(p[4:6])
}
func (p SessionSetupResponse) SetSecurityBufferOffset(v uint16) {
binary.LittleEndian.PutUint16(p[4:6], v)
}
func (p SessionSetupResponse) SecurityBufferLength() uint16 {
return binary.LittleEndian.Uint16(p[6:8])
}
func (p SessionSetupResponse) SetSecurityBufferLength(v uint16) {
binary.LittleEndian.PutUint16(p[6:8], v)
}
func (p SessionSetupResponse) Buffer() []byte {
return p[p.SecurityBufferOffset()-64 : p.SecurityBufferOffset()+p.SecurityBufferLength()]
}
func (p SessionSetupResponse) SetBuffer(v []byte) {
// p.SetSecurityBufferOffset(8)
offset := p.SecurityBufferOffset() - 64
length := p.SecurityBufferLength()
copy(p[offset:offset+length], v)
}