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/kademlia/server_info.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::Auxiliary::UDPScanner8include Msf::Auxiliary::Kademlia910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Gather Kademlia Server Information',15'Description' => %q(16This module uses the Kademlia BOOTSTRAP and PING messages to identify17and extract information from Kademlia speaking UDP endpoints,18typically belonging to eMule/eDonkey/BitTorrent servers or other P2P19applications.20),21'Author' => 'Jon Hart <jon_hart[at]rapid7.com>',22'References' =>23[24# There are lots of academic papers on the protocol but they tend to lack usable25# protocol details. This is the best I've found26['URL', 'https://gbmaster.wordpress.com/2013/06/16/botnets-surrounding-us-sending-kademlia2_bootstrap_req-kademlia2_hello_req-and-their-strict-cousins/#more-125']27],28'License' => MSF_LICENSE,29'Actions' => [30['BOOTSTRAP', 'Description' => 'Use a Kademlia2 BOOTSTRAP'],31['PING', 'Description' => 'Use a Kademlia2 PING']32],33'DefaultAction' => 'BOOTSTRAP'34)35)3637register_options(38[39Opt::RPORT(4672)40])41end4243def build_probe44@probe ||= case action.name45when 'BOOTSTRAP'46BootstrapRequest.new47when 'PING'48Ping.new49end50end5152def scanner_process(response, src_host, src_port)53return if response.blank?54peer = "#{src_host}:#{src_port}"5556case action.name57when 'BOOTSTRAP'58if bootstrap_res = BootstrapResponse.from_data(response)59info = {60peer_id: bootstrap_res.peer_id,61tcp_port: bootstrap_res.tcp_port,62version: bootstrap_res.version,63peers: bootstrap_res.peers64}65print_good("#{peer} ID #{bootstrap_res.peer_id}, TCP port #{bootstrap_res.tcp_port}," +66" version #{bootstrap_res.version}, #{bootstrap_res.peers.size} peers")67end68when 'PING'69if pong = Pong.from_data(response)70print_good("#{peer} PONG port #{pong.port}")71# port should match the port we contacted it from. TODO: validate this?72info = { udp_port: pong.port }73end74end7576return unless info77@results[src_host] ||= []78@results[src_host] << info79end8081def scanner_postscan(_batch)82@results.each_pair do |host, info|83report_host(host: host)84report_service(85host: host,86proto: 'udp',87port: rport,88name: 'kademlia',89info: info90)91end92end93end949596