PrePaidGSM.net Forum (Archived)


 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old
  (#10)
caliston (Offline)
Junior Member
Amateur Member
 
Posts: 22
Join Date: 11 Jun 2007

Country:
Default 12-05-2008, 16:53

What a coincidence! This week I've been working on the HTTP mangling too! I've come up with the following Perl script which acts as an HTTP proxy - should work in any browser on any OS. You'll need Perl installed, as well as the LWP::UserAgent module:
http://search.cpan.org/~gaas/libwww-...P/UserAgent.pm
(was already installed on my Ubuntu machine) and the HTTP::Proxy module:
http://search.cpan.org/~book/HTTP-Pr.../HTTP/Proxy.pm

Here's the script, which is very simple. It only works for HTTP, so don't try using it for HTTPS, FTP or other protocols - set your browser to go to WIND's proxy direct. I haven't done it, but it might be feasible to do a two-pass process to avoid the 1MB restriction by trying the WIND proxy, and if that fails redirect to another proxy (eg one using an SSH tunnel as I detailed above).

Code:
#!/usr/bin/perl

use HTTP::Proxy;
use LWP::UserAgent;

# create a filter to change the Content-Type header
{
  package FilterPerl;
  use base qw( HTTP::Proxy::HeaderFilter );
                          
  sub filter {
    my ( $self, $headers, $message) = @_;
    # grab the header, modify it, then write it back into the headers
    $ct=$headers->header('Content-Type');
    $ct =~ s!application/xhtml\+xml!text/html!g;
    $headers->header('Content-Type' => $ct);
  }
}

# create a new object to represent our onward connection - ie through
# WIND's proxy
my $fetcher = LWP::UserAgent->new();
$fetcher->proxy(['http','https','ftp','gopher'], 'http://192.168.200.10:9401/');
$fetcher->no_proxy('localhost');

# create our own proxy on localhost port 3128
my $proxy = HTTP::Proxy->new( port => 3128, agent => $fetcher );
# attach a filter to alter the responses returned by WIND's proxy
$proxy->push_filter( mime => undef, response => FilterPerl->new() );
# start the proxy running
$proxy->start;
Paste it into a file called something.pl and run it. The proxy will then run on localhost port 3128 for as long as the perl script is running.
   
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBulletin Skin developed by: vBStyles.com
© 2002-2020 PrePaidGSM.net