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
71
72
73
74
75
76
|
class SMB2CreateRequest(Structure):
"""
[MS-SMB2] v53.0 2017-09-15
2.2.13 SMB2 CREATE Request
The SMB2 Create Request packet is sent by a client to request either
creation of or access to a file.
"""
COMMAND = Commands.SMB2_CREATE
def __init__(self):
## pep 80 char issues force me to define this here
create_con_req = SMB2CreateContextRequest
self.fields = OrderedDict([
('structure_size', IntField(
size=2,
default=57,
)),
('security_flags', IntField(size=1)),
('requested_oplock_level', EnumField(
size=1,
enum_type=RequestedOplockLevel
)),
('impersonation_level', EnumField(
size=4,
enum_type=ImpersonationLevel
)),
('smb_create_flags', IntField(size=8)),
('reserved', IntField(size=8)),
('desired_access', IntField(size=4)),
('file_attributes', IntField(size=4)),
('share_access', FlagField(
size=4,
flag_type=ShareAccess
)),
('create_disposition', EnumField(
size=4,
enum_type=CreateDisposition
)),
('create_options', FlagField(
size=4,
flag_type=CreateOptions
)),
('name_offset', IntField(
size=2,
default=120 ## (header size 64) + (structure size 56)
)),
('name_length', IntField(
size=2,
default=lambda s: self._name_length(s)
)),
('create_contexts_offset', IntField(
size=4,
default=lambda s: self._create_contexts_offset(s)
)),
('create_contexts_length', IntField(
size=4,
default=lambda s: len(s['buffer_contexts'])
)),
## Technically these are all under buffer but we split it to make
## things easier
('buffer_path', BytesField(
size=lambda s: self._buffer_path_size(s),
)),
('padding', BytesField(
size=lambda s: self._padding_size(s),
default=lambda s: b"\x00" * self._padding_size(s)
)),
('buffer_contexts', ListField(
size=lambda s: s['create_contexts_length'].get_value(),
list_type=StructureField(
structure_type=create_con_req
),
unpack_func=lambda s, d: self._buffer_context_list(s, d)
))
])
super(SMB2CreateRequest, self).__init__()
|