From 03fafcf8ef46f61b3e92e748ae87d896fad4241f Mon Sep 17 00:00:00 2001 From: Lorenzo Martinico Date: Tue, 11 Sep 2018 12:03:42 +0200 Subject: [PATCH] Add custom useragent This is an initial commit to improve anonimity in Nayuos R69+. It adds the most common user agent string (Chrome R68 on Windows 10) to the chromium process at startup. This is also the first addition of a patching message to modify the ChromiumOS code. It does not modify the chromium browser code, which will be necessary for successive anonimity feature additions. This patch compiles, but it has not been tested if the user agent is actually modified when run on a board --- software/nayuos/instance.cfg | 3 ++- software/nayuos/patches/user-agent.patch | 14 ++++++++++++++ software/nayuos/scripts/cros_full_build.in | 5 +++++ software/nayuos/software.cfg | 4 +++- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 software/nayuos/patches/user-agent.patch diff --git a/software/nayuos/instance.cfg b/software/nayuos/instance.cfg index d51e875f11..90e528fa9a 100644 --- a/software/nayuos/instance.cfg +++ b/software/nayuos/instance.cfg @@ -99,7 +99,7 @@ context = recipe = slapos.recipe.template:jinja2 template = {{ software_dir }}/scripts/cros_full_build.in rendered = ${directory:run}/cros_full_build -md5sum = 2a64b5cc0314ec2221a949928956f5c0 +md5sum = ff09ba2bda748af933c78de4df9149fc mode = 0700 context = key bash_path bin:bash @@ -111,6 +111,7 @@ context = key keep_cache parameters:configuration.keep_cache key ebuilds_dir nayuos-ebuilds:location raw scripts_dir {{ software_dir }}/scripts + raw patches_dir {{ software_dir }}/patches raw logo_dir {{ software_dir }}/logo # packages to be copied from our overlay into ChromiuOS' overlay # those packages will be marked as dependency of root filesystem diff --git a/software/nayuos/patches/user-agent.patch b/software/nayuos/patches/user-agent.patch new file mode 100644 index 0000000000..79f68d5c21 --- /dev/null +++ b/software/nayuos/patches/user-agent.patch @@ -0,0 +1,14 @@ +diff --git a/login_manager/chrome_setup.cc b/login_manager/chrome_setup.cc +index cbe93f471..bd72cbb09 100644 +--- a/login_manager/chrome_setup.cc ++++ b/login_manager/chrome_setup.cc +@@ -341,6 +341,9 @@ void AddSystemFlags(ChromiumCommandBuilder* builder) { + // On developer systems, set a flag to let the browser know. + if (builder->is_developer_end_user()) + builder->AddArg("--system-developer-mode"); ++ //Modify user agent to improve anonimity by preventing fingerprinting ++ const char* useragent = "$USERAGENTSTRING" ++ builder->AddArg(base::StringPrintf("--user-agent=%s",useragent)) + } + + // Adds UI-related flags to the command line. diff --git a/software/nayuos/scripts/cros_full_build.in b/software/nayuos/scripts/cros_full_build.in index fc066d7f17..83afa70045 100644 --- a/software/nayuos/scripts/cros_full_build.in +++ b/software/nayuos/scripts/cros_full_build.in @@ -152,6 +152,11 @@ increase_revision_number ${CHROMIUM_OVERLAY}/chromeos-base/openssh-server-init/ sed -i -n '/src_install/q;p' $(latest_ebuild ${CHROMIUM_OVERLAY}/chromeos-base/chromeos-sshd-init) increase_revision_number ${CHROMIUM_OVERLAY}/chromeos-base/chromeos-sshd-init/ +# modify user agent to improve anonimity by preventing fingerprinting +# TODO: scrape https://techblog.willshouse.com/2012/01/03/most-common-user-agents/ +NEWUSERAGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" +sed -i "s!\$USERAGENTSTRING!${NEWUSERAGENT}!" {{patches_dir}}/user-agent.patch +patch {{ cros_location }}/{{ branch }}/src/platform2/login_manager/chrome_setup.cc {{patches_dir}}/user-agent.patch # bashrc modifications BASH_EBUILD_DIR="${PORTAGE_STABLE}/app-shells/bash" diff --git a/software/nayuos/software.cfg b/software/nayuos/software.cfg index fc19946a06..55921989fe 100644 --- a/software/nayuos/software.cfg +++ b/software/nayuos/software.cfg @@ -6,6 +6,7 @@ extends = ../../component/libexpat/buildout.cfg ../../component/libaio/buildout.cfg ../../component/boost-lib/buildout.cfg + ../../component/patch/buildout.cfg parts += slapos-cookbook @@ -13,6 +14,7 @@ parts += git curl thin-provisioning-tools + patch versions = versions @@ -26,7 +28,7 @@ recipe = slapos.recipe.template:jinja2 template = ${:_profile_base_location_}/instance.cfg rendered = ${buildout:directory}/instance.cfg mode = 0644 -md5sum = 73f964d73367dbf280d904e408a7f9b8 +md5sum = 30389eea4851d3e353466e1a2712c54e context = key software_dir :_profile_base_location_ key instance_dir buildout:directory -- 2.30.9