Example #1
0
 def __init__(self):
     create_con_req = smbprotocol.create_contexts.SMB2CreateContextRequest
     self.fields = OrderedDict([
         ('structure_size', IntField(size=2, default=89)),
         ('oplock_level', EnumField(size=1,
                                    enum_type=RequestedOplockLevel)),
         ('flag', FlagField(size=1, flag_type=FileFlags)),
         ('create_action', EnumField(size=4, enum_type=CreateAction)),
         ('creation_time', DateTimeField(size=8)),
         ('last_access_time', DateTimeField(size=8)),
         ('last_write_time', DateTimeField(size=8)),
         ('change_time', DateTimeField(size=8)),
         ('allocation_size', IntField(size=8)),
         ('end_of_file', IntField(size=8)),
         ('file_attributes', FlagField(size=4, flag_type=FileAttributes)),
         ('reserved2', IntField(size=4)), ('file_id', BytesField(size=16)),
         ('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']))),
         ('buffer',
          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(SMB2CreateResponse, self).__init__()
Example #2
0
 def __init__(self):
     self.fields = OrderedDict([
         ('next_entry_offset', IntField(size=4)),
         ('file_index', IntField(size=4)),
         ('creation_time', DateTimeField(size=8)),
         ('last_access_time', DateTimeField(size=8)),
         ('last_write_time', DateTimeField(size=8)),
         ('change_time', DateTimeField(size=8)),
         ('end_of_file', IntField(size=8)),
         ('allocation_size', IntField(size=8)),
         ('file_attributes', FlagField(size=4, flag_type=FileAttributes)),
         ('file_name_length',
          IntField(size=4, default=lambda s: len(s['file_name']))),
         ('ea_size', IntField(size=4)),
         ('short_name_length',
          IntField(size=1, default=lambda s: len(s['short_name']))),
         ('reserved1', IntField(size=1)),
         ('short_name',
          BytesField(size=lambda s: s['short_name_length'].get_value())),
         ('short_name_padding',
          BytesField(size=lambda s: 24 - len(s['short_name']),
                     default=lambda s: b"\x00" *
                     (24 - len(s['short_name'])))),
         ('reserved2', IntField(size=2)), ('file_id', IntField(size=8)),
         ('file_name',
          BytesField(size=lambda s: s['file_name_length'].get_value()))
     ])
     super(FileIdBothDirectoryInformation, self).__init__()
Example #3
0
 def __init__(self):
     self.fields = OrderedDict([
         ('structure_size', IntField(size=2, default=60)),
         ('flags', FlagField(size=2, flag_type=CloseFlags)),
         ('reserved', IntField(size=4)), ('creation_time', DateTimeField()),
         ('last_access_time', DateTimeField()),
         ('last_write_time', DateTimeField()),
         ('change_time', DateTimeField()),
         ('allocation_size', IntField(size=8)),
         ('end_of_file', IntField(size=8)),
         ('file_attributes', FlagField(size=4, flag_type=FileAttributes))
     ])
     super(SMB2CloseResponse, self).__init__()
Example #4
0
 def __init__(self):
     self.fields = OrderedDict([
         ('next_entry_offset', IntField(size=4)),
         ('file_index', IntField(size=4)),
         ('creation_time', DateTimeField(size=8)),
         ('last_access_time', DateTimeField(size=8)),
         ('last_write_time', DateTimeField(size=8)),
         ('change_time', DateTimeField(size=8)),
         ('end_of_file', IntField(size=8)),
         ('allocation_size', IntField(size=8)),
         ('file_attributes', FlagField(size=4, flag_type=FileAttributes)),
         ('file_name_length',
          IntField(size=4, default=lambda s: len(s['file_name']))),
         ('file_name',
          BytesField(size=lambda s: s['file_name_length'].get_value()))
     ])
     super(FileDirectoryInformation, self).__init__()
Example #5
0
 def __init__(self):
     self.fields = OrderedDict([
         ('filename_len',
          IntField(size=4, default=lambda s: int(len(s['filename']) / 2))),
         ('filename',
          BytesField(size=lambda s: s['filename_len'].get_value() * 2)),
         ('file_last_write', DateTimeField(size=8)),
         ('file_version_ls', IntField(size=4)),
         ('file_version_ms', IntField(size=4)),
         ('copy_file', BoolField(size=1))
     ])
     super(PAExecFileInfo, self).__init__()
Example #6
0
 def __init__(self):
     self.fields = OrderedDict([
         ('volume_creation_time', DateTimeField()),
         ('volume_serial_number', IntField(size=4)),
         ('volume_label_length', IntField(
             size=4,
             default=lambda s: len(s['volume_label']),
         )),
         ('supports_objects', BoolField(default=False)),
         ('reserved', IntField(size=1)),
         ('volume_label', TextField(
             size=lambda s: s['volume_label_length'].get_value(),
             encoding='utf-16-le',
         )),
     ])
     super(FileFsVolumeInformation, self).__init__()
Example #7
0
 def __init__(self):
     self.fields = OrderedDict([
         ('timestamp', DateTimeField())
     ])
     super(SMB2CreateTimewarpToken, self).__init__()
Example #8
0
 def __init__(self):
     self.fields = OrderedDict([
         ('timestamp', DateTimeField())
     ])
     super(SMB2CreateQueryMaximalAccessRequest, self).__init__()
Example #9
0
 def test_invalid_size_none(self):
     with pytest.raises(InvalidFieldDefinition) as exc:
         DateTimeField(size=4)
     assert str(exc.value) == "DateTimeField type must have a size of 8 " \
                              "not 4"
Example #10
0
 def __init__(self):
     self.fields = OrderedDict([
         ('field', DateTimeField(default=TestDateTimeField.DATE, ))
     ])
     super(TestDateTimeField.StructureTest, self).__init__()