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/scanner/memcached/memcached_amp.rb
Views: 11784
##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::Capture8include Msf::Auxiliary::UDPScanner9include Msf::Auxiliary::DRDoS1011def initialize12super(13'Name' => 'Memcached Stats Amplification Scanner',14'Description' => %q(15This module can be used to discover Memcached servers which expose the16unrestricted UDP port 11211. A basic "stats" request is executed to check17if an amplification attack is possible against a third party.18),19'Author' =>20[21'Marek Majkowski', # Cloudflare blog and base payload22'xistence <xistence[at]0x90.nl>', # Metasploit scanner module23'Jon Hart <[email protected]>', # Metasploit scanner module24],25'License' => MSF_LICENSE,26'DisclosureDate' => 'Feb 27 2018',27'References' =>28[29['URL', 'https://blog.cloudflare.com/memcrashed-major-amplification-attacks-from-port-11211/'],30['CVE', '2018-1000115']31]32)3334register_options([35Opt::RPORT(11211)36])37end3839def build_probe40# Memcached stats probe, per https://github.com/memcached/memcached/blob/master/doc/protocol.txt41@memcached_probe ||= [42rand(2**16), # random request ID430, # sequence number441, # number of datagrams in this sequence450, # reserved; must be 046"stats\r\n"47].pack("nnnna*")48end4950def scanner_process(data, shost, sport)51# Check the response data for a "STAT" response52if data =~ /\x0d\x0aSTAT\x20/53@results[shost] ||= []54@results[shost] << data55end56end5758# Called after the scan block59def scanner_postscan(batch)60@results.keys.each do |host|61response_map = { @memcached_probe => @results[host] }62report_service(63host: host,64proto: 'udp',65port: rport,66name: 'memcached'67)6869peer = "#{host}:#{rport}"70vulnerable, proof = prove_amplification(response_map)71what = 'memcached stats amplification'72if vulnerable73print_good("#{peer} - Vulnerable to #{what}: #{proof}")74report_vuln(75host: host,76port: rport,77proto: 'udp',78name: what,79refs: references80)81else82vprint_status("#{peer} - Not vulnerable to #{what}: #{proof}")83end84end85end86end878889