Fixed SPICE transport an typo on RDP transport

This commit is contained in:
Adolfo Gómez García 2019-09-23 11:31:41 +02:00
parent 99bfae10ad
commit 346c3a3d33
22 changed files with 282 additions and 224 deletions

View File

@ -30,7 +30,6 @@
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
import typing

View File

@ -165,7 +165,6 @@ class TRDPTransport(BaseRDPTransport):
OsDetector.Windows: 'windows',
OsDetector.Linux: 'linux',
OsDetector.Macintosh: 'macosx'
}.get(os['OS'])
if osName is None:

View File

@ -55,7 +55,7 @@ if xfreerdp is not None:
fnc, app = execNewXFreeRdp, xfreerdp
except Exception as e: # Valid version not found, pass to check rdesktop
# QtGui.QMessageBox.critical(parent, 'Notice', six.text_type(e), QtGui.QMessageBox.Ok) # @UndefinedVariable
# QtGui.QMessageBox.critical(parent, 'Notice', six.text_type(e), QtGui.QMessageBox.Ok)
pass
if udsrdp is not None:
@ -68,7 +68,7 @@ if app is None or fnc is None:
''')
else:
# Open tunnel
forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 3389, waitTime=sp['tunWait']) # @UndefinedVariable
forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 3389, waitTime=sp['tunWait'])
if forwardThread.status == 2:
raise Exception('Unable to open tunnel')

View File

@ -1 +1 @@
mVeXNISYgSRjJfdmw2ml60J80NSHPa3bMSDwiR71cwYRk+6uSolNfk53L7kGLR9SDIsDRIv9ruNV6LrJY2KcnAIkuWkDI62LAX7WCD0nN+H6CRS6Fbk2TFAEh6hgb/saya/mLyDmpxRpqLhuXQhHnnY90E3fWYm+ohoypu5UvqmHtBfvhYxgfGywkY/SEHOqSH4IY2bW8gfWn/4oSC6CRVVLQLsQu6v4InbZBY7GAymxCGDmDoS+CLnDoI6j+pnj9x/B2b0XT5zd3J7Q5vT8q7ZDtQjE7x2t/8WX0ZX57P0kzSuDgxP+zbnlgKD68WjHsGJStWeg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future__ import unicode_literals
import six
import os
__updated__ = '2017-05-13'
TEMPLATE = '''[virt-viewer]
type={type}
host={host}
port={port}
password={password}
tls-port={tls_port}
fullscreen={fullscreen}
title={title}:%d - Press SHIFT+F12 to Release Cursor
enable-smartcard={smartcard}
enable-usb-autoshare={usb_auto_share}
enable-usbredir={usb_auto_share}
delete-this-file={delete_file}
usb-filter=-1,-1,-1,-1,{new_usb_auto_share}
tls-ciphers=DEFAULT
host-subject={host_subject}
ca={ca}
toggle-fullscreen=shift+f11
release-cursor=shift+f12
secure-attention=ctrl+alt+end
{secure_channel}
'''
class RemoteViewerFile(object):
type = 'spice'
host = None
port = None
tls_port = None
password = None
fullscreen = False
title = 'UDS Enterprise'
host_subject = ''
ca = ''
smartcard = False
usb_auto_share = True
new_usb_auto_share = False
delete_file = True
def __init__(self, host, port, tls_port, password, ca, host_subject, fullscreen=False):
self.host = host
self.port = port
self.tls_port = tls_port
self.password = password
self.ca = ca
self.host_subject = host_subject
self.fullscreen = fullscreen
@property
def as_file(self):
return self.get()
@property
def as_file_ns(self):
return self.get(tls_port=-1)
def get(self, tls_port=None):
if tls_port is None:
tls_port = self.tls_port
fullscreen = '01'[self.fullscreen]
smartcard = '01'[self.smartcard]
delete_file = '01'[self.delete_file]
usb_auto_share = '01'[self.usb_auto_share]
new_usb_auto_share = '01'[self.new_usb_auto_share]
ca = self.ca.strip().replace('\n', '\\\\n') # So we get '\\n' and script works fine after replacement
return TEMPLATE.format(
type=self.type,
host=self.host,
port=self.port,
tls_port=self.tls_port,
password=self.password,
fullscreen=fullscreen,
title=self.title,
smartcard=smartcard,
usb_auto_share=usb_auto_share,
new_usb_auto_share=new_usb_auto_share,
delete_file=delete_file,
host_subject=self.host_subject if self.tls_port != -1 else '',
ca=ca if tls_port != -1 else '',
secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard' if tls_port != -1 else ''
)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012 Virtual Cable S.L.
# Copyright (c) 2012-2019 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@ -31,5 +31,5 @@
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
from .SPICETransport import SPICETransport
from .TSPICETransport import TSPICETransport
from .spice import SPICETransport
from .spice_tunnel import TSPICETransport

View File

@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2019 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import typing
TEMPLATE = '''[virt-viewer]
type={type}
host={host}
port={port}
password={password}
tls-port={tls_port}
fullscreen={fullscreen}
title={title}:%d - Press SHIFT+F12 to Release Cursor
enable-smartcard={smartcard}
enable-usb-autoshare={usb_auto_share}
enable-usbredir={usb_auto_share}
delete-this-file={delete_file}
usb-filter=-1,-1,-1,-1,{new_usb_auto_share}
tls-ciphers=DEFAULT
host-subject={host_subject}
ca={ca}
toggle-fullscreen=shift+f11
release-cursor=shift+f12
secure-attention=ctrl+alt+end
{secure_channel}
'''
class RemoteViewerFile:
connectionType: str = 'spice'
host: str = ''
port: typing.Optional[str] = None
tls_port: typing.Optional[str] = None
password: str
fullscreen: bool = False
title: str = 'UDS Enterprise'
host_subject: str = ''
ca: str = ''
smartcard: bool = False
usb_auto_share: bool = True
new_usb_auto_share: bool = False
delete_file: bool = True
def __init__(
self,
host: str,
port: str,
tls_port: str,
password: str,
ca: str,
host_subject: str,
fullscreen: bool = False
):
self.host = host
self.port = port
self.tls_port = tls_port
self.password = password
self.ca = ca
self.host_subject = host_subject
self.fullscreen = fullscreen
@property
def as_file(self) -> str:
return self.get()
@property
def as_file_ns(self) -> str:
return self.get('-1')
def get(self, tls_port: typing.Optional[str] = None) -> str:
if tls_port is None:
tls_port = self.tls_port
fullscreen = '01'[self.fullscreen]
smartcard = '01'[self.smartcard]
delete_file = '01'[self.delete_file]
usb_auto_share = '01'[self.usb_auto_share]
new_usb_auto_share = '01'[self.new_usb_auto_share]
ca = self.ca.strip().replace('\n', '\\\\n') # So we get '\\n' and script works fine after replacement
return TEMPLATE.format(
type=self.connectionType,
host=self.host,
port=self.port,
tls_port=self.tls_port,
password=self.password,
fullscreen=fullscreen,
title=self.title,
smartcard=smartcard,
usb_auto_share=usb_auto_share,
new_usb_auto_share=new_usb_auto_share,
delete_file=delete_file,
host_subject=self.host_subject if tls_port != '-1' else '',
ca=ca if tls_port != '-1' else '',
secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard' if tls_port != '-1' else ''
)

View File

@ -16,7 +16,7 @@ if executable is None:
</p>
''')
theFile = '''{m.r.as_file}'''
theFile = sp['as_file']
filename = tools.saveTempFile(theFile)

View File

@ -1 +1 @@
OXKEbc6+poPTlIVhceM9tzzQu5PhTPLyC/5xEnUGdGbUHlzO7LcnijVKL8FY3BhWBKrDdXRusYF4TGIQpb5ki1/F7y4A1X5aMSVDBJshrDs3WkeFgsn5VE5Dz3Ys6q23YwH0mlSNJeYLzOR9/7i+1i7H8tQ1vr6XFk9d+VzMeRpEYd7Fn1aIA70mycPlrarzyFYj4fjazUzb2PB/IzGh9ontzKaW6F0eRJ71+weTX6n+JwcgYZ+SMcH0iM4RYesGM8KVxYh0tP/y8FbfKQW2LBS1hV1dt1KWzneGelgk4XdfqfeeHuy55bdNeRfbQaOhZV8E/7oH12/Y5C5mxVWONithKXPm9unVOqv43VRUs5U9NUn8JX4s7awmqXFDJzmn5O1U1zL2CyLKISC2VdpiAjpTHN3MaJYwsvlmc+p6OgPmgHP07Zfl/sp4K6BCzz+OhbqCoIMMxjPDWB2XTxsgI/BWDiT2bfxERqYXr77RQzIbf9i+PJ1AoNe8NvA++Uv5HceoeXQg/otwIXmrqn+dwyp3Xz1IiX35Ul68RtYz+b1HdPrASbEpx9TiBlpmx33LC5R4wqptNs2CBOfpOuFiG512DTpJQ952eY94KL2vjvT43DwzSHo+N1OdAgxqXwywuNUutUdgSGlQdlBs2cyi3OaYO2TavMW7b7Lcct+KuhI=
KVdckBRbRq0iPwi9PwkkNDA7lLaopVALN+nNHanqrbNT6BT382WIx2aZQl542OOR6lr1y9A8nRDqpuqrWzwQvHESoetb/apvWKtM0H8qH3kygtN3jUwyr9854LQ3woaiykPOwBQC0w0JnSra1aeNM+rCbL035r40d7yYqHyul9fCkCuSMrnMamSBTqykKSGUOZ+dY4Wr9jYD2CEsyD3jgULlLTyTH0rVgE/1I2jiebzjgUMPHxdW1T43TXt4UQdPXb2AlUFRCgCxwxZ/0bE3bAOuxvaYG1oejT0lJPBswqlrQcYLDoAbd9hqotWqfTEB5qFEd2Xsr3TzO7ijfMlAE/UpU3Foybc8+FB90d0uGGjunsYyy+y4C5B6a/XkYfV25X2llSk21mOMGlzXDvY9FaH2CHIfiN7nUOuO1hl8p5aLr16sNMPibcRvx3bLvamexAAPMLB6r8hyQViZIHhMIT+DLXOWN3LyW4U+dR3QdG7KCF06r90OZ39Wf4p6ZXTJ0xK4NJHMRn3UznOhjmHSWGGrDdM5e3N8wrvCPOAHlP5JzWb4aVAFjTUGxxjVGTZk5qWm00o1JGTwVwViTsYfqyCvxXJ1oUq4xiOwjuiheTjD00rc1OUwkGYWwTs1qVVE/q5/V6MZSgiOlteh9bx5VADzGoIyhfR8GjIpi6wFNzk=

