コード例 #1
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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__()
コード例 #2
0
ファイル: open.py プロジェクト: martinhoefling/smbprotocol
 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__()
コード例 #3
0
ファイル: exceptions.py プロジェクト: robpal1990/smbprotocol
 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__()
コード例 #4
0
ファイル: exceptions.py プロジェクト: robpal1990/smbprotocol
 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__()
コード例 #5
0
 def __init__(self):
     self.fields = OrderedDict([
         ('ace_type', EnumField(
             size=1,
             default=AceType.SYSTEM_AUDIT_ACE_TYPE,
             enum_type=AceType
         )),
         ('ace_flags', FlagField(
             size=1,
             flag_type=AceFlags
         )),
         ('ace_size', IntField(
             size=2,
             default=lambda s: 8 + len(s['sid'])
         )),
         ('mask', FlagField(
             size=4,
             flag_type=AccessMask,
             flag_strict=False
         )),
         ('sid', StructureField(
             structure_type=SIDPacket
         ))
     ])
     super(SystemAuditAce, self).__init__()
コード例 #6
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__()
コード例 #7
0
 def __init__(self):
     self.fields = OrderedDict([
         ('field',
          StructureField(size=8,
                         structure_type=Structure2,
                         default=b"\x7d\x00\x00\x00\x10\x11\x12\x13"))
     ])
     super(TestStructureField.StructureTest, self).__init__()
コード例 #8
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 def __init__(self):
     self.fields = OrderedDict([
         ('result', EnumField(size=2, enum_type=ContextResult)),
         ('reason', EnumField(size=2, enum_type=ResultReason)),
         ('transfer_syntax',
          StructureField(size=20, structure_type=SyntaxIdElement)),
     ])
     super(Result, self).__init__()
コード例 #9
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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__()
コード例 #10
0
 def __init__(self):
     self.fields = OrderedDict([
         ('basic_information',
          StructureField(
              structure_type=FileBasicInformation,
              default=FileBasicInformation(),
          )),
         ('standard_information',
          StructureField(
              structure_type=FileStandardInformation,
              default=FileStandardInformation(),
          )),
         ('internal_information',
          StructureField(
              structure_type=FileInternalInformation,
              default=FileInternalInformation(),
          )),
         ('ea_information',
          StructureField(
              structure_type=FileEaInformation,
              default=FileEaInformation(),
          )),
         ('access_information',
          StructureField(
              structure_type=FileAccessInformation,
              default=FileAccessInformation(),
          )),
         ('position_information',
          StructureField(
              structure_type=FilePositionInformation,
              default=FilePositionInformation(),
          )),
         ('mode_information',
          StructureField(
              structure_type=FileModeInformation,
              default=FileModeInformation(),
          )),
         ('alignment_information',
          StructureField(
              structure_type=FileAlignmentInformation,
              default=FileAlignmentInformation(),
          )),
         ('name_information',
          StructureField(
              structure_type=FileNameInformation,
              default=FileNameInformation(),
          )),
     ])
     super(FileAllInformation, self).__init__()
コード例 #11
0
ファイル: paexec.py プロジェクト: nkpro2000sr/pypsexec
 def __init__(self):
     self.fields = OrderedDict([
         ('msg_id',
          EnumField(size=2,
                    default=PAExecMsgId.MSGID_SETTINGS,
                    enum_type=PAExecMsgId)),
         ('xor_val', IntField(size=4, default=os.urandom(4))),
         ('unique_id', IntField(size=4)), ('buffer_len', IntField(size=4)),
         ('buffer', StructureField(structure_type=PAExecSettingsBuffer))
     ])
     super(PAExecSettingsMsg, self).__init__()
コード例 #12
0
ファイル: ioctl.py プロジェクト: segxi/smbprotocol
 def __init__(self):
     self.fields = OrderedDict([
         # 0 if no more network interfaces
         ('next', IntField(size=4)),
         ('if_index', IntField(size=4)),
         ('capability', FlagField(size=4, flag_type=IfCapability)),
         ('reserved', IntField(size=4)),
         ('link_speed', IntField(size=8)),
         ('sock_addr_storage',
          StructureField(size=128, structure_type=SockAddrStorage))
     ])
     super(SMB2NetworkInterfaceInfo, self).__init__()
コード例 #13
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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__()
コード例 #14
0
ファイル: ioctl.py プロジェクト: segxi/smbprotocol
 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__()
コード例 #15
0
ファイル: ioctl.py プロジェクト: segxi/smbprotocol
 def __init__(self):
     self.fields = OrderedDict([
         ('family', EnumField(size=2, enum_type=SockAddrFamily)),
         ('buffer',
          StructureField(
              size=lambda s: self._get_buffer_size(s),
              structure_type=lambda s: self._get_buffer_structure_type(s))),
         ('reserved',
          BytesField(
              size=lambda s: self._get_reserved_size(s),
              default=lambda s: b"\x00" * self._get_reserved_size(s)))
     ])
     super(SockAddrStorage, self).__init__()
コード例 #16
0
ファイル: open.py プロジェクト: martinhoefling/smbprotocol
 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__()
コード例 #17
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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.FAULT)),
         ('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)),
         ('alloc_hint', IntField(size=4)), ('p_cont_id', IntField(size=2)),
         ('cancel_count', IntField(size=1)), ('reserved', IntField(size=1)),
         ('status',
          EnumField(size=4, enum_type=FaultStatus, enum_strict=False))
     ])
     super(FaultPDU, self).__init__()
コード例 #18
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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.RESPONSE)),
         ('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)), ('alloc_hint', IntField(size=4)),
         ('cont_id', IntField(size=2)), ('cancel_count', IntField(size=1)),
         ('reserved', IntField(size=1)),
         ('stub_data',
          BytesField(size=lambda s: self._get_stub_data_size(s))),
         ('auth_verifier',
          BytesField(size=lambda s: s['auth_length'].get_value()))
     ])
     super(ResponsePDU, self).__init__()
コード例 #19
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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.REQUEST)),
         ('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)), ('alloc_hint', IntField(size=4)),
         ('cont_id', IntField(size=2)), ('opnum', IntField(size=2)),
         ('object',
          BytesField(size=lambda s: 16 if s['pfx_flags'].has_flag(
              PFlags.PFC_OBJECT_UUID) else 0)),
         ('stub_data',
          BytesField(size=lambda s: self._get_stub_data_size(s))),
         ('auth_verifier',
          BytesField(size=lambda s: s['auth_length'].get_value()))
     ])
     super(RequestPDU, self).__init__()
コード例 #20
0
ファイル: rpc.py プロジェクト: nkpro2000sr/pypsexec
 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__()
コード例 #21
0
ファイル: paexec.py プロジェクト: nkpro2000sr/pypsexec
 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__()