Exemplo n.º 1
0
 def __init__(self):
     self.fields = OrderedDict([
         ('structure_size', IntField(
             size=2,
             default=9,
         )),
         ('error_context_count',
          IntField(
              size=1,
              default=lambda s: len(s['error_data'].get_value()),
          )),
         ('reserved', IntField(size=1)),
         ('byte_count',
          IntField(
              size=4,
              default=lambda s: len(s['error_data']),
          )),
         ('error_data',
          ListField(
              size=lambda s: s['byte_count'].get_value(),
              list_count=lambda s: s['error_context_count'].get_value(),
              list_type=StructureField(
                  structure_type=SMB2ErrorContextResponse),
              unpack_func=lambda s, d: self._error_data_value(s, d))),
     ])
     super(SMB2ErrorResponse, self).__init__()
Exemplo n.º 2
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__()
Exemplo n.º 3
0
 def __init__(self):
     self.fields = OrderedDict([
         ('rpc_vers', IntField(size=1, default=5)),
         ('rpc_vers_minor', IntField(size=1, default=0)),
         ('ptype', EnumField(size=1, enum_type=PType, default=PType.BIND)),
         ('pfx_flags', FlagField(size=1, flag_type=PFlags)),
         ('packed_drep',
          StructureField(size=4, structure_type=DataRepresentationFormat)),
         ('frag_length', IntField(size=2, default=lambda s: len(s))),
         ('auth_length',
          IntField(size=2, default=lambda s: len(s['auth_verifier']))),
         ('call_id', IntField(size=4)),
         ('max_xmit_frag', IntField(size=2, default=4280)),
         ('max_recv_frag', IntField(size=2, default=4280)),
         ('assoc_group_id', IntField(size=4)),
         # p_context_list_t
         ('n_context_elem',
          IntField(size=1,
                   default=lambda s: len(s['context_elems'].get_value()))),
         ('reserved', IntField(size=1)),
         ('reserved2', IntField(size=2)),
         ('context_elems',
          ListField(
              list_count=lambda s: s['n_context_elem'].get_value(),
              list_type=StructureField(structure_type=ContextElement),
              unpack_func=lambda s, d: self._unpack_context_elems(s, d))),
         ('auth_verifier',
          BytesField(size=lambda s: s['auth_length'].get_value()))
     ])
     super(BindPDU, self).__init__()
Exemplo n.º 4
0
 def __init__(self):
     self.fields = OrderedDict([
         ('structure_size', IntField(size=4, default=lambda s: len(s))),
         ('notification_type', IntField(size=4, default=3)),
         ('resource_name_offset',
          IntField(size=4,
                   default=lambda s: self._resource_name_offset(s))),
         ('resource_name_length',
          IntField(size=4, default=lambda s: len(s['resource_name']))),
         ('flags', IntField(size=2, default=0)),
         ('target_type', IntField(size=2, default=0)),
         ('ip_addr_count',
          IntField(
              size=4,
              default=lambda s: len(s['ip_addr_move_list'].get_value()))),
         ('ip_addr_move_list',
          ListField(size=lambda s: s['ip_addr_count'].get_value() * 24,
                    list_count=lambda s: s['ip_addr_count'].get_value(),
                    list_type=StructureField(
                        size=24,
                        structure_type=SMB2MoveDstIpAddrStructure))),
         ('resource_name',
          BytesField(size=lambda s: s['resource_name_length'].get_value()))
     ])
     super(SMB2ShareRedirectErrorContext, self).__init__()
Exemplo n.º 5
0
    def __init__(self):
        self.fields = OrderedDict([
            ('int_field', IntField(size=4)),
            ('bytes_field', BytesField(size=2)),
            ('var_field',
             BytesField(size=lambda s: s['int_field'].get_value(), )),
            ('default_field', IntField(
                size=2,
                default=b"\x01a",
            )),
            ('list_field',
             ListField(
                 list_count=lambda s: s['int_field'].get_value(),
                 list_type=BytesField(size=8),
                 size=lambda s: s['int_field'].get_value() * 8,
             )),
            ('structure_length',
             IntField(
                 size=2,
                 little_endian=False,
                 default=lambda s: len(s['structure_field']),
             )),
            ('structure_field',
             StructureField(
                 size=lambda s: s['structure_length'].get_value(),
                 structure_type=Structure2,
             )),
        ])

        super(Structure1, self).__init__()
