uagen – A Firefox-User-Agent generator for Privoxy and Mozilla browsers

Nowadays uagen is maintained by the Privoxy project and included in the official releases. If you are using Privoxy already, you probably have uagen installed as well.

Otherwise you can download uagen from the Privoxy CVS repository. Copies on this website are no longer updated. uagen ships as uagen.pl to make it clear that its a Perl script, on most operating systems you can strip the extension. You probably also want to chmod +x the file to make it executable.

To read the documentation run perldoc uagen, or see below:



uagen - A Firefox User-Agent generator for Privoxy and Mozilla browsers


uagen [--action-file action_file] [--action-injection] [--browser-release-date browser_release_date] [--browser-revision browser_revision] [--browser-version browser_version] [--clean-prefs-file] [--help] [--language-overwrite language(s)] [--logfile logfile] [--loop] [--no-action-file] [--no-logfile] [--prefs-file prefs_file] [--quiet] [--sleeping-time minutes] [--silent] [--version]


uagen generates a fake Firefox User-Agent and writes it into a Privoxy action file as parameter for Privoxy's hide-user-agent action. Operating system, architecture, platform, language and build date are randomized.

The generated language is also used as parameter for the hide-accept-language action which is understood by Privoxy since version 3.0.5 beta.

Additionally the User-Agent can be written into prefs.js files which are used by many Mozilla browsers.


--action-file action_file Privoxy action file to write the generated actions into. Default is /etc/privoxy/user-agent.action.

--action-injection Don't generate a new action file from scratch, but read an old one and just replace the action values. Useful to keep custom URL patterns. For this to work, the action file has to be already present. uagen neither checks the syntax nor cares if all actions are present. Garbage in, garbage out.

--browser-release-date browser_release_date Date when the faked browser version was first released, format is YYYYMMDD. uagen 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.

--browser-revision browser_revision Use a custom revision. uagen will use it without any sanity checks.

--browser-version browser_version Use a custom browser version. uagen will use it without any sanity checks.

--clean-prefs-file The prefs_file is read and the variables general.useragent.override and intl.accept_languages are removed. Only effective if prefs_file is set, and only useful if you want to use the browser's defaults again.

--help List command line options and exit.

--language-overwrite language(s) Comma separated list of language codes to overwrite the default values. uagen chooses one of them for the generated User-Agent, by default the chosen language in lower cases is also used as hide-accept-language parameter.

--logfile logfile Logfile to save error messages and the generated User-Agents. Default is /var/log/uagen.log.

--loop Don't exit after the generation of the action file. Sleep for a while and generate a new one instead. Useful if you don't have cron(8).

--no-logfile Don't log anything.

--no-action-file Don't write the action file.

--no-hide-accept-language Stay compatible with Privoxy 3.0.3 and don't generate the hide-accept-language action line. You should really update your Privoxy version instead.

--prefs-file prefs_file Use the generated User-Agent to set the general.useragent.override variable in the Mozilla preference file prefs_file, The intl.accept_languages variable will be set as well.

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.

--quiet Don't print the generated User-Agent to the console.

--sleeping-time minutes Time to sleep. Only effective if used with --loop.

--silent Don't print the generated User-Agent to the console.

--version Print version and exit.

The second dash is optional, options can be shortened, as long as there are no ambiguities.


In Privoxy's configuration file the line:

    actionsfile user-agent.action

should be added after:

    actionfile default.action

and before:

    actionfile user.action

This way the user can still use custom User-Agents in user.action. user-agent has to be the name of the generated action file.

If you are using Privoxy 3.0.6 or earlier, don't add the ``.action'' extension.


Without any options, uagen creates an action file like:

 {+hide-accept-language{en-ca} \
  +hide-user-agent{Mozilla/5.0 (X11; U; OpenBSD i386; en-CA; rv: Gecko/20060628 Firefox/} \

with the --no-accept-language option the generated file could look like this one:

 {+hide-user-agent{Mozilla/5.0 (X11; U; FreeBSD i386; de-DE; rv: Gecko/20060720 Firefox/} \


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.

Mozilla users can alter the browser's User-Agent with the --prefs-file option. But note that the preference file is only read on startup. If the browser is already running, uagen's changes will be ignored.

Hiding the User-Agent is pointless if the browser accepts all cookies or even is configured for remote maintenance through Flash, JavaScript, Java or similar security problems.


Some parameters can't be specified at the command line.




Fabian Keil <fk@fabiankeil.de>


http://www.fabiankeil.de/blog-surrogat/2006/01/26/firefox-user-agent-generator.html (German)