コード例 #1
0
ファイル: tunnel.py プロジェクト: krishuang0610/openuds
    password = codecs.encode(
        win32crypt.CryptProtectData(thePass, None, None, None, None, 0x01),
        'hex').decode()
except Exception:
    # Cannot encrypt for user, trying for machine
    password = codecs.encode(
        win32crypt.CryptProtectData(thePass, None, None, None, None, 0x05),
        'hex').decode()

# 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 = sp['as_file'].format(  # type: ignore
    password=password,
    address='127.0.0.1:{}'.format(fs.server_address[1]))

filename = tools.saveTempFile(theFile)
executable = tools.findApp('mstsc.exe')
if executable is None:
    raise Exception(
        'Unable to find mstsc.exe. Check that path points to your SYSTEM32 folder'
    )

try:
    key = wreg.OpenKey(
        wreg.HKEY_CURRENT_USER,
        'Software\\Microsoft\\Terminal Server Client\\LocalDevices', 0,
        wreg.KEY_SET_VALUE)
    wreg.SetValueEx(key, '127.0.0.1', 0, wreg.REG_DWORD, 255)  # type: ignore
    wreg.CloseKey(key)
except Exception as e:
    # logger.warn('Exception fixing redirection dialog: %s', e)
    pass  # Key does not exists, but it's ok
コード例 #2
0

def execRdesktop(parent, rdesktop, port):
    import subprocess  # @Reimport
    params = [rdesktop] + {m.r.as_rdesktop_params} + [
        '127.0.0.1:{{}}'.format(port)
    ]  # @UndefinedVariable
    p = subprocess.Popen(params, stdin=subprocess.PIPE)
    if {m.hasCredentials}:  # @UndefinedVariable
        p.stdin.write('{m.password}')
    p.stdin.close()
    tools.addTaskToWait(p)


# Try to locate a "valid" version of xfreerdp as first option (<1.1 does not allows drive redirections, so it will not be used if found)
xfreerdp = tools.findApp('xfreerdp')
rdesktop = tools.findApp('rdesktop')
fnc, app = None, None

if rdesktop is not None:
    fnc, app = execRdesktop, rdesktop