Exemplo n.º 6
0
 def __init__(self):
     self.fields = OrderedDict([
         ('field',
          ListField(size=7,
                    unpack_func=lambda s, d:
                    [b"\x01\x02", b"\x03\x04\x05\x06", b"\07"]))
     ])
     super(UnpackListStructure, self).__init__()
Exemplo n.º 7
0
 def __init__(self):
     self.fields = OrderedDict([
         ('field',
          ListField(size=4,
                    list_count=2,
                    list_type=BytesField(size=2),
                    default=[b"\x01\x02", b"\x03\x04"]))
     ])
     super(TestListField.StructureTest, self).__init__()
Exemplo n.º 8
0
 def __init__(self):
     self.fields = OrderedDict([
         ('path_consumed', IntField(size=2)),
         ('number_of_referrals', IntField(size=2)),
         ('referral_header_flags',
          FlagField(size=4, flag_type=DFSReferralHeaderFlags)),
         ('referral_entries',
          ListField(
              list_count=lambda s: s['number_of_referrals'].get_value(),
              unpack_func=lambda s, b: self._create_dfs_referral_entry(b))),
         ('string_buffer', BytesField()),
     ])
     super(DFSReferralResponse, self).__init__()
Exemplo n.º 9
0
 def __init__(self):
     self.fields = OrderedDict([
         ('source_key', BytesField(size=24)),
         ('chunk_count',
          IntField(size=4, default=lambda s: len(s['chunks'].get_value()))),
         ('reserved', IntField(size=4)),
         ('chunks',
          ListField(size=lambda s: s['chunk_count'].get_value() * 24,
                    list_count=lambda s: s['chunk_count'].get_value(),
                    list_type=StructureField(
                        size=24, structure_type=SMB2SrvCopyChunk)))
     ])
     super(SMB2SrvCopyChunkCopy, self).__init__()
 def __init__(self):
     self.fields = OrderedDict([
         ('revision', IntField(size=1, default=1)),
         ('sub_authority_count',
          IntField(
              size=1,
              default=lambda s: len(s['sub_authorities'].get_value()))),
         ('reserved', IntField(size=2)),
         ('identifier_authority', IntField(size=4, little_endian=False)),
         ('sub_authorities',
          ListField(
              list_type=IntField(size=4),
              list_count=lambda s: s['sub_authority_count'].get_value()))
     ])
     super(SIDPacket, self).__init__()
Exemplo n.º 11
0
 def __init__(self):
     # pep 80 char issues force me to define this here
     create_con_req = smbprotocol.create_contexts.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__()
 def __init__(self):
     self.fields = OrderedDict([
         ('acl_revision',
          EnumField(size=1,
                    default=AclRevision.ACL_REVISION,
                    enum_type=AclRevision)), ('sbz1', IntField(size=1)),
         ('acl_size', IntField(size=2,
                               default=lambda s: 8 + len(s['aces']))),
         ('ace_count',
          IntField(size=2, default=lambda s: len(s['aces'].get_value()))),
         ('sbz2', IntField(size=2)),
         ('aces',
          ListField(list_count=lambda s: s['ace_count'].get_value(),
                    unpack_func=lambda s, d: self._unpack_aces(s, d)))
     ])
     super(AclPacket, self).__init__()
Exemplo n.º 13
0
 def __init__(self):
     self.fields = OrderedDict([
         ('context_id', IntField(size=2)),
         ('n_transfer_syn',
          IntField(
              size=1,
              default=lambda s: len(s['transfer_syntaxes'].get_value()))),
         ('reserved', IntField(size=1)),
         ('abstract_syntax',
          StructureField(structure_type=SyntaxIdElement)),
         ('transfer_syntaxes',
          ListField(list_type=StructureField(
              size=20, structure_type=SyntaxIdElement),
                    list_count=lambda s: s['n_transfer_syn'].get_value(),
                    size=lambda s: s['n_transfer_syn'].get_value() * 20)),
     ])
     super(ContextElement, self).__init__()
