From 5baaa8947ec93287aefc32cbaec5efb5fa99eacf Mon Sep 17 00:00:00 2001 From: "Satoshi Mimura (@mimura1133)" Date: Mon, 6 Jan 2020 03:39:07 +0900 Subject: [PATCH 01/10] add support for ubuntu 19.04 and kali linux --- kali/install.sh | 71 +++++++++++++++++++++++++ ubuntu/19.04/install.sh | 113 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 kali/install.sh create mode 100644 ubuntu/19.04/install.sh diff --git a/kali/install.sh b/kali/install.sh new file mode 100644 index 0000000..0913190 --- /dev/null +++ b/kali/install.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# Original : https://raw.githubusercontent.com/Microsoft/linux-vm-tools/master/arch/install-config.sh + +############################################################################### +# Update our machine to the latest code if we need to. +# + +if [ "$(id -u)" -ne 0 ]; then + echo 'This script must be run with root privileges' >&2 + exit 1 +fi + +apt update && apt upgrade -y + +if [ -f /var/run/reboot-required ]; then + echo "A reboot is required in order to proceed with the install." >&2 + echo "Please reboot and re-run this script to finish the install." >&2 + exit 1 +fi + +############################################################################### +# Install XRDP +# +apt install -y xrdp + +############################################################################### +# Configure XRDP +# +systemctl enable xrdp +systemctl enable xrdp-sesman + +# Configure the installed XRDP ini files. +# use vsock transport. +sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini +# use rdp security. +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini +# remove encryption validation. +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini +# disable bitmap compression since its local its much faster +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini +sed -n -e 's/max_bpp=32/max_bpp=24/g' /etc/xrdp/xrdp.ini +sed -i_orig -e 's/X11DisplayOffset=10/X11DisplayOffset=0/g' /etc/xrdp/sesman.ini +# rename the redirected drives to 'shared-drives' +sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini + +# Change the allowed_users +echo "allowed_users=anybody" > /etc/X11/Xwrapper.config + + +#Ensure hv_sock gets loaded +if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then + echo "hv_sock" > /etc/modules-load.d/hv_sock.conf +fi + +# Configure the policy xrdp session +cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla < ~/.xinitrc +echo "exec startxfce4" > ~/.xinitrc +echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" +echo "Reboot your machine to begin using XRDP." \ No newline at end of file diff --git a/ubuntu/19.04/install.sh b/ubuntu/19.04/install.sh new file mode 100644 index 0000000..199c423 --- /dev/null +++ b/ubuntu/19.04/install.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +# +# This script is for Ubuntu 18.04 Bionic Beaver to download and install XRDP+XORGXRDP via +# source. +# +# Major thanks to: http://c-nergy.be/blog/?p=11336 for the tips. +# + +############################################################################### +# Update our machine to the latest code if we need to. +# + +if [ "$(id -u)" -ne 0 ]; then + echo 'This script must be run with root privileges' >&2 + exit 1 +fi + +apt update && apt upgrade -y + +if [ -f /var/run/reboot-required ]; then + echo "A reboot is required in order to proceed with the install." >&2 + echo "Please reboot and re-run this script to finish the install." >&2 + exit 1 +fi + +############################################################################### +# XRDP +# + +# Install hv_kvp utils +apt install -y linux-tools-virtual +apt install -y linux-cloud-tools-virtual + +# Install the xrdp service so we have the auto start behavior +apt install -y xrdp + +systemctl stop xrdp +systemctl stop xrdp-sesman + +# Configure the installed XRDP ini files. +# use vsock transport. +sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini +# use rdp security. +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini +# remove encryption validation. +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini +# disable bitmap compression since its local its much faster +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini + +# Add script to setup the ubuntu session properly +if [ ! -e /etc/xrdp/startubuntu.sh ]; then +cat >> /etc/xrdp/startubuntu.sh << EOF +#!/bin/sh +export GNOME_SHELL_SESSION_MODE=ubuntu +export XDG_CURRENT_DESKTOP=ubuntu:GNOME +exec /etc/xrdp/startwm.sh +EOF +chmod a+x /etc/xrdp/startubuntu.sh +fi + +# use the script to setup the ubuntu session +sed -i_orig -e 's/startwm/startubuntu/g' /etc/xrdp/sesman.ini + +# rename the redirected drives to 'shared-drives' +sed -i -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini + +# Changed the allowed_users +sed -i_orig -e 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config + +# Blacklist the vmw module +if [ ! -e /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf ]; then +cat >> /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf < /etc/modules-load.d/hv_sock.conf +fi + +# Configure the policy xrdp session +cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla < Date: Sat, 1 Feb 2020 03:48:28 +0900 Subject: [PATCH 02/10] support Kali Linux 2020.1 --- kali/{ => 2019.x}/install.sh | 0 kali/2020.x/install.sh | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) rename kali/{ => 2019.x}/install.sh (100%) create mode 100644 kali/2020.x/install.sh diff --git a/kali/install.sh b/kali/2019.x/install.sh similarity index 100% rename from kali/install.sh rename to kali/2019.x/install.sh diff --git a/kali/2020.x/install.sh b/kali/2020.x/install.sh new file mode 100644 index 0000000..390edf8 --- /dev/null +++ b/kali/2020.x/install.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# Original : https://raw.githubusercontent.com/Microsoft/linux-vm-tools/master/arch/install-config.sh + +############################################################################### +# Update our machine to the latest code if we need to. +# + +if [ "$(id -u)" -ne 0 ]; then + echo 'This script must be run with root privileges' >&2 + exit 1 +fi + +apt update && apt upgrade -y + +if [ -f /var/run/reboot-required ]; then + echo "A reboot is required in order to proceed with the install." >&2 + echo "Please reboot and re-run this script to finish the install." >&2 + exit 1 +fi + +############################################################################### +# Install XRDP +# +apt install -y xrdp + +############################################################################### +# Configure XRDP +# +systemctl enable xrdp +systemctl enable xrdp-sesman + +# Configure the installed XRDP ini files. +# use vsock transport. +# sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini +sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' /etc/xrdp/xrdp.ini +# use rdp security. +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini +# remove encryption validation. +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini +# disable bitmap compression since its local its much faster +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini +sed -n -e 's/max_bpp=32/max_bpp=24/g' /etc/xrdp/xrdp.ini +sed -i_orig -e 's/X11DisplayOffset=10/X11DisplayOffset=0/g' /etc/xrdp/sesman.ini +# rename the redirected drives to 'shared-drives' +sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini + +# Change the allowed_users +echo "allowed_users=anybody" > /etc/X11/Xwrapper.config + + +#Ensure hv_sock gets loaded +if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then + echo "hv_sock" > /etc/modules-load.d/hv_sock.conf +fi + +# Configure the policy xrdp session +cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla < ~/.xinitrc +echo "exec startxfce4" > ~/.xinitrc +echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" +echo "Reboot your machine to begin using XRDP." From 85fd0c0ad7062dd5c3343235e89f128a3326b38f Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Sat, 1 Feb 2020 05:29:44 +0900 Subject: [PATCH 03/10] Update install.sh --- kali/2020.x/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kali/2020.x/install.sh b/kali/2020.x/install.sh index 390edf8..47ca6db 100644 --- a/kali/2020.x/install.sh +++ b/kali/2020.x/install.sh @@ -67,6 +67,6 @@ EOF # .xinitrc has to be modified manually. # #echo "exec gnome-session" > ~/.xinitrc -echo "exec startxfce4" > ~/.xinitrc -echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" +#echo "exec startxfce4" > ~/.xinitrc +#echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" echo "Reboot your machine to begin using XRDP." From e945ca147308bf0f2d9994a7341a390cf9d7adee Mon Sep 17 00:00:00 2001 From: DruffilaX <39039699+DruffilaX@users.noreply.github.com> Date: Sat, 8 May 2021 23:07:18 +0200 Subject: [PATCH 04/10] Update install.sh --- kali/2020.x/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/kali/2020.x/install.sh b/kali/2020.x/install.sh index 47ca6db..7ceb268 100644 --- a/kali/2020.x/install.sh +++ b/kali/2020.x/install.sh @@ -68,5 +68,6 @@ EOF # #echo "exec gnome-session" > ~/.xinitrc #echo "exec startxfce4" > ~/.xinitrc +#echo "exec mate-session" > ~/.xinitrc exec mate-session #echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" echo "Reboot your machine to begin using XRDP." From aa6615fc3fe5ad2bbde31ef5706be3b404b3d02d Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Mon, 10 May 2021 04:24:29 +0900 Subject: [PATCH 05/10] Update Readme to Reflect Archival # Conflicts: # README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 74fbba5..60e1f22 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# This Repo Has Been Archived -This repo has been archived. You can continue to use the optimized Ubuntu image that is available by default in the Hyper-V Quick Create Gallery. If you are looking for an integrated Linux developer experience on Windows, we encourage you to check out [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/). WSL 2 lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup. The ability to run Linux GUI apps in WSL is also on the [roadmap](https://devblogs.microsoft.com/commandline/whats-new-in-the-windows-subsystem-for-linux-september-2020/#gui-apps). +# Repo Overview \ No newline at end of file From e72bd42b55d8939105a0826ec5a97825f2f5d104 Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Mon, 10 May 2021 04:25:11 +0900 Subject: [PATCH 06/10] fix : readme.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60e1f22..d465d0b 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# Repo Overview \ No newline at end of file +# Repo Overview +This repository is the home of a set of bash scripts that enable and configure an enhanced session mode on Linux VM -- especially for Kali Linux -- for Hyper-V. \ No newline at end of file From 7719b5ac5396a3cb72015022f3caa51cf0e2aa40 Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Sun, 16 May 2021 09:52:47 +0900 Subject: [PATCH 07/10] add : gdm3 support for kali/2021.x script. add : ubuntu 20.10 support. (Maybe it works at 21.04 too. ) --- kali/2021.x/install.sh | 78 +++++++++++++++++++++++++++ ubuntu/20.10/install.sh | 113 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 kali/2021.x/install.sh create mode 100644 ubuntu/20.10/install.sh diff --git a/kali/2021.x/install.sh b/kali/2021.x/install.sh new file mode 100644 index 0000000..21ac47d --- /dev/null +++ b/kali/2021.x/install.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Original : https://raw.githubusercontent.com/Microsoft/linux-vm-tools/master/arch/install-config.sh + +############################################################################### +# Update our machine to the latest code if we need to. +# + +if [ "$(id -u)" -ne 0 ]; then + echo 'This script must be run with root privileges' >&2 + exit 1 +fi + +apt update && apt upgrade -y + +if [ -f /var/run/reboot-required ]; then + echo "A reboot is required in order to proceed with the install." >&2 + echo "Please reboot and re-run this script to finish the install." >&2 + exit 1 +fi + +############################################################################### +# Install XRDP +# +apt install -y xrdp + +############################################################################### +# Configure XRDP +# +systemctl enable xrdp +systemctl enable xrdp-sesman + +# Configure the installed XRDP ini files. +# use vsock transport. +# sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini +sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' /etc/xrdp/xrdp.ini +# use rdp security. +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini +# remove encryption validation. +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini +# disable bitmap compression since its local its much faster +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini +sed -n -e 's/max_bpp=32/max_bpp=24/g' /etc/xrdp/xrdp.ini +sed -i_orig -e 's/X11DisplayOffset=10/X11DisplayOffset=0/g' /etc/xrdp/sesman.ini +# rename the redirected drives to 'shared-drives' +sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini + +# Change the allowed_users +echo "allowed_users=anybody" > /etc/X11/Xwrapper.config + + +#Ensure hv_sock gets loaded +if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then + echo "hv_sock" > /etc/modules-load.d/hv_sock.conf +fi + +# Configure the policy xrdp session +cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla < ~/.xinitrc +#echo "exec startxfce4" > ~/.xinitrc +#echo "exec mate-session" > ~/.xinitrc exec mate-session +#echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" +echo "Reboot your machine to begin using XRDP." diff --git a/ubuntu/20.10/install.sh b/ubuntu/20.10/install.sh new file mode 100644 index 0000000..199c423 --- /dev/null +++ b/ubuntu/20.10/install.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +# +# This script is for Ubuntu 18.04 Bionic Beaver to download and install XRDP+XORGXRDP via +# source. +# +# Major thanks to: http://c-nergy.be/blog/?p=11336 for the tips. +# + +############################################################################### +# Update our machine to the latest code if we need to. +# + +if [ "$(id -u)" -ne 0 ]; then + echo 'This script must be run with root privileges' >&2 + exit 1 +fi + +apt update && apt upgrade -y + +if [ -f /var/run/reboot-required ]; then + echo "A reboot is required in order to proceed with the install." >&2 + echo "Please reboot and re-run this script to finish the install." >&2 + exit 1 +fi + +############################################################################### +# XRDP +# + +# Install hv_kvp utils +apt install -y linux-tools-virtual +apt install -y linux-cloud-tools-virtual + +# Install the xrdp service so we have the auto start behavior +apt install -y xrdp + +systemctl stop xrdp +systemctl stop xrdp-sesman + +# Configure the installed XRDP ini files. +# use vsock transport. +sed -i_orig -e 's/use_vsock=false/use_vsock=true/g' /etc/xrdp/xrdp.ini +# use rdp security. +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini +# remove encryption validation. +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini +# disable bitmap compression since its local its much faster +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini + +# Add script to setup the ubuntu session properly +if [ ! -e /etc/xrdp/startubuntu.sh ]; then +cat >> /etc/xrdp/startubuntu.sh << EOF +#!/bin/sh +export GNOME_SHELL_SESSION_MODE=ubuntu +export XDG_CURRENT_DESKTOP=ubuntu:GNOME +exec /etc/xrdp/startwm.sh +EOF +chmod a+x /etc/xrdp/startubuntu.sh +fi + +# use the script to setup the ubuntu session +sed -i_orig -e 's/startwm/startubuntu/g' /etc/xrdp/sesman.ini + +# rename the redirected drives to 'shared-drives' +sed -i -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini + +# Changed the allowed_users +sed -i_orig -e 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config + +# Blacklist the vmw module +if [ ! -e /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf ]; then +cat >> /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf < /etc/modules-load.d/hv_sock.conf +fi + +# Configure the policy xrdp session +cat > /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla < Date: Sun, 16 May 2021 19:02:44 +0900 Subject: [PATCH 08/10] fix : custom.conf to daemon.conf --- kali/2021.x/install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kali/2021.x/install.sh b/kali/2021.x/install.sh index 21ac47d..85505b9 100644 --- a/kali/2021.x/install.sh +++ b/kali/2021.x/install.sh @@ -63,9 +63,9 @@ ResultInactive=no ResultActive=yes EOF -# gdm3 support. -if [ -e /etc/gdm3/custom.conf ]; then - sed -i_orig -e 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf +# gdm3 support (experiment) +if [ -e /etc/gdm3/daemon.conf ]; then + sed -i_orig -e 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/daemon.conf fi ############################################################################### @@ -75,4 +75,4 @@ fi #echo "exec startxfce4" > ~/.xinitrc #echo "exec mate-session" > ~/.xinitrc exec mate-session #echo "You will have to configure .xinitrc to start your windows manager, see https://wiki.archlinux.org/index.php/Xinit" -echo "Reboot your machine to begin using XRDP." +echo "Reboot your machine to begin using XRDP." \ No newline at end of file From b2d4574970c98ee08917b7926d314dd908289d27 Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Thu, 16 Sep 2021 10:19:51 +0900 Subject: [PATCH 09/10] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d465d0b..ef6da9e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # Repo Overview -This repository is the home of a set of bash scripts that enable and configure an enhanced session mode on Linux VM -- especially for Kali Linux -- for Hyper-V. \ No newline at end of file +This repository is the home of a set of bash scripts that enable and configure an enhanced session mode on Linux VM -- especially for Kali Linux -- for Hyper-V. + +# For Kali-Linux Users. +This project's code has merged to https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/helpers/hyperv-enhanced-mode +So, please use "kali-tweaks" command instead of it. + +how to use: +https://www.kali.org/docs/virtualization/install-hyper-v-guest-enhanced-session-mode/ From a725afa421c4bd818c787152bb55dd5aca07f1dc Mon Sep 17 00:00:00 2001 From: Satoshi Mimura Date: Thu, 16 Sep 2021 10:20:03 +0900 Subject: [PATCH 10/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef6da9e..749b1dc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repository is the home of a set of bash scripts that enable and configure an enhanced session mode on Linux VM -- especially for Kali Linux -- for Hyper-V. # For Kali-Linux Users. -This project's code has merged to https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/helpers/hyperv-enhanced-mode +This project's code has merged to https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/helpers/hyperv-enhanced-mode
So, please use "kali-tweaks" command instead of it. how to use: