Path: blob/master/modules/auxiliary/scanner/memcached/memcached_udp_version.rb
19567 views
##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::UDPScanner910def initialize11super(12'Name' => 'Memcached UDP Version Scanner',13'Description' => %q(14This module can be used to discover Memcached servers which expose the15unrestricted UDP port 11211. A basic "version" request is executed to obtain16the version of memcached.17),18'Author' => [19'Jon Hart <[email protected]>' # Metasploit scanner module20],21'License' => MSF_LICENSE,22'DisclosureDate' => 'Jul 23 2003',23'References' => [24['URL', 'https://github.com/memcached/memcached/blob/master/doc/protocol.txt']25]26)2728register_options(29[30Opt::RPORT(11211)31]32)33end3435def build_probe36# Memcached version probe, per https://github.com/memcached/memcached/blob/master/doc/protocol.txt37@memcached_probe ||= [38rand(2**16), # random request ID390, # sequence number401, # number of datagrams in this sequence410, # reserved; must be 042"version\r\n"43].pack("nnnna*")44end4546def scanner_process(data, shost, sport)47# Check the response data for a "VERSION" response48if /VERSION (?<version>[\d\.]+)\r\n/ =~ data49print_good("#{shost}:#{sport}/udp memcached version #{version}")50report_service(51host: shost,52proto: 'udp',53port: rport,54info: version,55name: 'memcached'56)57end58end59end606162