Exemplo n.º 14
0
 def __init__(self):
     self.fields = OrderedDict([
         ('capabilities', FlagField(
             size=4,
             flag_type=Capabilities,
         )), ('guid', UuidField()),
         ('security_mode', EnumField(
             size=2,
             enum_type=SecurityMode,
         )),
         ('dialect_count',
          IntField(size=2,
                   default=lambda s: len(s['dialects'].get_value()))),
         ('dialects',
          ListField(
              size=lambda s: s['dialect_count'].get_value() * 2,
              list_count=lambda s: s['dialect_count'].get_value(),
              list_type=EnumField(size=2, enum_type=Dialects),
          ))
     ])
     super(SMB2ValidateNegotiateInfoRequest, self).__init__()
Exemplo n.º 15
0
 def __init__(self):
     self.fields = OrderedDict([
         ('rpc_vers', IntField(size=1, default=5)),
         ('rpc_vers_minor', IntField(size=1)),
         ('ptype', EnumField(size=1,
                             enum_type=PType,
                             default=PType.BIND_ACK)),
         ('pfx_flags', FlagField(size=1, flag_type=PFlags)),
         ('packed_drep',
          StructureField(size=4, structure_type=DataRepresentationFormat)),
         ('frag_length', IntField(size=2, default=lambda s: len(s))),
         ('auth_length',
          IntField(size=2, default=lambda s: len(s['auth_verifier']))),
         ('call_id', IntField(size=4)),
         ('max_xmit_frag', IntField(size=2)),
         ('max_recv_frag', IntField(size=2)),
         ('assoc_group_id', IntField(size=4)),
         # port_any_t
         ('sec_addr_len',
          IntField(size=2, default=lambda s: len(s['sec_addr']))),
         ('sec_addr',
          BytesField(size=lambda s: s['sec_addr_len'].get_value())),
         ('pad2',
          BytesField(size=lambda s: self._pad2_size(s),
                     default=lambda s: b"\x00" * self._pad2_size(s))),
         # p_result_list_t
         ('n_results',
          IntField(size=1,
                   default=lambda s: len(s['results'].get_value()))),
         ('reserved', IntField(size=1)),
         ('reserved2', IntField(size=2)),
         ('results',
          ListField(list_count=lambda s: s['n_results'].get_value(),
                    list_type=StructureField(size=24,
                                             structure_type=Result))),
         ('auth_verifier',
          BytesField(size=lambda s: s['auth_length'].get_value()))
     ])
     super(BindAckPDU, self).__init__()
Exemplo n.º 16
0
 def __init__(self):
     self.fields = OrderedDict([
         ('rpc_vers', IntField(size=1, default=5)),
         ('rpc_vers_minor', IntField(size=1)),
         ('ptype', EnumField(size=1,
                             enum_type=PType,
                             default=PType.BIND_NAK)),
         ('pfx_flags', FlagField(size=1, flag_type=PFlags)),
         ('packed_drep',
          StructureField(size=4, structure_type=DataRepresentationFormat)),
         ('frag_length', IntField(size=2, default=lambda s: len(s))),
         ('auth_length', IntField(size=2)),
         ('call_id', IntField(size=4)),
         ('provider_reject_reason',
          EnumField(size=2, enum_type=BindNakReason)),
         # versions
         ('n_protocols',
          IntField(size=1,
                   default=lambda s: len(s['p_protocols'].get_value()))),
         ('p_protocols',
          ListField(list_type=IntField(size=2),
                    list_count=lambda s: s['n_protocols'].get_value()))
     ])
     super(BindNakPDU, self).__init__()
