📜 ⬆️ ⬇️

Forbidding to change browser settings


Yesterday at work, I needed to configure Firefox browsers on thin clients of our Internet account in such a way that users could not change some settings in the browser and surf the Internet bypassing the proxy. Searching the Internet and further customization led me to write this article. Here I will tell you how you can block some of the browser settings from changing users with playful handles.

Create a mozilla.txt file with something like this:

//
lockPref("browser.startup.homepage", "http://habrahabr.ru");
lockPref("network.proxy.type", 1);
lockPref("network.proxy.http", "192.168.1.1");
lockPref("network.proxy.http_port", 3128);
lockPref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");


The first line must be two slashes (//). The names of the necessary parameters and their values ​​can be viewed by typing about: config in the browser. For this example, I forbade users to change the settings of our proxy and home page.

Now you need to shift all the characters of this file by 13 positions in the ASCII table and get the encrypted file mozilla.cfg.
To do this, use the online service Automatic Mozilla Configurator .
Under Windows, you can use the program ByteShifter , there is also a version under Linux, but it did not work for me. It is better to create such a perl script:
')
#!/usr/bin/perl
# Byteshifting program for mozilla's netscape.cfg files
# Old netscape 4.x uses a bytechift of 7
# To decode: moz-byteshift.pl -s -7 <netscape.cfg >netscape.cfg.txt
# To encode: moz-byteshift.pl -s 7 <netscape.cfg.txt >netscape.cfg
# Mozilla uses a byteshift of 13
# To decode: moz-byteshift.pl -s -13 <mozilla.cfg >mozilla.txt
# To encode: moz-byteshift.pl -s 13 <mozilla.txt >mozilla.cfg

use strict;
use Getopt::Std;
use vars qw/$opt_s/;
getopts("s:");
die "Missing shift\n" if (!defined $opt_s);
my $buffer;
while(1) {
my $n=sysread STDIN, $buffer, 1;
last if ($n eq 0);
my $byte = unpack("c", $buffer);
$byte += 512 + $opt_s;
$buffer = pack("c", $byte);
syswrite STDOUT, $buffer, 1;
}


Save the file as mozilla_byteshift.pl , make it executable:
$ chmod +x mozilla_byteshift.pl

Put our mozilla.txt file in the folder with the script and execute it in the terminal:
$ ./mozilla_byteshift.pl -s 13 <mozilla.txt >mozilla.cfg

The resulting mozilla.cfg file should be put in the folder with the executable file Firefox:
For Linux, usually: / usr / lib / firefox /
For Windows, usually: C: \ Program Files \ Mozilla Firefox \

Now open the ./greprefs subdirectory along this path and find the file all.js there . Open this file in a text editor and add the following line to the end:
pref("general.config.filename", "mozilla.cfg");
Save the changes.

Launch Firefox and see:


All our forbidden settings are now unavailable for change!

Source: https://habr.com/ru/post/40098/


All Articles