MCPcopy
hub / github.com/Pennyw0rth/NetExec / connect

Method connect

nxc/modules/enum_av.py:140–181  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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()

Callers 15

reflect_tableMethod · 0.45
dcom_FirewallCheckerFunction · 0.45
authenticateMethod · 0.45
run_ldaps_noEPAMethod · 0.45
run_ldaps_withEPAMethod · 0.45
run_ldapMethod · 0.45
parse_fileMethod · 0.45
do_samr_addMethod · 0.45
__fetchListMethod · 0.45
perform_attackMethod · 0.45

Calls 1

get_dce_rpcMethod · 0.80

Tested by

no test coverage detected