Exemplo n.º 17
0
 def __init__(self):
     self.fields = OrderedDict([
         ('version', IntField(size=4, default=1)),
         ('num_processors',
          IntField(size=4,
                   default=lambda s: len(s['processors'].get_value()))),
         ('processors',
          ListField(size=lambda s: s['num_processors'].get_value() * 4,
                    list_count=lambda s: s['num_processors'].get_value(),
                    list_type=IntField(size=4))),
         ('copy_files', BoolField(size=1)),
         ('force_copy', BoolField(size=1)),
         ('copy_if_newer_or_higher_ver', BoolField(size=1)),
         ('asynchronous', BoolField(size=1)),
         ('dont_load_profile', BoolField(size=1)),
         ('interactive_session', IntField(size=4)),
         ('interactive', BoolField(size=1)),
         ('run_elevated', BoolField(size=1)),
         ('run_limited', BoolField(size=1)),
         ('password_len',
          IntField(size=4, default=lambda s: int(len(s['password']) / 2))),
         ('password',
          BytesField(size=lambda s: s['password_len'].get_value() * 2)),
         ('username_len',
          IntField(size=4, default=lambda s: int(len(s['username']) / 2))),
         ('username',
          BytesField(size=lambda s: s['username_len'].get_value() * 2)),
         ('use_system_account', BoolField(size=1)),
         ('working_dir_len',
          IntField(size=4,
                   default=lambda s: int(len(s['working_dir']) / 2))),
         ('working_dir',
          BytesField(size=lambda s: s['working_dir_len'].get_value() * 2)),
         ('show_ui_on_win_logon', BoolField(size=1)),
         ('priority',
          EnumField(size=4,
                    default=ProcessPriority.NORMAL_PRIORITY_CLASS,
                    enum_type=ProcessPriority)),
         ('executable_len',
          IntField(size=4,
                   default=lambda s: int(len(s['executable']) / 2))),
         ('executable',
          BytesField(size=lambda s: s['executable_len'].get_value() * 2)),
         ('arguments_len',
          IntField(size=4, default=lambda s: int(len(s['arguments']) / 2))),
         ('arguments',
          BytesField(size=lambda s: s['arguments_len'].get_value() * 2)),
         ('disable_file_redirection', BoolField(size=1)),
         ('enable_debug', BoolField(size=1)),
         ('remote_log_path_len',
          IntField(size=4,
                   default=lambda s: int(len(s['remote_log_path']) / 2))),
         ('remote_log_path',
          BytesField(
              size=lambda s: s['remote_log_path_len'].get_value() * 2)),
         ('no_delete', BoolField(size=1)),
         ('src_dir_len',
          IntField(size=4, default=lambda s: int(len(s['src_dir']) / 2))),
         ('src_dir',
          BytesField(size=lambda s: s['src_dir_len'].get_value() * 2)),
         ('dest_dir_len',
          IntField(size=4, default=lambda s: int(len(s['dest_dir']) / 2))),
         ('dest_dir',
          BytesField(size=lambda s: s['dest_dir_len'].get_value() * 2)),
         ('num_src_files',
          IntField(size=4,
                   default=lambda s: len(s['src_files'].get_value()))),
         ('src_files',
          ListField(list_count=lambda s: s['num_src_files'].get_value(),
                    list_type=StructureField(structure_type=PAExecFileInfo),
                    unpack_func=lambda s, d: self._unpack_file_list(
                        s, d, 'num_src_files'))),
         ('num_dest_files',
          IntField(size=4,
                   default=lambda s: len(s['dest_files'].get_value()))),
         ('dest_files',
          ListField(list_count=lambda s: s['num_dest_files'].get_value(),
                    list_type=StructureField(structure_type=PAExecFileInfo),
                    unpack_func=lambda s, d: self._unpack_file_list(
                        s, d, 'num_dest_files'))),
         ('timeout_seconds', IntField(size=4))
     ])
     super(PAExecSettingsBuffer, self).__init__()
Exemplo n.º 18
0
 def __init__(self):
     self.fields = OrderedDict([('field', ListField(list_count=1))])
     super(InvalidListField, self).__init__()
Exemplo n.º 19
0
 def __init__(self):
     self.fields = OrderedDict([('field',
                                 ListField(unpack_func="a"))])
     super(InvalidListField, self).__init__()
Exemplo n.º 20
0
 def __init__(self):
     self.fields = OrderedDict([
         ('field', ListField(list_type=BytesField(size=1)))
     ])
     super(InvalidListField, self).__init__()