All pastes #772620 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-13 22:50 UTC
rendered paste body
	 # Ugly IP to Hex hack for sniffer "filter" :p
	 my $pcap = Net::Pcap::open_live($dev, 1048576, 1, 1000*60, \$err);
	 Net::Pcap::loop($pcap, 1024, \&process_packet, '');

	sub process_packet {
        my($user_data, $header, $packet) = @_;
	$srip = ($ARGV[0] =~ m/(.*)\.(.*)\.(.*)\.(.*)/g);
	$hexval = sprintf("%x", $1);
	$hexvala = sprintf("%x", $2);
	$hexvalb = sprintf("%x", $3);
	$hexvalc = sprintf("%x", $4);

	# "Filter" :p
	if($packet =~ /"\x0".$hexval."\x0".$hexvala."\x0".$hexvalb."\x0".$hexvalc/) {
	print $packet;
	}
	}