From b5ebd1f1fb44216e1737a46ca65bbef6d6529599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 18 May 2018 10:55:47 +0200 Subject: [PATCH] Added RDP option to allow only "new local drives" from windows --- .../src/uds/transports/RDP/BaseRDPTransport.py | 14 ++++++++++++-- server/src/uds/transports/RDP/RDPFile.py | 18 ++++++++++-------- server/src/uds/transports/RDP/RDPTransport.py | 6 +++--- server/src/uds/transports/RDP/TRDPTransport.py | 6 +++--- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/server/src/uds/transports/RDP/BaseRDPTransport.py b/server/src/uds/transports/RDP/BaseRDPTransport.py index 6cd0ba3da..770423455 100644 --- a/server/src/uds/transports/RDP/BaseRDPTransport.py +++ b/server/src/uds/transports/RDP/BaseRDPTransport.py @@ -42,7 +42,7 @@ from uds.core.util import connection import logging import os -__updated__ = '2018-03-21' +__updated__ = '2018-05-18' logger = logging.getLogger(__name__) @@ -65,7 +65,17 @@ class BaseRDPTransport(Transport): allowSmartcards = gui.CheckBoxField(label=_('Allow Smartcards'), order=20, tooltip=_('If checked, this transport will allow the use of smartcards'), tab=gui.PARAMETERS_TAB) allowPrinters = gui.CheckBoxField(label=_('Allow Printers'), order=21, tooltip=_('If checked, this transport will allow the use of user printers'), tab=gui.PARAMETERS_TAB) - allowDrives = gui.CheckBoxField(label=_('Allow Drives'), order=22, tooltip=_('If checked, this transport will allow the use of user drives'), tab=gui.PARAMETERS_TAB) + allowDrives = gui.ChoiceField( + label=_('Allow Drives'), + order=22, + tooltip=_('Local drives redirection allowed'), + defvalue='false', + values=[ + {'id': 'false', 'text': 'None' }, + {'id': 'dynamic', 'text': 'Only PnP drives' }, + {'id': 'true', 'text': 'All drives' }, + ], tab=gui.PARAMETERS_TAB) + allowSerials = gui.CheckBoxField(label=_('Allow Serials'), order=23, tooltip=_('If checked, this transport will allow the use of user serial ports'), tab=gui.PARAMETERS_TAB) allowClipboard = gui.CheckBoxField(label=_('Enable clipboard'), order=24, tooltip=_('If checked, copy-paste functions will be allowed'), tab=gui.PARAMETERS_TAB, defvalue=gui.TRUE) allowAudio = gui.CheckBoxField(label=_('Enable sound'), order=25, tooltip=_('If checked, sound will be redirected.'), tab=gui.PARAMETERS_TAB, defvalue=gui.TRUE) diff --git a/server/src/uds/transports/RDP/RDPFile.py b/server/src/uds/transports/RDP/RDPFile.py index 143d626a5..0fca276a0 100644 --- a/server/src/uds/transports/RDP/RDPFile.py +++ b/server/src/uds/transports/RDP/RDPFile.py @@ -39,7 +39,7 @@ from uds.core.util import OsDetector import six import shlex -__updated__ = '2018-03-21' +__updated__ = '2018-05-18' class RDPFile(object): @@ -53,7 +53,7 @@ class RDPFile(object): password = '' redirectSerials = False redirectPrinters = False - redirectDrives = False + redirectDrives = "false" # Can have "true", "false" or "dynamic" redirectHome = False redirectSmartcards = False redirectAudio = True @@ -119,7 +119,7 @@ class RDPFile(object): if self.multimedia: params.append('/multimedia') - if self.redirectDrives is True: + if self.redirectDrives != 'false': params.append('/drive:media,/media') # params.append('/home-drive') @@ -198,7 +198,7 @@ class RDPFile(object): else: params.append('-rsound:off') - if self.redirectDrives is True: + if self.redirectDrives != 'false': params.append('-rdisk:media=/media') if self.redirectSerials is True: @@ -238,7 +238,6 @@ class RDPFile(object): screenMode = self.fullScreen and "2" or "1" audioMode = self.redirectAudio and "0" or "2" serials = self.redirectSerials and "1" or "0" - drives = self.redirectDrives and "1" or "0" scards = self.redirectSmartcards and "1" or "0" printers = self.redirectPrinters and "1" or "0" compression = self.compression and "1" or "0" @@ -290,8 +289,11 @@ class RDPFile(object): if self.redirectAudio is True: res += 'audiocapturemode:i:1\n' - if self.redirectDrives is True: - res += 'drivestoredirect:s:*\n' + if self.redirectDrives != 'false': + if self.redirectDrives == 'true': + res += 'drivestoredirect:s:*\n' + else: # Dynamic + res += 'drivestoredirect:s:DynamicDrives\n' res += 'devicestoredirect:s:*\n' res += 'enablecredsspsupport:i:{}\n'.format(0 if self.enablecredsspsupport is False else 1) @@ -312,7 +314,7 @@ class RDPFile(object): {} '''.format(self.width, self.height) - drives = self.redirectDrives and "1" or "0" + drives = self.redirectDrives != 'false' and "1" or "0" audioMode = self.redirectAudio and "0" or "2" wallpaper = self.showWallpaper and 'true' or 'false' diff --git a/server/src/uds/transports/RDP/RDPTransport.py b/server/src/uds/transports/RDP/RDPTransport.py index cd9bf55a6..282c8992c 100644 --- a/server/src/uds/transports/RDP/RDPTransport.py +++ b/server/src/uds/transports/RDP/RDPTransport.py @@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) READY_CACHE_TIMEOUT = 30 -__updated__ = '2017-12-21' +__updated__ = '2018-05-18' class RDPTransport(BaseRDPTransport): @@ -103,7 +103,7 @@ class RDPTransport(BaseRDPTransport): r.domain = domain r.redirectPrinters = self.allowPrinters.isTrue() r.redirectSmartcards = self.allowSmartcards.isTrue() - r.redirectDrives = self.allowDrives.isTrue() + r.redirectDrives = self.allowDrives.value r.redirectHome = self.redirectHome.isTrue() r.redirectSerials = self.allowSerials.isTrue() r.enableClipboard = self.allowClipboard.isTrue() @@ -133,7 +133,7 @@ class RDPTransport(BaseRDPTransport): 'depth': depth, 'printers': self.allowPrinters.isTrue(), 'smartcards': self.allowSmartcards.isTrue(), - 'drives': self.allowDrives.isTrue(), + 'drives': self.allowDrives.value, 'serials': self.allowSerials.isTrue(), 'compression': True, 'wallpaper': self.wallpaper.isTrue(), diff --git a/server/src/uds/transports/RDP/TRDPTransport.py b/server/src/uds/transports/RDP/TRDPTransport.py index 752d36c37..163a0b0cb 100644 --- a/server/src/uds/transports/RDP/TRDPTransport.py +++ b/server/src/uds/transports/RDP/TRDPTransport.py @@ -48,7 +48,7 @@ import logging import random import string -__updated__ = '2017-12-21' +__updated__ = '2018-05-18' logger = logging.getLogger(__name__) @@ -131,7 +131,7 @@ class TRDPTransport(BaseRDPTransport): r.domain = domain r.redirectPrinters = self.allowPrinters.isTrue() r.redirectSmartcards = self.allowSmartcards.isTrue() - r.redirectDrives = self.allowDrives.isTrue() + r.redirectDrives = self.allowDrives.value r.redirectHome = self.redirectHome.isTrue() r.redirectSerials = self.allowSerials.isTrue() r.enableClipboard = self.allowClipboard.isTrue() @@ -165,7 +165,7 @@ class TRDPTransport(BaseRDPTransport): 'depth': depth, 'printers': self.allowPrinters.isTrue(), 'smartcards': self.allowSmartcards.isTrue(), - 'drives': self.allowDrives.isTrue(), + 'drives': self.allowDrives.value, 'serials': self.allowSerials.isTrue(), 'compression': True, 'wallpaper': self.wallpaper.isTrue(),