From 842595be954f86d0c1df05294a617dd411516807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Tue, 23 Apr 2019 14:39:06 +0200 Subject: [PATCH] clientfix --- client/full/src/UDSClient.py | 2 +- server/src/uds/REST/methods/client.py | 4 ++-- server/src/uds/transports/RDP/RDPTransport.py | 4 +++- .../src/uds/transports/RDP/scripts/windows/direct.py | 11 ++++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client/full/src/UDSClient.py b/client/full/src/UDSClient.py index 298924580..05faa46b2 100755 --- a/client/full/src/UDSClient.py +++ b/client/full/src/UDSClient.py @@ -194,7 +194,7 @@ class UDSClient(QtGui.QMainWindow): if tools.verifySignature(script, signature) is False: logger.error('Signature is invalid') - # raise Exception('Invalid UDS code signature. Please, report to administrator') + raise Exception('Invalid UDS code signature. Please, report to administrator') self.stopAnim() diff --git a/server/src/uds/REST/methods/client.py b/server/src/uds/REST/methods/client.py index 30aeeef90..2028d4f48 100644 --- a/server/src/uds/REST/methods/client.py +++ b/server/src/uds/REST/methods/client.py @@ -54,7 +54,7 @@ import logging logger = logging.getLogger(__name__) CLIENT_VERSION = UDS_VERSION -REQUIRED_CLIENT_VERSION = '2.5.0' +REQUIRED_CLIENT_VERSION = '3.0.0' # Enclosed methods under /actor path @@ -150,7 +150,7 @@ class Client(Handler): return Client.result(result={ 'script': transportScript, 'signature': signature, # It is already on base64 - 'params': json.dumps(params).encode('bz2').encode('base64'), + 'params': encoders.encode(encoders.encode(json.dumps(params), 'bz2'), 'base64', asText=True), }) except ServiceNotReadyError as e: # Refresh ticket and make this retrayable diff --git a/server/src/uds/transports/RDP/RDPTransport.py b/server/src/uds/transports/RDP/RDPTransport.py index 95984d93f..3a8fe2886 100644 --- a/server/src/uds/transports/RDP/RDPTransport.py +++ b/server/src/uds/transports/RDP/RDPTransport.py @@ -159,6 +159,9 @@ class RDPTransport(BaseRDPTransport): sp = { 'password': password, 'this_server': request.build_absolute_uri('/'), + 'ip': ip, + 'port': '3389', + 'address': r.address, } if os == 'windows': @@ -176,7 +179,6 @@ class RDPTransport(BaseRDPTransport): else: # Mac sp.update({ 'as_file': r.as_file, - 'ip': ip, 'as_cord_url': r.as_cord_url, }) if domain != '': diff --git a/server/src/uds/transports/RDP/scripts/windows/direct.py b/server/src/uds/transports/RDP/scripts/windows/direct.py index 32c418fae..9c56bc3da 100644 --- a/server/src/uds/transports/RDP/scripts/windows/direct.py +++ b/server/src/uds/transports/RDP/scripts/windows/direct.py @@ -9,7 +9,6 @@ try: except ImportError: # Python 2.7 fallback import _winreg as wreg # @UnresolvedImport, pylint: disable=import-error -import os import subprocess from uds.log import logger # @UnresolvedImport @@ -18,7 +17,7 @@ from uds import tools # @UnresolvedImport import six try: - thePass = six.binary_type("""{m.password}""".encode('UTF-16LE')) + thePass = six.binary_type(sp['password'].encode('UTF-16LE')) # @UndefinedVariable password = win32crypt.CryptProtectData(thePass, None, None, None, None, 0x01).encode('hex') except Exception: logger.info('Cannot encrypt for user, trying for machine') @@ -26,14 +25,16 @@ except Exception: try: key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, 'Software\Microsoft\Terminal Server Client\LocalDevices', 0, wreg.KEY_SET_VALUE) # @UndefinedVariable - wreg.SetValueEx(key, '{m.ip}', 0, wreg.REG_DWORD, 255) # @UndefinedVariable + wreg.SetValueEx(key, sp['ip'], 0, wreg.REG_DWORD, 255) # @UndefinedVariable wreg.CloseKey(key) # @UndefinedVariable except Exception as e: logger.warn('Exception fixing redirection dialog: %s', e) # The password must be encoded, to be included in a .rdp file, as 'UTF-16LE' before protecting (CtrpyProtectData) it in order to work with mstsc -theFile = '''{m.r.as_file}'''.format(password=password) - +theFile = sp['as_file'].format(# @UndefinedVariable + password=password, + address=sp['ip']+':'+sp['port'] # @UndefinedVariable +) filename = tools.saveTempFile(theFile) executable = tools.findApp('mstsc.exe')