| Class | PacketFu::Utils |
| In: |
lib/packetfu/utils.rb
|
| Parent: | Object |
Utils is a collection of various and sundry network utilities that are useful for packet manipulation.
Returns the MAC address of an IP address, or nil if it‘s not responsive to arp. Takes a dotted-octect notation of the target IP address, as well as a number of parameters:
:eth_saddr
Source MAC address. Defaults to "00:00:00:00:00:00".
:ip_saddr
Source IP address. Defaults to "0.0.0.0"
:flavor
The flavor of the ARP request. Defaults to :none.
:timeout
Timeout in seconds. Defaults to 3.
=== Example
PacketFu::Utils::arp("192.168.1.1") #=> "00:18:39:01:33:70"
PacketFu::Utils::arp("192.168.1.1", :timeout => 5, :flavor => :hp_deskjet)
=== Warning
It goes without saying, spewing forged ARP packets on your network is a great way to really
irritate your co-workers.
Discovers the local IP and Ethernet address, which is useful for writing packets you expect to get a response to. Note, this is a noisy operation; a UDP packet is generated and dropped on to the default (or named) interface, and then captured (which means you need to be root to do this).
whoami? returns a hash of :eth_saddr, :eth_src, :ip_saddr, :ip_src, :eth_dst, and :eth_daddr (the last two are usually suitable for a gateway mac address). It‘s most useful as an argument to PacketFu::Config.new.
:iface => "eth0" An interface to listen for packets on. Note that since we rely on the OS to send the probe packet, you will need to specify a target which will use this interface. :target => "1.2.3.4" A target IP address. By default, a packet will be sent to a random address in the 177/8 network. Since this network is IANA reserved (for now), this network should be handled by your default gateway and default interface.