From 927a86c83557bbb95384b7a92b25d64b4e65cee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Wed, 6 Apr 2022 14:21:52 +0200 Subject: [PATCH] Added USB redirection policy for windows --- server/src/uds/transports/RDP/rdp.py | 2 ++ server/src/uds/transports/RDP/rdp_base.py | 37 ++++++++++++++++------ server/src/uds/transports/RDP/rdp_file.py | 8 +++++ server/src/uds/transports/RDP/rdptunnel.py | 2 ++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/server/src/uds/transports/RDP/rdp.py b/server/src/uds/transports/RDP/rdp.py index 79dfa0c5..7cde5ba8 100644 --- a/server/src/uds/transports/RDP/rdp.py +++ b/server/src/uds/transports/RDP/rdp.py @@ -71,6 +71,7 @@ class RDPTransport(BaseRDPTransport): allowClipboard = BaseRDPTransport.allowClipboard allowAudio = BaseRDPTransport.allowAudio allowWebcam = BaseRDPTransport.allowWebcam + usbRedirection = BaseRDPTransport.usbRedirection wallpaper = BaseRDPTransport.wallpaper multimon = BaseRDPTransport.multimon @@ -142,6 +143,7 @@ class RDPTransport(BaseRDPTransport): r.printerString = self.printerString.value r.linuxCustomParameters = self.customParameters.value r.enforcedShares = self.enforceDrives.value + r.redirectUSB = self.usbRedirection.value osName = { OsDetector.KnownOS.Windows: 'windows', diff --git a/server/src/uds/transports/RDP/rdp_base.py b/server/src/uds/transports/RDP/rdp_base.py index 9775e2b2..34371f9a 100644 --- a/server/src/uds/transports/RDP/rdp_base.py +++ b/server/src/uds/transports/RDP/rdp_base.py @@ -160,15 +160,34 @@ class BaseRDPTransport(transports.Transport): tab=gui.PARAMETERS_TAB, defvalue=gui.FALSE, ) + usbRedirection = gui.ChoiceField( + label=_('USB redirection'), + order=28, + tooltip=_('USB redirection policy'), + defvalue='false', + values=[ + {'id': 'false', 'text': 'Allow none'}, + {'id': 'true', 'text': 'Allow all'}, + {'id': '{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}', 'text': 'Cameras'}, + {'id': '{4d36e967-e325-11ce-bfc1-08002be10318}', 'text': 'Disk Drives'}, + {'id': '{4d36e979-e325-11ce-bfc1-08002be10318}', 'text': 'Printers'}, + {'id': '{50dd5230-ba8a-11d1-bf5d-0000f805f530}', 'text': 'Smartcards'}, + {'id': '{745a17a0-74d3-11d0-b6fe-00a0c90f57da}', 'text': 'HIDs'}, + + ], + tab=gui.PARAMETERS_TAB, + ) + + credssp = gui.CheckBoxField( label=_('Credssp Support'), - order=28, + order=29, tooltip=_('If checked, will enable Credentials Provider Support)'), tab=gui.PARAMETERS_TAB, defvalue=gui.TRUE, ) rdpPort = gui.NumericField( - order=29, + order=30, length=5, # That is, max allowed value is 65535 label=_('RDP Port'), tooltip=_('Use this port as RDP port. Defaults to 3389.'), @@ -179,7 +198,7 @@ class BaseRDPTransport(transports.Transport): screenSize = gui.ChoiceField( label=_('Screen Size'), - order=30, + order=31, tooltip=_('Screen size for this transport'), defvalue='-1x-1', values=[ @@ -203,7 +222,7 @@ class BaseRDPTransport(transports.Transport): colorDepth = gui.ChoiceField( label=_('Color depth'), - order=31, + order=32, tooltip=_('Color depth for this connection'), defvalue='24', values=[ @@ -217,7 +236,7 @@ class BaseRDPTransport(transports.Transport): wallpaper = gui.CheckBoxField( label=_('Wallpaper/theme'), - order=32, + order=33, tooltip=_( 'If checked, the wallpaper and themes will be shown on machine (better user experience, more bandwidth)' ), @@ -225,7 +244,7 @@ class BaseRDPTransport(transports.Transport): ) multimon = gui.CheckBoxField( label=_('Multiple monitors'), - order=33, + order=34, tooltip=_( 'If checked, all client monitors will be used for displaying (only works on windows clients)' ), @@ -233,20 +252,20 @@ class BaseRDPTransport(transports.Transport): ) aero = gui.CheckBoxField( label=_('Allow Desk.Comp.'), - order=34, + order=35, tooltip=_('If checked, desktop composition will be allowed'), tab=gui.DISPLAY_TAB, ) smooth = gui.CheckBoxField( label=_('Font Smoothing'), defvalue=gui.TRUE, - order=35, + order=36, tooltip=_('If checked, fonts smoothing will be allowed'), tab=gui.DISPLAY_TAB, ) showConnectionBar = gui.CheckBoxField( label=_('Connection Bar'), - order=36, + order=37, tooltip=_('If checked, connection bar will be shown (only on Windows clients)'), tab=gui.DISPLAY_TAB, defvalue=gui.TRUE, diff --git a/server/src/uds/transports/RDP/rdp_file.py b/server/src/uds/transports/RDP/rdp_file.py index 86f7b733..501c9284 100644 --- a/server/src/uds/transports/RDP/rdp_file.py +++ b/server/src/uds/transports/RDP/rdp_file.py @@ -56,6 +56,7 @@ class RDPFile: redirectSmartcards = False redirectAudio = True redirectWebcam = False + redirectUSB = 'false' # Can have, false, true, or a GUID compression = True multimedia = True alsa = True @@ -266,6 +267,13 @@ class RDPFile: res += 'drivestoredirect:s:{}DynamicDrives\n'.format(enforcedSharesStr) res += 'devicestoredirect:s:*\n' + if self.redirectUSB != 'false': + if self.redirectUSB == 'true': + res += 'usbdevicestoredirect:s:*\n' + else: + # add the USB device to the list of devices to redirect + res += 'usbdevicestoredirect:s:{}\n'.format(self.redirectUSB) + res += 'enablecredsspsupport:i:{}\n'.format( 0 if self.enablecredsspsupport is False else 1 ) diff --git a/server/src/uds/transports/RDP/rdptunnel.py b/server/src/uds/transports/RDP/rdptunnel.py index 192149ce..c9ceee2a 100644 --- a/server/src/uds/transports/RDP/rdptunnel.py +++ b/server/src/uds/transports/RDP/rdptunnel.py @@ -108,6 +108,7 @@ class TRDPTransport(BaseRDPTransport): allowClipboard = BaseRDPTransport.allowClipboard allowAudio = BaseRDPTransport.allowAudio allowWebcam = BaseRDPTransport.allowWebcam + usbRedirection = BaseRDPTransport.usbRedirection wallpaper = BaseRDPTransport.wallpaper multimon = BaseRDPTransport.multimon @@ -195,6 +196,7 @@ class TRDPTransport(BaseRDPTransport): r.printerString = self.printerString.value r.linuxCustomParameters = self.customParameters.value r.enforcedShares = self.enforceDrives.value + r.redirectUSB = self.usbRedirection.value osName = { OsDetector.KnownOS.Windows: 'windows',