| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use HTTP::Proxy; |
| 7 |
use HTTP::Recorder; |
| 8 |
use Getopt::Long; |
| 9 |
use Pod::Usage; |
| 10 |
|
| 11 |
my $port = 8080; |
| 12 |
my $filename = "http_traffic"; |
| 13 |
my $show_help = ''; |
| 14 |
|
| 15 |
GetOptions ("port=i" => \$port, "file=s" => \$filename, "help" => \$show_help); |
| 16 |
pod2usage(1) if ($show_help); |
| 17 |
|
| 18 |
print "httprecorder - quick script for recording HTTP traffic\n"; |
| 19 |
|
| 20 |
my $proxy = HTTP::Proxy->new( port => $port ); |
| 21 |
print "Proxy server host:port ".$proxy->host.":".$proxy->port."\n"; |
| 22 |
|
| 23 |
# create a new HTTP::Recorder object |
| 24 |
my $agent = new HTTP::Recorder; |
| 25 |
print "Proxy control panel http://" . $agent->control . "/\n"; |
| 26 |
|
| 27 |
# set the log file (optional) |
| 28 |
$agent->file($filename); |
| 29 |
print "Recording to file $filename\n"; |
| 30 |
|
| 31 |
# set HTTP::Recorder as the agent for the proxy |
| 32 |
$proxy->agent( $agent ); |
| 33 |
|
| 34 |
# start the proxy |
| 35 |
$proxy->start(); |
| 36 |
|
| 37 |
=head1 NAME |
| 38 |
|
| 39 |
httprecorder - quick script for recording HTTP traffic |
| 40 |
|
| 41 |
=head1 SYNOPSIS |
| 42 |
|
| 43 |
httprecorder [ --port=8080 ] [ --file=http_traffic ] [ --help ] |
| 44 |
|
| 45 |
Options: |
| 46 |
--help brief help message |
| 47 |
--port Port number to use for the proxy server (default 8080) |
| 48 |
--file filename to record the traffic to (default "http_traffic") |
| 49 |
|
| 50 |
=head1 DESCRIPTION |
| 51 |
|
| 52 |
This is a quick script for using HTTP::Recorder module. If you need customizing |
| 53 |
please see the module itself |
| 54 |
|
| 55 |
=head1 Author |
| 56 |
|
| 57 |
Shmuel Fomberg <[email protected]> |
| 58 |
|
| 59 |
=head1 COPYRIGHT AND LICENSE |
| 60 |
|
| 61 |
Copyright 2011 Shmuel Fomberg. |
| 62 |
|
| 63 |
This program is free software; Released under the GNU Public License. |
| 64 |
|
| 65 |
=cut |