View File

@ -21,22 +21,22 @@ if executable is None:
''')
theFile = '''{m.r.as_file_ns}'''
forwardThread1 = None
if {m.port} != -1: # @UndefinedVariable
forwardThread1, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.port}) # @UndefinedVariable
theFile = sp['as_file_ns']
if sp['port'] != '-1':
forwardThread1, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port'])
if forwardThread1.status == 2:
raise Exception('Unable to open tunnel')
else:
port = -1
if {m.secure_port} != -1: # @UndefinedVariable
theFile = '''{m.r.as_file}'''
if sp['secure_port'] != '-1':
theFile = sp['as_file']
if port != -1:
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port'])
else:
forwardThread2, secure_port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port'])
if forwardThread2.status == 2:
raise Exception('Unable to open tunnel')
@ -49,6 +49,4 @@ theFile = theFile.format(
)
filename = tools.saveT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ZobEsA0b9YKpMZ5FhH1cx5sDQtZTEW9/YrA+cP8KC4UJ+uRuebbF96rKJL6l1OYX88aWoFtRNFf92QvSREwJFmA9MGnpHphdqo4bmwS06CEDn6KE3AxR76ICcJvoioBvO+F+X7CRll7KNJumIB60k74XNxKdBdlR8fV+PDY1kP0RvwQYii2z/40zRFB8l7BnvSs8OgSwACHoKDcsESAUvAwVSi6q9mmTZkKvrpDu0fZIstn4iLFgOS+PnwJYZv5dmW3SrE7DCnwn6ktZMqGCQoRZ2R+Ydi1mnH8+CTf1F03Vxn4UUwZ+G5gPMYk4iW0FhX543TdqBA=

View File

@ -25,7 +25,7 @@ if not os.path.isfile(remoteViewer):
''')
theFile = '''{m.r.as_file}'''
theFile = sp['as_file']
filename = tools.saveTempFile(theFile)

View File

