Module: Rex::Proto::Kademlia

Included in:
Msf::Auxiliary::Kademlia
Defined in:
lib/rex/proto/kademlia/message.rb,
lib/rex/proto/kademlia/ping.rb,
lib/rex/proto/kademlia/pong.rb,
lib/rex/proto/kademlia/util.rb,
lib/rex/proto/kademlia/bootstrap_request.rb,
lib/rex/proto/kademlia/bootstrap_response.rb

Overview

Minimal support for the newer Kademlia protocol, referred to here and often elsewhere as Kademlia2. It is unclear how this differs from the old protocol.

Protocol details are hard to come by because most documentation is academic in nature and glosses over the low-level network details. The best documents I found on the protocol are:

gbmaster.wordpress.com/2013/05/05/botnets-surrounding-us-an-initial-focus-on-kad/ gbmaster.wordpress.com/2013/06/16/botnets-surrounding-us-sending-kademlia2_bootstrap_req-kademlia2_hello_req-and-their-strict-cousins/ gbmaster.wordpress.com/2013/11/23/botnets-surrounding-us-performing-requests-sending-out-kademlia2_req-and-asking-contact-where-art-thou/

Defined Under Namespace

Classes: BootstrapRequest, BootstrapResponse, Message, Ping, Pong

Constant Summary collapse

PING =

Opcode for a PING request

0x60
PONG =

Opcode for a PING response

0x61
BOOTSTRAP_REQUEST =

Opcode for a BOOTSTRAP request

0x01
BOOTSTRAP_RESPONSE =

Opcode for a bootstrap response

0x09

Class Method Summary collapse

Class Method Details

.decode_peer_id(bytes) ⇒ String

Decodes an on-the-wire representation of a Kademlia peer to its 16-character hex equivalent

Parameters:

  • bytes (String)

    the on-the-wire representation of a Kademlia peer

Returns:

  • (String)

    the peer ID if valid, nil otherwise


10
11
12
13
14
15
# File 'lib/rex/proto/kademlia/util.rb', line 10

def self.decode_peer_id(bytes)
  peer_id = 0
  return nil unless bytes.size == 16
  bytes.unpack('VVVV').map { |p| peer_id = ((peer_id << 32) ^ p) }
  peer_id.to_s(16).upcase
end