Obtains a RPC Transport and a DCE interface according to the bindings and transfer syntax specified. :return: tuple of DCE/RPC and RPC Transport objects :rtype: (DCERPC_v5, DCERPCTransport)
(self, string_binding=None, iface_uuid=None)
| 138 | self.remoteHost = remoteHost |
| 139 | |
| 140 | def connect(self, string_binding=None, iface_uuid=None): |
| 141 | """Obtains a RPC Transport and a DCE interface according to the bindings and |
| 142 | transfer syntax specified. |
| 143 | :return: tuple of DCE/RPC and RPC Transport objects |
| 144 | :rtype: (DCERPC_v5, DCERPCTransport) |
| 145 | """ |
| 146 | string_binding = string_binding or self.string_binding |
| 147 | if not string_binding: |
| 148 | raise NotImplementedError("String binding must be defined") |
| 149 | |
| 150 | rpc_transport = transport.DCERPCTransportFactory(string_binding) |
| 151 | rpc_transport.setRemoteHost(self.remoteHost) |
| 152 | |
| 153 | # Set timeout if defined |
| 154 | if self.timeout: |
| 155 | rpc_transport.set_connect_timeout(self.timeout) |
| 156 | |
| 157 | # Authenticate if specified |
| 158 | if self.authn and hasattr(rpc_transport, "set_credentials"): |
| 159 | # This method exists only for selected protocol sequences. |
| 160 | rpc_transport.set_credentials(self.username, self.password, self.domain, self.lmhash, self.nthash, self.aesKey) |
| 161 | |
| 162 | if self.doKerberos: |
| 163 | rpc_transport.set_kerberos(self.doKerberos, kdcHost=self.kdcHost) |
| 164 | |
| 165 | # Gets the DCE RPC object |
| 166 | dce = rpc_transport.get_dce_rpc() |
| 167 | |
| 168 | if self.doKerberos: |
| 169 | dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE) |
| 170 | |
| 171 | # Connect |
| 172 | dce.connect() |
| 173 | |
| 174 | # Bind if specified |
| 175 | iface_uuid = iface_uuid or self.iface_uuid |
| 176 | if iface_uuid and self.transfer_syntax: |
| 177 | dce.bind(iface_uuid, transfer_syntax=self.transfer_syntax) |
| 178 | elif iface_uuid: |
| 179 | dce.bind(iface_uuid) |
| 180 | |
| 181 | return dce, rpc_transport |
| 182 | |
| 183 | def open_policy(self, dce): |
| 184 | request = lsad.LsarOpenPolicy2() |
no test coverage detected