maoxia.dev

a cybersecurity journey

Hyper-V Enhanced Session Mode with Parrot OS

In the end this was pretty easy to do, just nowhere online seems to explain it – maybe Hyper-V isn’t very popular to use? It will allow you to use higher screen resolutions, as well as allow the clipboard to work between host and VM 🙂

Anyway, once Parrot OS is installed, fire up the terminal then get started.

First, install the dependencies (hyperv-daemons should already be on there, but I’ll leave it here just in case)

sudo apt-get -y install hyperv-daemons pulseaudio-module-xrdp xrdp

Next we need to configure XRDP. This code is taken from the kali-tweaks script.

#!/bin/bash
# vim: et sts=4 sw=4

# Configure XRDP, cf. xrdp.ini(5).
# * use vsock transport
# * use rdp security
# * remove encryption validation
# * disable bitmap compression, since its local its much faster
#
# Note: there are several 'port=' statements in the config file,
# we match 'port=3389' (the default value) to make sure to change
# only this line.
cp -f --preserve=all "/etc/xrdp/xrdp.ini" "/etc/xrdp/xrdp.ini.backup"
sed -i \
    -e 's|^ *port=3389|port=vsock://-1:3389|' \
    -e 's|^ *security_layer=.*|security_layer=rdp|' \
    -e 's|^ *crypt_level=.*|crypt_level=none|' \
    -e 's|^ *bitmap_compression=.*|bitmap_compression=false|' \
    /etc/xrdp/xrdp.ini

# Configure the XRDP session manager, cf. sesman.ini(5).
# * set the first X display number available for xrdp-sesman to 0
# * rename the redirected drives to 'shared-drives'.
cp -f --preserve=all "/etc/xrdp/sesman.ini" "/etc/xrdp/sesman.ini.backup"
sed -i \
    -e 's|^ *X11DisplayOffset=.*|X11DisplayOffset=0|' \
    -e 's|^ *FuseMountName=.*|FuseMountName=shared-drives|' \
    /etc/xrdp/sesman.ini

# Ensure the Hyper-V sockets module gets loaded.
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
systemctl restart systemd-modules-load.service

Start up the XRDP service

sudo systemctl start xrdp

And we’re done for the linux config side of things, so shut down the VM, then open an admin Powershell session and type:

Set-VM "YourVMName" -EnhancedSessionTransportType HVSocket

On booting back up, you’ll get the XRDP login screen instead of the normal Parrot OS one and all is good.

Fixing the screen resolution in 4K

If you are using a 4K screen, you’ll probably want to fix the scaling. Usually you would just change the Hyper-V zoom mode, but this is disabled when using enhanced sessions.

Instead, load up MATE Tweak (System > Preferences > Look and Feel)

Choose the Windows tab, then change the HiDPI setting to HiDPI.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *