From 47214705e46ba3f90122099e41f3004128958d4b Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 29 Jun 2011 18:35:23 +0000 Subject: [PATCH] Only randomize the release date if the new --randomize-release-date option is enabled. Firefox versions after 4 use a fixed date string without meaning. --- tools/uagen.pl | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/uagen.pl b/tools/uagen.pl index b865320d..214d887b 100755 --- a/tools/uagen.pl +++ b/tools/uagen.pl @@ -3,7 +3,7 @@ ############################################################################################## # uagen (http://www.fabiankeil.de/sourcecode/uagen/) # -# $Id: uagen.pl,v 1.10 2010/12/11 15:54:30 fabiankeil Exp $ +# $Id: uagen.pl,v 1.11 2011/03/08 18:43:46 fabiankeil Exp $ # # Generates a pseudo-random Firefox user agent and writes it into a Privoxy action file # and optionally into a Mozilla prefs file. For documentation see 'perldoc uagen(.pl)'. @@ -51,6 +51,10 @@ use constant { LOOP => 0, SLEEPING_TIME => 5, + # As of Firefox 4, the "Gecko token" has been frozen + # http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/ + RANDOMIZE_RELEASE_DATE => 0, + # These variables belong together. If you only change one of them, the generated # User-Agent might be invalid. If you're not sure which values make sense, # are too lazy to check, but want to change them anyway, take the values you @@ -200,11 +204,13 @@ sub generate_firefox_user_agent() { our $browser_version; our $browser_revision; our $browser_release_date; + our $randomize_release_date; my $mozillaversion = '5.0'; my $security = "U"; - my $creation_time = generate_creation_time($browser_release_date); + my $creation_time = $randomize_release_date ? + generate_creation_time($browser_release_date) : $browser_release_date; my ( $locale, $accept_language ) = generate_language_settings(); my ( $platform, $os_or_cpu ) = generate_platform_and_os; @@ -360,6 +366,7 @@ Options and their default values if there are any: [--no-hide-accept-language] [--no-logfile] [--prefs-file$mozilla_prefs_file] + [--randomize-release-date] [--quiet] [--silent] [--sleeping-time $sleeping_time] @@ -379,6 +386,7 @@ sub main() { our $no_logging = NO_LOGGING; our $logfile = UAGEN_LOGFILE; our $action_file = ACTION_FILE; + our $randomize_release_date = RANDOMIZE_RELEASE_DATE; our $browser_version = BROWSER_VERSION; our $browser_revision = BROWSER_REVISION; our $browser_release_date = BROWSER_RELEASE_DATE; @@ -399,6 +407,7 @@ sub main() { 'no-hide-accept-language' => \$no_hide_accept_language, 'no-logfile' => \$no_logging, 'no-action-file' => \$no_action_file, + 'randomize-release-date' => \$randomize_release_date, 'browser-version=s' => \$browser_version, 'browser-revision=s' => \$browser_revision, 'browser-release-date=s' => \$browser_release_date, @@ -449,14 +458,14 @@ B [B<--action-file> I] [B<--action-injection>] [B<--clean-prefs-file>] [B<--help>] [B<--language-overwrite> I] [B<--logfile> I] [B<--loop>] [B<--no-action-file>] [B<--no-logfile>] -[B<--prefs-file> I] +[B<--prefs-file> I] [B<--randomize-release-date>] [B<--quiet>] [B<--sleeping-time> I] [B<--silent>] [B<--version>] =head1 DESCRIPTION B generates a fake Firefox User-Agent and writes it into a Privoxy action file as parameter for Privoxy's B action. Operating system, architecture, -platform, language and build date are randomized. +platform, language and, optionally, the build date are randomized. The generated language is also used as parameter for the B action which is understood by Privoxy since @@ -476,10 +485,9 @@ to keep custom URL patterns. For this to work, the action file has to be already present. B neither checks the syntax nor cares if all actions are present. Garbage in, garbage out. -B<--browser-release-date> I Date when the faked -browser version was first released, format is YYYYMMDD. B will -pick a date between the release date and the actual date to use it as -build time. Some sanity checks are done, but you shouldn't rely on them. +B<--browser-release-date> I Date to use. +The format is YYYYMMDD. Some sanity checks are done, but you +shouldn't rely on them. B<--browser-revision> I Use a custom revision. B will use it without any sanity checks. @@ -521,6 +529,12 @@ Firefox's preference file is usually located in ~/.mozilla/firefox/*.default/prefs.js. Note that Firefox doesn't reread the file once it is running. +B<--randomize-release-date> Randomly pick a date between the configured +release date and the actual date. Note that Firefox versions after 4.0 +no longer provide the build date in the User-Agent header, so if you +randomize the date anyway, it will be obvious that the generated User-Agent +is fake. + B<--quiet> Don't print the generated User-Agent to the console. B<--sleeping-time> I Time to sleep. Only effective if used with B<--loop>. -- 2.39.2