@ -1 +1 @@
WJbaOk3Y6vCy79Hl1mcMMU94Kz7OxFm4/XABVcxRyGboYMqBFVxmfr6wyX0szpSaJl1HJuiXhYWT00ssAyqSoC5gKKBqVrM/+y/CDnIxZDyjZFS0o2VoCgeVVJZS7wgJWiLF9U/9/G+xNyJ4ah+YDHuxtqRqTK5ZvfAyOitlOzRSZp6ymUtZXx6XxIvFP29waZuk17zHQnURQvKdHKsopIjktJXMRahPjGROm+nA/5mRwh91oCJ55o+oW+HHf5VjSwIa7CMHLMVC65mPt21S62++42cgDwgutzVF8Oq/5qcPt2u97RfSCqtS/4fCgO9Us+ClpIIK543vk135SMLDJTWianK1zQve89Op1mE1kZDWKhp2G7+5XHasVOn7mrA1zIGBSxjHL62m5GxvBs9C0x6pTkPh23PEC05i9HrxMzItgp7WSiKVmkDm8QKUukv5T3O3T8zBSL2sfww0CjjF6TvKPrXm9AkUL9r/tnscMHW0yuL3zvonwjhJYleDmfVSFS5hUDYJcgMiBuGHGQCOWD4A5rNTTojE5rvT8p8Ec9xTgjAHhQjFn3zryis1pBVfPfhU/wEmYY7J/sXNSstrJjcLobMNc/6BA7RnyMRwARvGnZSGQjwCjYFlC23fWqOd+xI8+8/HfBntSL1MIwbwy3hkNwyzbjhNBV8IubCfNnM=
omMUcXLu3wGpKRISFlcEG9j0GWbhkud++umoXOoAREnLPlqwxxlIiWEaB5fkTR2ZjPFIXB/lQzGN28PEDbCkxagXb8KA+zXWmYvwkj3uB0QpCkfk0I+5/0cy5p1njxaAyENGZQFVZorqWvtWzuaFsDZrDZvV0qygWK/a7TTwQOxr2xFElnG+u/HzSNx09VzAIeVNkIu/3xP3LA6fo5/uzswDDFmRSch02aFp7AL6PBroq2mdN4aopu/xsdSAEdRzSumPWRLNLVd/yttfW+OOvMX6liUQr0CkFP0BQrHeAJnZVHXVnUNYDqRvnb3m9DjVfjUbFRs5vljxgr9zlcmFRdUXOJMYgDZelMqY0MidOPStoxnx/VHNijurMyBF4rlra0jIAkojqwNMxe788A9WJwKmPxkgeBiqVrVNYgSUpGWixSp3UpNGOtyD6jbY0ghnABoED/3NQl2NZj93SUHliUV14shf6pkrcxk7I4AB0BSIvvLRX6B3sN5hk6wm5rgzLpPl1DlgRGLvCLuLyp8cqiXQalntWPThck9OZLL9MATRK5BkPqNx5M2eEl3gqNNYKwnm+cEFvwbUhSQKsnyqpKCdzQJzp6LkgO4XuSdP4GrNCjUObL4X6Ogq2kb/tc3//ouvES81M11aeS84jBV7+PRcibLXc0t7gcyAUuRxlnc=

View File

@ -25,22 +25,22 @@ if not os.path.isfile(remoteViewer):
</p>
''')
theFile = '''{m.r.as_file_ns}'''
if {m.port} != -1: # @UndefinedVariable
forwardThread1, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.port}) # @UndefinedVariable
theFile = sp['as_file_ns']
if sp['port'] != '-1':
forwardThread1, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port'])
if forwardThread1.status == 2:
raise Exception('Unable to open tunnel')
else:
forwardThread1 = None
port = -1
if {m.secure_port} != -1: # @UndefinedVariable
theFile = '''{m.r.as_file}'''
if sp['secure_port'] != '-1':
theFile = sp['as_file']
if port != -1:
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port'])
else:
forwardThread2, secure_port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port'])
if forwardThread2.status == 2:
raise Exception('Unable to open tunnel')
@ -53,5 +53,4 @@ theFile = theFile.format(
)
filename = tools.saveTempFile(theFile)
subprocess.Popen([remoteViewer, filename])

View File

@ -1 +1 @@
RygPTRTwxvAx6QKdBYmM5ACYP5Q79raH3LfZtsydUR97H/R+vla+TWy7YACyiodMD+Q+jP53ROtoDHx3slcuwrLigJI5rZFcn254STwyNAytZ0My/FKFAnu6dXOW40fxb3U1/cnT6BuQiFRYmzk56uyBmvFXOrvvkkPmg3soGNhUwF22R2PmG2LKxnbRqfnt4M94CS6NEobeVz+ul6B49YOX23aOQ6UfjmuVahZGgDrpFb/eqiiC7QrntGTcqJLEMOdCm6YR1aaClnPIPDroO8RwiSkaOF9HjTkTQZzbDjMwI6akkUTr6IBQk61Lp0rM/b0OiipJKfA0UPvlzl7RiePPlHNWX59Fs86iWbAqrGeBwVTi4+hOixezBvFvt/mXLiMCNTMOhyVXCqXDV9Tm8hj5lvaJbO0ueJC5neKSbMhuyieajVvc6d0X/A3+NtfLfvZoxwA/bbb/qCUaR49U9tXGdd2AU2h/VBoSJbCOImWIF/puP8CfkRmXwJxzN6gzae4CCAAADyvyQVPMLhwNsf0rr1oqTd9k4hbjT74bdfrbj8l8K6qGSR4dEtCQskA9nHtUX3ujWCXWcQdAsOLYYYMRgzC9np3AEOiVw9fJ72qK1IXOmMcWOciLqN7bYlfq/NtfnGCUKmJ/oDRkeYogCL/Bca/B7vxxSVnyg7Bb9vw=
dR+uIC5WKTM3Iicua7Jv7YEksMy8gIf3U5MfYzh6pCNYkkdEywpuszoIxHqgn/ltIjuvY4s2kATXqQtuZ7BYCNhB7vGw/nA/PDGqpOPNDCAamRL+N15Ctjb1+olmhQgqR+D/lv7GaScO+5n579OSmrHPaZkDbRo3U9wRiMzg+FLaL6Rknz8Hirpeas4kAculg+s3BeCRmf0fghz6UI9/xf+At0sd6M76p1E/3oFiIBjBNw9yKkLiPgDzq5DrrxA0SLWBwl15IPYqNpBCGo/VMV2pBQsSWmFGS62C3R6KdjMHN9jmO+seWcfhcNF2eCk3ODcoFeZUTfvXT+GoN7u7z3Dt4CyWx9k01RqSMxXcnf+vv2MqgBZde5Lu75ZqIpYP4qBkO4h6CH5isg1KVZJW/tGWGgU3fyVAkY9oxt6B8R2xo3mQeTkY+AGH+7KQHsB9l/OU0R1jHllbEIo9wopb4/SzZLMrECDMgOscA69BFodoFt6suT+QimzPHcgCQLE8xGY9KUZ7rrEn82rr3O7bAKXlJIti+UaT+zbgOizekA5+9CJRNVsWTmFsZ+6ghqY6L/QdyWJhere3Rrzh/0mg36Jk4XEaI8GI/VI/TmtmTwgut6B5gH/6fg+yaVAqYexIcINVMSSdIZyBVeX1QXbzcgYc5QJo9+EOJrzP5U0K+pI=

View File

@ -28,7 +28,7 @@ if executable is None:
</p>
''')
theFile = '''{m.r.as_file}'''
theFile = sp['as_file']
filename = tools.saveTempFile(theFile)

