Created
November 5, 2016 23:35
-
-
Save picatz/076cbd285972e9de4c6bdb8e31e27b26 to your computer and use it in GitHub Desktop.
PacketFu example setting a Berkeley Packet Filter syntax for a capture.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'packetfu' | |
# get the default routable interface | |
iface = PacketFu::Utils.default_int | |
# Get my local ip | |
my_ip = PacketFu::Utils.ifconfig(iface)[:ip_saddr] | |
# Create a new capture on the en0 interface, just because I can | |
cap = PacketFu::Capture.new(:iface => 'en0') | |
# Set the bpf to filter ipv4 tcp connections with my host on port 22 | |
cap.bpf(:filter => "ip host #{my_ip} and tcp port 22") | |
# Start capturing packs | |
cap.start | |
# Should need to process the packets with .stream() as I've shown earlier. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment