Class: BetterCap::Discovery::Agents::Icmp

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/discovery/agents/icmp.rb

Overview

Class responsible to do a ping-sweep on the network.

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ Icmp

Create a thread which will perform a ping-sweep on the network in order to populate the ARP cache with active targets.


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bettercap/discovery/agents/icmp.rb', line 21

def initialize( ctx )
  Factories::Firewall.get.enable_icmp_bcast(true)

  # TODO: Use the real broadcast address for this network.
  3.times do
    pkt = PacketFu::ICMPPacket.new

    pkt.eth_saddr = ctx.ifconfig[:eth_saddr]
    pkt.eth_daddr = 'ff:ff:ff:ff:ff:ff'
    pkt.ip_saddr  = ctx.ifconfig[:ip_saddr]
    pkt.ip_daddr  = '255.255.255.255'
    pkt.icmp_type = 8
    pkt.icmp_code = 0
    pkt.payload   = "ABCD"
    pkt.recalc

    ctx.packets.push(pkt)
  end
end