Skip to content

Instantly share code, notes, and snippets.

@chluehr
Created December 14, 2010 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chluehr/740539 to your computer and use it in GitHub Desktop.
Save chluehr/740539 to your computer and use it in GitHub Desktop.
Ethernet scan for http requests (headers)
#!/usr/bin/perl -w
use strict;
use lib 'lib';
use Class::Accessor;
use Net::Pcap;
use Sniffer::HTTP;
use Data::Dumper;
=head1 NAME
live-http-headers.pl - Dump the headers of HTTP connections as they happen
=head1 SYNTAX
live-http-headers.pl INTERFACE
C<INTERFACE> is the name of the interface, or on Windows, a substring
of the description of the interface. If none is given, the program
defaults to C<any> on Linux and dies on Windows.
=cut
my $VERBOSE = 1;
my $device = $ARGV[0];
if ($^O =~ /MSWin32|cygwin/ && $device) {
$device = qr/$device/i
};
my $sniffer = Sniffer::HTTP->new(
callbacks => {
request => sub { my ($req,$conn) = @_; print ">>>\n", $req->as_string },
response => sub { my ($res,$req,$conn) = @_; print "<<<\n", $res->status_line,"\n",$res->headers->as_string },
log => sub { print $_[0] if $VERBOSE },
tcp_log => sub { print $_[0] if $VERBOSE > 1 },
}
)->run( $device, $ARGV[1] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment