X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=tools%2Fuagen.pl;h=b6af7332751fdef522ab574bee6f5f1d3cd016fc;hp=fe1c27cfacab73791ad54564f0dbafcb20e6b6c3;hb=a5b4d31ab5ad2ed24cdb53ffa92679411b4176b0;hpb=334ae4607182dbbf5d42f685d640dbb5268b7e95 diff --git a/tools/uagen.pl b/tools/uagen.pl index fe1c27cf..b6af7332 100755 --- a/tools/uagen.pl +++ b/tools/uagen.pl @@ -1,24 +1,23 @@ #!/usr/bin/perl ############################################################################################## -# uagen (http://www.fabiankeil.de/sourcecode/uagen/) -# -# $Id: uagen.pl,v 1.15 2011/06/29 20:29:29 fabiankeil Exp $ +# uagen (https://www.fabiankeil.de/sourcecode/uagen/) # # 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)'. # -# Examples (created with v1.0): +# Examples (created with v1.2.2): # -# Mozilla/5.0 (X11; U; NetBSD i386; en-US; rv:1.8.0.2) Gecko/20060421 Firefox/1.5.0.2 -# Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-CA; rv:1.8.0.2) Gecko/20060425 Firefox/1.5.0.2 -# Mozilla/5.0 (X11; U; SunOS i86pc; no-NO; rv:1.8.0.2) Gecko/20060420 Firefox/1.5.0.2 -# Mozilla/5.0 (X11; U; Linux x86_64; de-AT; rv:1.8.0.2) Gecko/20060422 Firefox/1.5.0.2 -# Mozilla/5.0 (X11; U; NetBSD i386; en-US; rv:1.8.0.2) Gecko/20060415 Firefox/1.5.0.2 -# Mozilla/5.0 (X11; U; OpenBSD sparc64; pl-PL; rv:1.8.0.2) Gecko/20060429 Firefox/1.5.0.2 -# Mozilla/5.0 (X11; U; Linux i686; en-CA; rv:1.8.0.2) Gecko/20060413 Firefox/1.5.0.2 +# Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (Macintosh; PPC Mac OS X; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; NetBSD i386; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; OpenBSD alpha; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; ElectroBSD amd64; rv:78.0) Gecko/20100101 Firefox/78.0 +# Mozilla/5.0 (X11; FreeBSD i386; rv:78.0) Gecko/20100101 Firefox/78.0 # -# Copyright (c) 2006-2011 Fabian Keil +# Copyright (c) 2006-2020 Fabian Keil # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -40,7 +39,7 @@ use Getopt::Long; use constant { - UAGEN_VERSION => 'uagen 1.1', + UAGEN_VERSION => 'uagen 1.2.2', UAGEN_LOGFILE => '/var/log/uagen.log', ACTION_FILE => '/etc/privoxy/user-agent.action', @@ -52,7 +51,7 @@ use constant { 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/ + # https://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 @@ -60,8 +59,8 @@ use constant { # are too lazy to check, but want to change them anyway, take the values you # see in the "Help/About Mozilla Firefox" menu. - BROWSER_VERSION => "5.0", - BROWSER_REVISION => '5.0', + BROWSER_VERSION => "78.0", + BROWSER_REVISION => '78.0', BROWSER_RELEASE_DATE => '20100101', }; @@ -130,10 +129,16 @@ sub generate_language_settings() { sub generate_platform_and_os() { my %os_data = ( + ElectroBSD => { + karma => 1, + platform => 'X11', + architectures => [ 'i386', 'amd64' ], + order_is_inversed => 0, + }, FreeBSD => { karma => 1, platform => 'X11', - architectures => [ 'i386', 'amd64', 'sparc64', 'alpha' ], + architectures => [ 'i386', 'amd64', 'sparc64' ], order_is_inversed => 0, }, OpenBSD => { @@ -204,7 +209,6 @@ sub generate_firefox_user_agent() { our $randomize_release_date; my $mozillaversion = '5.0'; - my $security = "U"; my $creation_time = $randomize_release_date ? generate_creation_time($browser_release_date) : $browser_release_date; @@ -212,8 +216,8 @@ sub generate_firefox_user_agent() { my ( $platform, $os_or_cpu ) = generate_platform_and_os; my $firefox_user_agent = - sprintf "Mozilla/%s (%s; %s; %s; %s; rv:%s) Gecko/%s Firefox/%s", - $mozillaversion, $platform, $security, $os_or_cpu, $locale, $browser_revision, + sprintf "Mozilla/%s (%s; %s; rv:%s) Gecko/%s Firefox/%s", + $mozillaversion, $platform, $os_or_cpu, $browser_revision, $creation_time, $browser_version; return $accept_language, $firefox_user_agent; @@ -235,7 +239,7 @@ sub log_to_file($) { return if $no_logging; - open(my $log_fd, ">>" . $logfile) || die "Writing " . $logfile . " failed"; + open(my $log_fd, ">>", $logfile) || die "Writing " . $logfile . " failed"; printf $log_fd UAGEN_VERSION . " ($logtime) $message\n"; close($log_fd); } @@ -277,7 +281,7 @@ sub write_action_file() { $action_file_content .= sprintf " +hide-user-agent{%s} \\\n}\n/\n", $user_agent; } - open(my $actionfile_fd, ">" . $action_file) + open(my $actionfile_fd, ">", $action_file) or log_error "Writing action file $action_file failed!"; print $actionfile_fd $action_file_content; close($actionfile_fd); @@ -295,7 +299,7 @@ sub write_prefs_file() { my $prefs_file_content = ''; my $prefsfile_fd; - if (open($prefsfile_fd, $mozilla_prefs_file)) { + if (open($prefsfile_fd, "<", $mozilla_prefs_file)) { while (<$prefsfile_fd>) { s@user_pref\(\"general.useragent.override\",.*\);\n?@@; @@ -312,7 +316,7 @@ sub write_prefs_file() { sprintf("user_pref(\"intl.accept_languages\", \"%s\");\n", $accept_language) unless $clean_prefs; - open($prefsfile_fd, ">" . $mozilla_prefs_file) + open($prefsfile_fd, ">", $mozilla_prefs_file) or log_error "Writing prefs file $mozilla_prefs_file failed!"; print $prefsfile_fd $prefs_file_content; close($prefsfile_fd); @@ -320,8 +324,8 @@ sub write_prefs_file() { } sub VersionMessage() { - printf UAGEN_VERSION . "\n" . 'Copyright (C) 2006-2011 Fabian Keil ' . - "\nhttp://www.fabiankeil.de/sourcecode/uagen/\n"; + printf UAGEN_VERSION . "\n" . 'Copyright (C) 2006-2020 Fabian Keil ' . + "\nhttps://www.fabiankeil.de/sourcecode/uagen/\n"; } sub help() { @@ -440,7 +444,6 @@ sub main() { } main(); -exit(0); =head1 NAME @@ -581,10 +584,8 @@ could look like this one: =head1 CAVEATS -If the browser opens an encrypted connection, Privoxy can't inspect -the content and the browser's headers reach the server unmodified. -It is the user's job to use Privoxy's limit-connect action to make sure -there are no encrypted connections to untrusted sites. +Use the https-inspection action to make sure Privoxy can modify +the browser's headers for encrypted traffic as well. Mozilla users can alter the browser's User-Agent with the B<--prefs-file> option. But note that the preference file is only read @@ -606,9 +607,9 @@ privoxy(1) Fabian Keil -http://www.fabiankeil.de/sourcecode/uagen/ +https://www.fabiankeil.de/sourcecode/uagen/ -http://www.fabiankeil.de/blog-surrogat/2006/01/26/firefox-user-agent-generator.html (German) +https://www.fabiankeil.de/blog-surrogat/2006/01/26/firefox-user-agent-generator.html (German) =cut