#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use LWP::Simple; use LWP::UserAgent; use HTTP::Request; use HTTP::Cookies; use HTTP::Headers; use File::Find; use File::stat; use Fcntl qw/:flock :DEFAULT/; print "Content-type: text/html\n\n"; BEGIN { $ENV{PATH} = "/usr/bin:/bin:/usr/local/bin"; use CGI::Carp qw(carpout); open(LOG, ">browser-log.txt") or print "Unable to write to mycgi-log: $!\n"; carpout(*LOG); close(LOG); } if ($ENV{REQUEST_METHOD} ne "POST") { print < mini-Browser... another Internet First!
  
WebZip mini-Browser©

Hey, Look! I'm pretending to be a new browser!*

GO to any website that requires an updated browser.** This browser now supports http and ftp websites. NOTE: Secure (https) sites or secure links will not work with this tool at this time.



* This browser sends a fake header stating that you are using a Mozilla 4 (IE5.5 compatible) browser; and does some other things behind the scenes. NOTE: this browser will only support program languages that your own browser already supports.

** This browser is not intended to be used as a full-time replacement for your regular browser. It's purpose is to view websites that you cannot view with your regular browser.
EOL my $counter = "browsercount.txt"; sysopen(COUNT, $counter, O_RDWR|O_CREAT) or die "Can't OPEN data file for READING and WRITING: $!"; flock(COUNT, LOCK_EX) or die "Cannot get an EXCLUSIVE LOCK on data file: $!"; my $num = || 0; chomp $num; $num++; seek(COUNT, 0, 0) or die "can't REWIND to beginning of data file: $!"; truncate(COUNT, 0) or die "can't TRUNCATE data file: $!"; print COUNT "$num\n"; ## Take out the line below if you don't ## want commas in your numbers. 1 while $num =~ s/(.*\d)(\d\d\d)/$1,$2/; close COUNT or warn $!; print < $num

EOL } else { $url = param('url'); print < $url
EOL ### Check for correct file extensions if ($url !~ "http|ftp") { print "









ERROR: You have entered the WRONG TYPE of FILE.
\n
" and exit 0; }; ### Prevent copying of my files if ( $url =~ "$ENV{HTTP_HOST}" ) { die "LOL... You cannot copy my files... Goodbye!"}; my ($err_msg, $data) = &bypass($url); if ($err_msg) {print "
$err_msg\n"; exit}; sub bypass { my ($url) = @_; my $data = ''; my $err_msg = ''; Err: { my $url_data = $url; my $url_html = $url; my $request = (); my $response = (); # Make initial request to the first page. This makes things # "look good" to any smart observers on the far side. We also # catch the first cookie and persist it: my $ua = new LWP::UserAgent; my $headers = new HTTP::Headers; my $cookie_jar = new HTTP::Cookies; # Simulate IE 5.5 browser: $ua->agent( 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)' ); $headers->header( 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT-ENCODING' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,ko;q=0.7,ja;q=0.3', 'HTTP_CONNECTION' => 'close', ); $headers->referer($url); # Request initial HTML page: $request = new HTTP::Request( 'GET' => $url_html, $headers, $stat ); $response = $ua->request( $request); $cookie_jar->extract_cookies( $response ); unless ($response->is_success()) { $err_msg = $response->error_as_HTML(); next Err; } # Request follow-up page, using simulated REFERER and cookies: $headers->header('HTTP_REFERER' => $url_html ); $request = new HTTP::Request('GET' => $url_data, $headers ); $cookie_jar->add_cookie_header( $request ); $response = $ua->request( $request ); $cookie_jar->extract_cookies( $response ); $base = ""; unless ($response->is_success()) { $err_msg = $response->error_as_HTML(); next Err; } $data = $response->content(); last Err; } return ($err_msg, $data); } print $base; print $data; print ""; };