| Class | PacketFu::Capture |
| In: |
lib/packetfu/capture.rb
|
| Parent: | Object |
The Capture class is used to construct PcapRub objects in order to collect packets from an interface.
This class requires PcapRub. In addition, you will need root (or root-like) privileges in order to capture from the interface.
Note, on some wireless cards, setting :promisc => true will disable capturing.
# Typical use cap = PacketFu::Capture.new(:iface => 'eth0', :promisc => true) cap.start sleep 10 cap.save first_packet = cap.array[0] # Tcpdump-like use cap = PacketFu::Capture.new(:start => true) cap.show_live(:save => true, :filter => 'tcp and not port 22')
| array | [RW] | |
| iface | [R] | |
| promisc | [R] | |
| snaplen | [R] | |
| stream | [RW] | |
| timeout | [R] |
capture() initializes the @stream varaible. Valid arguments are:
:filter
Provide a bpf filter to enable for the capture. For example, 'ip and not tcp'
:start
When true, start capturing packets to the @stream variable. Defaults to true
show_live() is a method to capture packets and display peek() data to stdout. Valid arguments are:
:filter
Provide a bpf filter to captured packets.
:save
Save the capture in @array
:verbose
TODO: Not implemented yet; do more than just peek() at the packets.
:quiet
TODO: Not implemented yet; do less than peek() at the packets.
wire_to_array() saves a packet stream as an array of binary strings. From here, packets may accessed by other functions. Note that the wire_to_array empties the stream, so multiple calls will append new packets to @array. Valid arguments are:
:filter
Provide a bpf filter to apply to packets moving from @stream to @array.