Consuming Ethernet with nom
Nov 5, 2019
31 minute read

Now that we’ve found the best way to find the “default network interface”… what can we do with that interface?

Well, listen for network traffic of course!

use rawsock::open_best_library;
use std::time::Instant;

fn main() -> Result<(), Error> {
    let lib = open_best_library()?;

    let iface_name = format!(r#"\Device\NPF_{}"#, netinfo::default_nic_guid()?);
    let iface = lib.open_interface(&iface_name)?;

    println!("Listening for packets...");

    // doing some low-cost logging over here
    let start = Instant::now();
    iface.loop_infinite_dyn(&mut |packet| {
            "{:?} | received {} bytes",

Here’s a video:

Want to read more?

This post is Patreon-exclusive until November 29, 2019

Become a Patron! Log in

Become a Patron now to get early access to all my posts. Learn more