if xfreerdp is not None:
    # Check for nice version
    try:
        try:
            version = subprocess.check_output([xfreerdp, '--version'])
        except subprocess.CalledProcessError as e:
            version = e.output

        version = float(
コード例 #3
0
ファイル: tunnel.py プロジェクト: dkmstr/openuds
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, undefined-variable
import subprocess

from uds import tools  # @UnresolvedImport
from uds.forward import forward  # @UnresolvedImport

executable = tools.findApp('remote-viewer')

if executable is None:
    raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
    Please, install appropriate package for your system.
</p>
<p>
    Please, install appropriate package for your Linux system. (probably named something like <b>virt-viewer</b>)
</p>
''')


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

    if forwardThread1.status == 2:
        raise Exception('Unable to open tunnel')
else:
コード例 #4
0
ファイル: direct.py プロジェクト: tanonl/openuds
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module
import subprocess
from os.path import expanduser

from uds import tools  # @UnresolvedImport

home = expanduser('~') + ':1;/media:1;'
keyFile = tools.saveTempFile(sp['key'])
theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port'])
filename = tools.saveTempFile(theFile)

# HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session

executable = tools.findApp('x2goclient')
if executable is None:
    raise Exception('''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p>
<p>Please, install the required packages for your platform</p>''')

subprocess.Popen([executable, '--session-conf={}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
# tools.addFileToUnlink(filename)
# tools.addFileToUnlink(keyFile)
コード例 #5
0
ファイル: direct.py プロジェクト: techkie/openuds
# pylint: disable=import-error, no-name-in-module
import os
import glob
import subprocess

from uds import tools  # @UnresolvedImport

# Lets find remote viewer
# There is a bug that when installed, the remote viewer (at least 64 bits version) does not store correctly its path, so lets find it "a las bravas"
extraPaths = ()
for env in ('PROGRAMFILES', 'PROGRAMW6432'):
    if env in os.environ:
        extraPaths += tuple(
            p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*'))

executable = tools.findApp('remote-viewer.exe', extraPaths)

if executable is None:
    raise Exception(
        '''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
    Please, install appropriate package for your system.
</p>
<p>
    <a href="http://virt-manager.org/download/">Open download page</a>
</p>
''')

theFile = '''{m.r.as_file}'''

filename = tools.saveTempFile(theFile)
コード例 #6
0
ファイル: tunnel.py プロジェクト: joaoguariglia/openuds
# pylint: disable=import-error, no-name-in-module, undefined-variable
import os
import glob
import subprocess

from uds import tools  # @UnresolvedImport
from uds.forward import forward  # @UnresolvedImport

# Lets find remote viewer
# There is a bug that when installed, the remote viewer (at least 64 bits version) does not store correctly its path, so lets find it "a las bravas"
extraPaths = ()
for env in ('PROGRAMFILES', 'PROGRAMW6432'):
    if env in os.environ:
        extraPaths += tuple(p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*'))

executable = tools.findApp('remote-viewer.exe', extraPaths)

if executable is None:
    raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
    Please, install appropriate package for your system.
</p>
<p>
    <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

    if forwardThread1.status == 2:
コード例 #7
0
ファイル: direct.py プロジェクト: dkmstr/openuds
    params = [xfreerdp] + sp['as_new_xfreerdp_params'] + ['/v:{}'.format(sp['address'])]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))


def execRdesktop(rdesktop):
    # import subprocess  # @Reimport
    params = [rdesktop] + sp['as_rdesktop_params'] + [sp['address']]  # @UndefinedVariable
    p = subprocess.Popen(params, stdin=subprocess.PIPE)
    if sp['password'] != '':  # @UndefinedVariable
        p.stdin.write(sp['password'])  # @UndefinedVariable
    p.stdin.close()
    tools.addTaskToWait(p)


# Try to locate a "valid" version of xfreerdp as first option (<1.1 does not allows drive redirections, so it will not be used if found)
xfreerdp = tools.findApp('xfreerdp')
rdesktop = tools.findApp('rdesktop')
udsrdp = tools.findApp('udsrdp')
fnc, app = None, None

if rdesktop is not None:
    fnc, app = execRdesktop, rdesktop

if xfreerdp is not None:
    # Check for nice version
    try:
        try:
            version = subprocess.check_output([xfreerdp, '--version'])
        except subprocess.CalledProcessError as e:
            version = e.output
コード例 #8
0
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, undefined-variable
import subprocess
from uds.forward import forward  # @UnresolvedImport

from uds import tools  # @UnresolvedImport

try:
    cmd = tools.findApp('nxclient', ['/usr/NX/bin/'])
    if cmd is None:
        raise Exception()
except Exception:
    raise Exception('''<p>You need to have installed NX Client version 3.5 in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system.</p>
''')

# Open tunnel
forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port'])
if forwardThread.status == 2:
    raise Exception('Unable to open tunnel')


theFile = sp['as_file_for_format'].format(
    address='127.0.0.1',
    port=port
)

filename = tools.saveTempFile(theFile)
コード例 #9
0
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module
import subprocess

from uds import tools  # @UnresolvedImport

executable = tools.findApp('remote-viewer')

if executable is None:
    raise Exception(
        '''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
    Please, install appropriate package for your Linux system. (probably named something like <b>remote-viewer</b>)
</p>
''')

theFile = '''{m.r.as_file}'''

filename = tools.saveTempFile(theFile)

subprocess.Popen([executable, filename])

# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
コード例 #10
0
ファイル: tunnel.py プロジェクト: joaoguariglia/openuds
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable

import os
import subprocess
from uds.forward import forward  # @UnresolvedImport

from uds import tools  # @UnresolvedImport

import six

forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22)

if forwardThread.status == 2:
    raise Exception('Unable to open tunnel')

tools.addTaskToWait(forwardThread)

keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(export='c:\\:1;', keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port)
filename = tools.saveTempFile(theFile)

x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient'
executable = tools.findApp('x2goclient.exe', [x2goPath])
if executable is None:
    raise Exception('''<p>You must have installed latest X2GO Client in default program file folder in order to connect to this UDS service.</p>
<p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>''')

subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
コード例 #11
0
ファイル: tunnel.py プロジェクト: AlexeyBychkov/openuds
from PyQt4 import QtCore, QtGui
import win32crypt  # @UnresolvedImport
import os
import subprocess
from uds.forward import forward  # @UnresolvedImport

from uds import tools  # @UnresolvedImport

import six

forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 3389)

if forwardThread.status == 2:
    raise Exception('Unable to open tunnel')

# 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=win32crypt.CryptProtectData(six.binary_type('{m.password}'.encode('UTF-16LE')), None, None, None, None, 0x01).encode('hex'),
    address='127.0.0.1:{{}}'.format(port)
)

filename = tools.saveTempFile(theFile)
executable = tools.findApp('mstsc.exe')
if executable is None:
    raise Exception('Unable to find mstsc.exe')

subprocess.Popen([executable, filename])
tools.addFileToUnlink(filename)

# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
コード例 #12
0
ファイル: direct.py プロジェクト: glyptodon/openuds
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module
import subprocess

from uds import tools  # @UnresolvedImport


try:
    cmd = tools.findApp('nxclient', ['/usr/NX/bin/'])
    if cmd is None:
        raise Exception()

except Exception:
    raise Exception('''<p>You need to have installed NX Client version 3.5 in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system.</p>
''')

filename = tools.saveTempFile('''{r.as_file}''')
tools.addTaskToWait(subprocess.Popen([cmd, '--session', filename]))
tools.addFileToUnlink(filename)
コード例 #13
0
ファイル: tunnel.py プロジェクト: karthik-arjunan/testuds
                              '{m.tunPass}', '{m.ip}', 22)

if forwardThread.status == 2:
    raise Exception('Unable to open tunnel')

tools.addTaskToWait(forwardThread)

home = expanduser('~').replace('\\', '\\\\') + '#1;'
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(export=home,
                              keyFile=keyFile.replace('\\', '/'),
                              ip='127.0.0.1',
                              port=port)
filename = tools.saveTempFile(theFile)

x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient'
executable = tools.findApp('x2goclient.exe', [x2goPath])
if executable is None:
    raise Exception(
        '''<p>You must have installed latest X2GO Client in default program file folder in order to connect to this UDS service.</p>
<p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>'''
    )

subprocess.Popen([
    executable, '--session-conf={{}}'.format(filename),
    '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu',
    '--add-to-known-hosts'
])

# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
コード例 #14
0
ファイル: tunnel.py プロジェクト: AlexeyBychkov/openuds
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, undefined-variable
from PyQt4 import QtCore, QtGui  # @UnusedImport
import subprocess
from uds.forward import forward  # @UnresolvedImport

from uds import tools  # @UnresolvedImport

import six

try:
    cmd = tools.findApp("nxclient", ["/usr/NX/bin/"])
    if cmd is None:
        raise Exception()
except Exception:
    raise Exception(
        """<p>You need to have installed NX Client version 3.5 in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system.</p>
"""
    )

forwardThread, port = forward(
    "{m.tunHost}", "{m.tunPort}", "{m.tunUser}", "{m.tunPass}", "{m.ip}", {m.port}
)  # @UndefinedVariable
if forwardThread.status == 2:
    raise Exception("Unable to open tunnel")

コード例 #15
0
ファイル: tunnel.py プロジェクト: glyptodon/openuds
import os
import subprocess
from uds.forward import forward  # @UnresolvedImport
from os.path import expanduser

from uds import tools  # @UnresolvedImport

import six

forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22)

if forwardThread.status == 2:
    raise Exception('Unable to open tunnel')

tools.addTaskToWait(forwardThread)

home = expanduser('~') + ':1;'
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port)
filename = tools.saveTempFile(theFile)

# HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session

executable = tools.findApp('x2goclient')
if executable is None:
    raise Exception('''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p>
<p>Please, install the required packages for your platform</p>''')

subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])

コード例 #16
0
# Inject local passed sp into globals for functions
globals()['sp'] = sp  # type: ignore  # pylint: disable=undefined-variable

def execUdsRdp(udsrdp, port):
    import subprocess  # @Reimport
    params = [udsrdp] + sp['as_new_xfreerdp_params'] + ['/v:127.0.0.1:{}'.format(port)]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))


def execNewXFreeRdp(xfreerdp, port):
    import subprocess  # @Reimport
    params = [xfreerdp] + sp['as_new_xfreerdp_params'] + ['/v:127.0.0.1:{}'.format(port)]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))

# Try to locate a "valid" version of xfreerdp as first option (<1.1 does not allows drive redirections, so it will not be used if found)
xfreerdp = tools.findApp('xfreerdp')
udsrdp = tools.findApp('udsrdp')
fnc, app = None, None

if xfreerdp:
    fnc, app = execNewXFreeRdp, xfreerdp

if udsrdp:
    fnc, app = execUdsRdp, udsrdp

if app is None or fnc is None:
    raise Exception('''<p>You need to have installed xfreerdp (>= 1.1) or rdesktop, and have them in your PATH in order to connect to this UDS service.</p>
    <p>Please, install apropiate package for your system.</p>
    <p>Also note that xfreerdp prior to version 1.1 will not be taken into consideration.</p>
''')
else: