Module: Msf::Exploit::Remote::MsIcpr
- Includes:
- CertRequest, DCERPC, LDAP::ActiveDirectory::AdCsOpts, SMB::Client::Ipc
- Defined in:
- lib/msf/core/exploit/remote/ms_icpr.rb
Defined Under Namespace
Classes: MsIcprAuthenticationError, MsIcprAuthorizationError, MsIcprConnectionError, MsIcprError, MsIcprNotFoundError, MsIcprUnexpectedReplyError, MsIcprUnknownError
Constant Summary collapse
- ADCS_CA_SERVICE_NAME =
'adcs-ca'
Constants included from DCERPC
DCERPC::DCERPCClient, DCERPC::DCERPCPacket, DCERPC::DCERPCResponse, DCERPC::DCERPCUUID, DCERPC::NDR
Constants included from DCERPC_LSA
Constants included from DCERPC_MGMT
Constants included from SMB::Client
SMB::Client::CONST, SMB::Client::DCERPCClient, SMB::Client::DCERPCPacket, SMB::Client::DCERPCResponse, SMB::Client::DCERPCUUID, SMB::Client::NDR, SMB::Client::SIMPLE, SMB::Client::XCEPT
Instance Attribute Summary
Attributes included from DCERPC
Attributes included from Tcp
Attributes included from SMB::Client
Class Method Summary collapse
- .connect_icpr(tree) ⇒ Object
- .do_request_cert(icpr, opts, csr, attributes) ⇒ Object
- .report_icertpassage_service ⇒ Object
Instance Method Summary collapse
Methods included from LDAP::ActiveDirectory::AdCsOpts
Methods included from CertRequest
#create_csr, #get_cert_msext_sid, #get_cert_msext_upn, #get_cert_policy_oids, #get_cert_san, #get_cert_san_dns, #get_cert_san_email, #get_cert_san_uri, #with_adcs_certificate_request
Methods included from DCERPC
#dcerpc_bind, #dcerpc_call, #dcerpc_getarch, #dcerpc_handle, #dcerpc_handle_target, #unicode
Methods included from DCERPC_LSA
Methods included from DCERPC_MGMT
#dcerpc_mgmt_connect, #dcerpc_mgmt_inq_if_ids, #dcerpc_mgmt_inq_if_stats, #dcerpc_mgmt_inq_princ_name, #dcerpc_mgmt_is_server_listening, #dcerpc_mgmt_stop_server_listening
Methods included from DCERPC_EPM
#dcerpc_endpoint_find_tcp, #dcerpc_endpoint_find_udp, #dcerpc_endpoint_list
Methods included from Tcp
#chost, #cleanup, #connect, #connect_timeout, #cport, #disconnect, #handler, #lhost, #lport, #peer, #print_prefix, #proxies, #replicant, #rhost, #rport, #set_tcp_evasions, #shutdown, #ssl, #ssl_cipher, #ssl_verify_mode, #ssl_version, #sslkeylogfile
Methods included from SMB::Client::Ipc
connect_ipc, disconnect_ipc, report_dcerpc_service
Methods included from Auxiliary::Report
#active_db?, #create_cracked_credential, #create_credential, #create_credential_and_login, #create_credential_login, #db, #db_warning_given?, #get_client, #get_host, #inside_workspace_boundary?, #invalidate_login, #mytask, #myworkspace, #myworkspace_id, #report_auth_info, #report_client, #report_exploit, #report_host, #report_loot, #report_note, #report_service, #report_vuln, #report_web_form, #report_web_page, #report_web_site, #report_web_vuln, #store_cred, #store_local, #store_loot
Methods included from Metasploit::Framework::Require
optionally, optionally_active_record_railtie, optionally_include_metasploit_credential_creation, #optionally_include_metasploit_credential_creation, optionally_require_metasploit_db_gem_engines
Methods included from Kerberos::ServiceAuthenticator::Options
#kerberos_auth_options, #kerberos_clock_skew_seconds
Methods included from Kerberos::Ticket::Storage
#kerberos_storage_options, #kerberos_ticket_storage, store_ccache
Methods included from SMB::Client
#connect, #domain, #domain_username_split, #smb_create, #smb_direct, #smb_enumprinters, #smb_enumprintproviders, #smb_file_exist?, #smb_file_rm, #smb_fingerprint, #smb_fingerprint_windows_lang, #smb_fingerprint_windows_sp, #smb_hostname, #smb_lanman_netshareenumall, #smb_login, #smb_lookup_share_type, #smb_netshareenumall, #smb_netsharegetinfo, #smb_open, #smb_peer_lm, #smb_peer_os, #smb_srvsvc_netshareenumall, #smb_srvsvc_netsharegetinfo, #smbhost, #splitname, #unicode
Class Method Details
.connect_icpr(tree) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/msf/core/exploit/remote/ms_icpr.rb', line 80 def connect_icpr(tree) vprint_status('Connecting to ICertPassage (ICPR) Remote Protocol') icpr = tree.open_file(filename: 'cert', write: true, read: true) vprint_status('Binding to \\cert...') icpr.bind( endpoint: RubySMB::Dcerpc::Icpr, auth_level: RubySMB::Dcerpc::RPC_C_AUTHN_LEVEL_PKT_PRIVACY, auth_type: RubySMB::Dcerpc::RPC_C_AUTHN_WINNT ) vprint_good('Bound to \\cert') report_icertpassage_service icpr end |
.do_request_cert(icpr, opts, csr, attributes) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/msf/core/exploit/remote/ms_icpr.rb', line 97 def do_request_cert(icpr, opts, csr, attributes) response = icpr.cert_server_request( attributes: attributes, authority: datastore['CA'], csr: csr ) case response[:status] when :issued print_good('The requested certificate was issued.') when :submitted print_warning('The requested certificate was submitted for review.') else print_error('There was an error while requesting the certificate.') print_error(response[:disposition_message].strip.to_s) unless response[:disposition_message].blank? hresult = ::WindowsError::HResult.find_by_retval(response[:disposition]).first if hresult print_error('Error details:') print_error(" Source: #{hresult.facility}") if hresult.facility print_error(" HRESULT: #{hresult}") end case hresult when ::WindowsError::HResult::CERTSRV_E_ENROLL_DENIED raise MsIcprAuthorizationError.new(hresult.description) when ::WindowsError::HResult::CERTSRV_E_TEMPLATE_DENIED raise MsIcprAuthorizationError.new(hresult.description) when ::WindowsError::HResult::CERTSRV_E_UNSUPPORTED_CERT_TYPE raise MsIcprNotFoundError.new(hresult.description) else raise MsIcprUnknownError.new(hresult.description) end end response[:certificate] end |
.report_icertpassage_service ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/msf/core/exploit/remote/ms_icpr.rb', line 134 def report_icertpassage_service report_service({ name: 'icertpassage', resource: { dcerpc: { pipe: 'cert' } }, host: simple.peerhost, port: simple.peerport, proto: 'tcp', parents: report_dcerpc_service }) end |
Instance Method Details
#icpr_request_certificate(opts = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/msf/core/exploit/remote/ms_icpr.rb', line 41 def icpr_request_certificate(opts = {}) tree = opts[:tree] || connect_ipc begin icpr = connect_icpr(tree) rescue RubySMB::Error::UnexpectedStatusCode => e if e.status_code == ::WindowsError::NTStatus::STATUS_OBJECT_NAME_NOT_FOUND # STATUS_OBJECT_NAME_NOT_FOUND will be the status if Active Directory Certificate Service (AD CS) is not installed on the target raise MsIcprNotFoundError, 'Connection failed (AD CS was not found).' end elog(e., error: e) raise MsIcprUnexpectedReplyError, "Connection failed (unexpected status: #{e.status_name})" end opts = opts.dup # Don't alter the caller's instance # Calls to this come from different places with different imports and different opts hash values, so we need this # here to make sure all the data we need is populated opts[:username] = opts.fetch(:username) { datastore['SMBUser'] } opts[:domain] = opts.fetch(:domain) { simple.client.default_domain } opts[:service] = report_icertpassage_service with_adcs_certificate_request(opts) do |csr, attributes| do_request_cert(icpr, opts, csr, attributes) end rescue RubySMB::Dcerpc::Error::FaultError => e elog(e., error: e) raise MsIcprUnexpectedReplyError, "Operation failed (DCERPC fault: #{e.status_name})" rescue RubySMB::Dcerpc::Error::DcerpcError => e elog(e., error: e) raise MsIcprUnexpectedReplyError, e. rescue RubySMB::Error::RubySMBError => e elog(e., error: e) raise MsIcprUnknownError, e. end |