Example

The following program executes P0f in promiscuous mode and prints the IP addresses and the operating systems of the hosts.


#!/usr/bin/perl
use strict;
use Net::P0f;

my $sniffer = new Net::P0f interface => 'eth0', promiscuous => 1;
$sniffer->loop(callback => \&process_packet);

sub process_packet {
    my($header,$os_info,$link_info) = @_;
    printf "%s:%s (%s) -> %s:%s  distance=%d  link: %s\n",
        $header->{ip_src}, $header->{port_src}, $os_info->{genre},
        $header->{ip_dest}, $header->{ip_port},
        $link_info->{distance}, $link_info->{link_type}
}


YAPC::Europe 2004 20 / 36