tools/footprint/buster.cgi

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rwxr-xr-x

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 #!/usr/bin/perl
     2 #
     3 # This Source Code Form is subject to the terms of the Mozilla Public
     4 # License, v. 2.0. If a copy of the MPL was not distributed with this
     5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 # This is a modified version of Chris Hofmann's <chofmann@netscape.com>
     8 # infamous "browser buster" test harness. It's a bit simpler (CGI
     9 # instead of using cookies; IFRAME instead of FRAMESET), and has some
    10 # extra parameters that make it a bit easier to test with, but it's
    11 # pretty faithful otherwise.
    12 #
    13 # It accepts a couple of parameters, including
    14 #
    15 #   file=<filename> Set this to the name of the file containing
    16 #     the URLs that you want the buster to cycle through. This
    17 #     might be a security hole, so don't run this script on a
    18 #     server with s3kret stuff on it, mmkay?
    19 #
    20 #   page=<number> This is used to maintain state, and is the line
    21 #     number in the file that the buster will pull up in the
    22 #     IFRAME. Set if by hand if you need to for some reason.
    23 #
    24 #   last=<number> The buster will run until it's exhausted all
    25 #     the URLs in the file, or until it reaches this line in the
    26 #     file; e.g., setting it to "5" will load five URLs.
    27 #
    28 #   refresh=<number> The timeout (in seconds) to wait before doing
    29 #     a page refresh, and thus loading the next URL. Defaults to
    30 #     thirty.
    32 use CGI;
    34 # Find the page'th URL in the file with the specified name
    35 sub FindURL($$)
    36 {
    37     my ($file, $page) = @_;
    39     open URLS, $file
    40         || die("can't open $::File");
    42     LINE: while (<URLS>) {
    43         next LINE if /^#/;
    44         last LINE unless --$page;
    45     }
    47     close URLS;
    49     chomp;
    50     return $_;
    51 }
    53 # Scrape parameters
    54 $::Query = new CGI;
    56 $::File = $::Query->param("file");
    57 $::File = "top100.txt" unless $::File;
    59 $::Page = $::Query->param("page");
    60 $::Page = 0 unless $::Page;
    61 $::URL = FindURL($::File, ++$::Page);
    63 $::Last = $::Query->param("last");
    64 $::Last = -1 unless $::Last;
    66 $::Refresh = $::Query->param("refresh");
    67 $::Refresh = 30 unless $::Refresh;
    69 # Header
    70 print qq{Content-type: text/html
    72 <html>
    73 <head>
    74 };
    76 # Meat
    77 if ($::URL && ($::Page <= $::Last || $::Last == -1)) {
    78     # Make a web page that'll load $::URL in an IFRAME, with
    79     # a meta-refresh that'll reload us again in short order.
    80     print qq{<meta http-equiv="Pragma" content="no-cache">
    81 <meta http-equiv="refresh" content="$::Refresh;url=buster.cgi?file=$::File&page=$::Page&last=$::Last&refresh=$::Refresh">
    82 <title>BrowserBuster II: $::URL</title>
    83 <style type="text/css">
    84 body {
    85   overflow: hidden;
    86   border: 0;
    87   margin: 0;
    88 }
    89 </style>
    90 </head>
    91 <script>
    92 dump("+++ loading $::URL\\n");
    93 </script>
    94 <body>
    95 };
    96     print "$::File: $::URL";
    97     if ($::Last != -1) {
    98         print " ($::Page of $::Last)<br>";
    99     }
   100     print qq{
   101 <iframe width="100%" height="100%" src="$::URL">
   102 };
   103 }
   104 else {
   105     # Make a web page that'll close the current browser
   106     # window, terminating the test app.
   107     print qq{<head>
   108 <title>BrowserBuster II: Done!</title>
   109 <body onload="window.close();">
   110 All done!
   111 };
   112 }
   114 # Footer
   115 print qq{</body>
   116 </html>
   117 };

mercurial