View File

@ -1 +1 @@
RvUnaV1eJSTiLYd9jLweZMY8rxOEdswTRLI6kyo2kJ/2F9Y2LwfY6KqBSK5FVid3Ia5pJmUUWEei4GXsoolvon2yBT0kNrloQDKVFUWceuKHQPsxxdJtr0EkZK2pfiy1Vg+GiBv6DhIIqpmEt/Iol7OUYJliMvE0CdIcOljFG18YJvOeoe8lymWYspdrM3H49md+XrhJh9rKsUCiixgoTDldmZcgGa2CMdKISzBbc2AdWxc0Iy4/E7bc0+Fjzfci6IAAJ+fYo+15ghENwl0MP8YPLhJpTz2IEuv4Jz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,22 @@ if executable is None:
<a href="http://virt-manager.org/download/">Open download page</a>
</p>
''')
theFile = '''{m.r.as_file_ns}'''
if {m.port} != -1: # @UndefinedVariable
forwardThread1, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.port}) # @UndefinedVariable
theFile = sp['as_file_ns']
if sp['port'] != '-1':
forwardThread1, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port'])
if forwardThread1.status == 2:
raise Exception('Unable to open tunnel')
else:
forwardThread1 = None
port = -1
if {m.secure_port} != -1: # @UndefinedVariable
theFile = '''{m.r.as_file}'''
if sp['secure_port'] != '-1':
theFile = sp['as_file']
if port != -1:
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port'])
else:
forwardThread2, secure_port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.secure_port}) # @UndefinedVariable
forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port'])
if forwardThread2.status == 2:
raise Exception('Unable to open tunnel')

View File

@ -1 +1 @@
Mu46b/IOLXJKXTHm0uXdXsXIVPKniZJIpl1w2jg8dCXIVooFE/Ml3XaZkeaCq6a2AHZnsvye9OedNUD5NTSylADjGMjH3Qx3i4ACQ/T6exV4c2448KnRpjYhZJnn/wa70jdwsotW5377wulixYr7s9sRLiUMM5Vab5Wi6qeXaCxQa4EU+oOJZXhb9FewJHuZnzndOmKo28Xxfqb6hbA0id9KX7vdQnkJiSdD+ZlCa/2Dhd+lHeyM9v/4NDhzT0gHcs/Qr5OC2WTX/XyiKCYqOKazJKoUq19eeMdVYs5xrG8W5AEBtlDDEhpG1lJdn5xAwHzhtWmDaCa64xMu86aStaY2+s8zdtdAgO1jjTz0SPu4NqAwv/p0HwHsT2qdo9ukkiIBe0tYjgEEKbzTxMk83vs+o17mcNpSKMDJX4hU87XLx9K1TsVoOhMhqM2oBgkMgq9CBCeslpLzP5e/R0edjs1yuoV8tgkaJTZ/GFV05PU3Ggt7Ndak60irFKJfKB6KDU1UpZPGIFEjI74wOJdabZ9Il3ztmB/+NeVhK01YrizyqLbAFLDspClaq8wTvPvg8yYLcMnwthVkkZV8MU7qcTK9150On4sq9LH7wEEZR+aILl6MQvo/SQ3rw50TKWjEGrZk+YU3IszxhUyr5D/LPfbnJoZn/ofNWrUXjaP247s=
WxhSxSYZISZNlj+Slprz8cdzstKFghx3zuQXdMmakzg5mLDyetwR9cSdWRkYd9vcP8j6aeufbK1io4rwvsdxu+7jRLSL9GVwB+MbIQYrBZ7RbiA2hqWhzQ/LCncSL73Jq9jZtt3i2pgWyA691z8UUbpts6wimsn6cDXQtEHda7MOFIi4Nzlzjf8AMpPTCkPldIDiXhyH+nuCXdzpOY32Gvrq8w6eTQrUWF8dswa1er0SQJENc2StEh9Tt1378QwTBtPQNgyop++sv/FhLdDB8hBQliX5LX7t9NxzZcvyFBYHqFnfXEsYc2bWWkt264CWfULREPLRQK11UWZ51ldvY1+xFOEg1eGAna8nWhapZ9R5DagSfehokpAov30Y0PwjTx5MGxiubd0gMeP4Vr2YZ77qBb5JnPKplEH2VsHS7TRgJyKNf2xI9Yw80iGSrO8LUC6L+9+cLDACyrmFINUA/2sFbRLjqdogY7CREIMzP07DUOluEcNgMnPLBKrTZ5U9nxnwgdgptLZgDNJHagitAiW5zMS10lEnJKRLZ0zVgWdiFna29SB7o75jO5M0LA+adIOzRH4G0C5vFYiiMVwsfLhqT3nUvaacTMLslFxWbr5T4QxWJkuLNjIMypw0cOzSaPsXW1tuZXwL0CjgnXDat7iNFQZCzEDQuoDaGDWvYpE=

View File

@ -30,16 +30,19 @@
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
import typing
from django.utils.translation import ugettext_noop as _
from uds.core.util import os_detector as OsDetector
from uds.core.util import tools
from .BaseSPICETransport import BaseSpiceTransport
from .RemoteViewerFile import RemoteViewerFile
from .spice_base import BaseSpiceTransport
from .remote_viewer_file import RemoteViewerFile
import logging
__updated__ = '2017-12-20'
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
from uds import models
from django.http import HttpRequest # pylint: disable=ungrouped-imports
logger = logging.getLogger(__name__)
@ -62,33 +65,43 @@ class SPICETransport(BaseSpiceTransport):
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
smartCardRedirect = BaseSpiceTransport.smartCardRedirect
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
userServiceInstance = userService.getInstance()
def getUDSTransportScript( # pylint: disable=too-many-locals
self,
userService: 'models.UserService',
transport: 'models.Transport',
ip: str,
os: typing.Dict[str, str],
user: 'models.User',
password: str,
request: 'HttpRequest'
) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]:
userServiceInstance: typing.Any = userService.getInstance()
con = userServiceInstance.getConsoleConnection()
logger.debug('Connection data: {}'.format(con))
logger.debug('Connection data: %s', con)
port, secure_port = con['port'], con['secure_port']
port = -1 if port is None else port
secure_port = -1 if secure_port is None else secure_port
# Spice connection
con = userServiceInstance.getConsoleConnection()
port: str = con['port'] or '-1'
secure_port: str = con['secure_port'] or '-1'
r = RemoteViewerFile(con['address'], port, secure_port, con['ticket']['value'], self.serverCertificate.value, con['cert_subject'], fullscreen=self.fullScreen.isTrue())
r.usb_auto_share = self.usbShare.isTrue()
r.new_usb_auto_share = self.autoNewUsbShare.isTrue()
r.smartcard = self.smartCardRedirect.isTrue()
m = tools.DictAsObj({
'r': r
})
os = {
osName = {
OsDetector.Windows: 'windows',
OsDetector.Linux: 'linux',
OsDetector.Macintosh: 'macosx'
}.get(os.OS)
}.get(os['OS'])
if os is None:
return super(self.__class__, self).getUDSTransportScript(userService, transport, ip, os, user, password, request)
if osName is None:
return super().getUDSTransportScript(userService, transport, ip, os, user, password, request)
return self.getScript('scripts/{}/direct.py'.format(os)).format(m=m)
sp = {
'as_file': r.as_file,
}
return self.getScript('scripts/{}/tunnel.py', osName, sp)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012 Virtual Cable S.L.
# Copyright (c) 2012-2019 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@ -30,28 +30,30 @@
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import os
import logging
import typing
from django.utils.translation import ugettext_noop as _
from uds.core.managers.user_preferences import CommonPrefs
from uds.core.ui import gui
from uds.core.transports.transport import Transport
from uds.core import transports
from uds.core.transports import protocols
from uds.core.util import connection
# This transport is specific for oVirt, so we need to point to it
from uds.services.OVirt.OVirtProvider import Provider as oVirtProvider
import logging
import os
__updated__ = '2017-12-20'
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
from uds import models
from django.http import HttpRequest # pylint: disable=ungrouped-imports
logger = logging.getLogger(__name__)
READY_CACHE_TIMEOUT = 30
class BaseSpiceTransport(Transport):
class BaseSpiceTransport(transports.Transport):
"""
Provides access via SPICE to service.
This transport can use an domain. If username processed by authenticator contains '@', it will split it and left-@-part will be username, and right password
@ -114,29 +116,27 @@ class BaseSpiceTransport(Transport):
tab=gui.ADVANCED_TAB
)
def isAvailableFor(self, userService, ip):
def isAvailableFor(self, userService: 'models.UserService', ip: str) -> bool:
"""
Checks if the transport is available for the requested destination ip
"""
ready = self.cache.get(ip)
if ready is None:
userServiceInstance = userService.getInstance()
userServiceInstance: typing.Any = userService.getInstance() # Disable mypy checks on this
con = userServiceInstance.getConsoleConnection()
logger.debug('Connection data: {}'.format(con))
logger.debug('Connection data: %s', con)
if con is None:
return False
port, secure_port = con['port'], con['secure_port']
port = -1 if port is None else port
secure_port = -1 if secure_port is None else secure_port
port, secure_port = con['port'] or -1, con['secure_port'] or -1
# test ANY of the ports
port_to_test = port if port != -1 else secure_port
if port_to_test == -1:
self.cache.put('cachedMsg', 'Could not find the PORT for connection', 120) # Write a message, that will be used from getCustom
logger.info('SPICE didn\'t find has any port: {}'.format(con))
logger.info('SPICE didn\'t find has any port: %s', con)
return False
self.cache.put('cachedMsg',
@ -149,36 +149,47 @@ class BaseSpiceTransport(Transport):
return ready == 'Y'
def getCustomAvailableErrorMsg(self, userService, ip):
def getCustomAvailableErrorMsg(self, userService: 'models.UserService', ip: str) -> str:
msg = self.cache.get('cachedMsg')
if msg is None:
return Transport.getCustomAvailableErrorMsg(self, userService, ip)
return transports.Transport.getCustomAvailableErrorMsg(self, userService, ip)
return msg
def processedUser(self, userService, userName):
v = self.processUserPassword(userService, userName, '')
def processedUser(self, userService: 'models.UserService', user: 'models.User') -> str:
v = self.processUserPassword(userService, user, '')
return v['username']
def processUserPassword(self, service, user, password):
def processUserPassword(self, userService: 'models.UserService', user: 'models.User', password: str) -> typing.Dict[str, str]:
username = user.getUsernameForAuth()
if self.fixedName.value != '':
if self.fixedName.value:
username = self.fixedName.value
if self.fixedPassword.value != '':
if self.fixedPassword.value:
password = self.fixedPassword.value
if self.useEmptyCreds.isTrue():
username, password = '', ''
# Fix username/password acording to os manager
username, password = service.processUserPassword(username, password)
username, password = userService.processUserPassword(username, password)
return {'protocol': self.protocol, 'username': username, 'password': password}
def getConnectionInfo(self, service, user, password):
return self.processUserPassword(service, user, password)
def getConnectionInfo(
self,
userService: typing.Union['models.UserService', 'models.ServicePool'],
user: 'models.User',
password: str
) -> typing.Dict[str, str]:
return self.processUserPassword(userService, user, password)
def getScript(self, script):
with open(os.path.join(os.path.dirname(__file__), script)) as f:
data = f.read()
return data
def getScript(self, scriptNameTemplate: str, osName: str, params: typing.Dict[str, typing.Any]) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]:
# Reads script
scriptNameTemplate = scriptNameTemplate.format(osName)
with open(os.path.join(os.path.dirname(__file__), scriptNameTemplate)) as f:
script = f.read()
# Reads signature
with open(os.path.join(os.path.dirname(__file__), scriptNameTemplate + '.signature')) as f:
signature = f.read()
return script, signature, params

View File

@ -30,24 +30,27 @@
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
import random
import string
import typing
from django.utils.translation import ugettext_noop as _
from uds.core.ui import gui
from uds.core.transports.transport import Transport
from uds.core.transports.transport import TUNNELED_GROUP
from uds.core.transports import protocols
from uds.core import transports
from uds.core.util import os_detector as OsDetector
from uds.core.util import tools
from uds.models import TicketStore
from .BaseSPICETransport import BaseSpiceTransport
from .RemoteViewerFile import RemoteViewerFile
from .spice_base import BaseSpiceTransport
from .remote_viewer_file import RemoteViewerFile
import logging
import random
import string
__updated__ = '2019-05-10'
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
from uds import models
from uds.core import Module
from django.http import HttpRequest # pylint: disable=ungrouped-imports
logger = logging.getLogger(__name__)
@ -60,8 +63,8 @@ class TSPICETransport(BaseSpiceTransport):
typeName = _('SPICE')
typeType = 'TSSPICETransport'
typeDescription = _('SPICE Protocol. Tunneled connection.')
protocol = protocols.SPICE
group = TUNNELED_GROUP
protocol = transports.protocols.SPICE
group = transports.TUNNELED_GROUP
tunnelServer = gui.TextField(label=_('Tunnel server'), order=1, tooltip=_('IP or Hostname of tunnel server sent to client device ("public" ip) and port. (use HOST:PORT format)'), tab=gui.TUNNEL_TAB)
@ -71,19 +74,27 @@ class TSPICETransport(BaseSpiceTransport):
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
smartCardRedirect = BaseSpiceTransport.smartCardRedirect
def initialize(self, values):
def initialize(self, values: 'Module.ValuesType'):
if values is not None:
if values['tunnelServer'].count(':') != 1:
raise Transport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field'))
raise transports.Transport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field'))
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
userServiceInstance = userService.getInstance()
def getUDSTransportScript( # pylint: disable=too-many-locals
self,
userService: 'models.UserService',
transport: 'models.Transport',
ip: str,
os: typing.Dict[str, str],
user: 'models.User',
password: str,
request: 'HttpRequest'
) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]:
userServiceInstance: typing.Any = userService.getInstance()
# Spice connection
con = userServiceInstance.getConsoleConnection()
port, secure_port = con['port'], con['secure_port']
port = -1 if port is None else port
secure_port = -1 if secure_port is None else secure_port
port: str = con['port'] or '-1'
secure_port: str = con['secure_port'] or '-1'
# Ticket
tunpass = ''.join(random.SystemRandom().choice(string.letters + string.digits) for _i in range(12))
@ -91,13 +102,26 @@ class TSPICETransport(BaseSpiceTransport):
sshHost, sshPort = self.tunnelServer.value.split(':')
r = RemoteViewerFile('127.0.0.1', '{port}', '{secure_port}', con['ticket']['value'], self.serverCertificate.value, con['cert_subject'], fullscreen=self.fullScreen.isTrue())
r = RemoteViewerFile(
'127.0.0.1', '{port}', '{secure_port}', con['ticket']['value'],
self.serverCertificate.value.strip(), con['cert_subject'], fullscreen=self.fullScreen.isTrue()
)
r.usb_auto_share = self.usbShare.isTrue()
r.new_usb_auto_share = self.autoNewUsbShare.isTrue()
r.smartcard = self.smartCardRedirect.isTrue()
m = tools.DictAsObj({
'r': r,
osName = {
OsDetector.Windows: 'windows',
OsDetector.Linux: 'linux',
OsDetector.Macintosh: 'macosx'
}.get(os['OS'])
if osName is None:
return super().getUDSTransportScript(userService, transport, ip, os, user, password, request)
sp = {
'as_file': r.as_file,
'as_file_ns': r.as_file_ns,
'tunUser': tunuser,
'tunPass': tunpass,
'tunHost': sshHost,
@ -105,15 +129,6 @@ class TSPICETransport(BaseSpiceTransport):
'ip': con['address'],
'port': port,
'secure_port': secure_port
})
}
os = {
OsDetector.Windows: 'windows',
OsDetector.Linux: 'linux',
OsDetector.Macintosh: 'macosx'
}.get(os.OS)
if os is None:
return super(self.__class__, self).getUDSTransportScript(userService, transport, ip, os, user, password, request)
return self.getScript('scripts/{}/tunnel.py'.format(os)).format(m=m)
return self.getScript('scripts/{}/tunnel.py', osName, sp)