Пример #1
0
def execNewXFreeRdp(xfreerdp, port):
    import subprocess  # @Reimport
    import os.path
    params = [
        os.path.expandvars(i) for i in [xfreerdp] +
        sp['as_new_xfreerdp_params'] + ['/v:127.0.0.1:{}'.format(port)]
    ]  # type: ignore
    tools.addTaskToWait(subprocess.Popen(params))
Пример #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)
Пример #3
0
def execRdesktop(parent, rdesktop):
    import subprocess  # @Reimport
    params = [rdesktop] + {m.r.as_rdesktop_params} + ['{m.r.address}']  # @UndefinedVariable
    p = subprocess.Popen(params, stdin=subprocess.PIPE)
    if '{m.password}' != '':
        p.stdin.write('{m.password}')
    p.stdin.close()
    tools.addTaskToWait(p)
Пример #4
0
def execUdsRdp(udsrdp):
    import subprocess  # @Reimport
    import os.path
    params = [
        os.path.expandvars(i) for i in [udsrdp] +
        sp['as_new_xfreerdp_params'] + ['/v:{}'.format(sp['address'])]
    ]  # type: ignore
    tools.addTaskToWait(subprocess.Popen(params))
Пример #5
0
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)
Пример #6
0
def execRdesktop(parent, rdesktop):
    import subprocess  # @Reimport
    params = [rdesktop] + {m.r.as_rdesktop_params} + ['{m.r.address}']  # @UndefinedVariable
    p = subprocess.Popen(params, stdin=subprocess.PIPE)
    if '{m.password}' != '':
        p.stdin.write('{m.password}')
    p.stdin.close()
    tools.addTaskToWait(p)
Пример #7
0
def execRdesktop(rdesktop, port):
    import subprocess  # @Reimport
    params = [rdesktop] + sp['as_rdesktop_params'] + ['127.0.0.1:{}'.format(port)]  # @UndefinedVariable
    p = subprocess.Popen(params, stdin=subprocess.PIPE)
    if sp['password'] != '':
        p.stdin.write(sp['password'].encode())
    p.stdin.close()
    tools.addTaskToWait(p)
Пример #8
0
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)
Пример #9
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)
Пример #10
0
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
def execNewXFreeRdp(xfreerdp):
    # import subprocess  # @Reimport
    params = [xfreerdp] + sp['as_new_xfreerdp_params'] + [
        '/v:{}'.format(sp['address'])
    ]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #12
0
from uds import tools  # @UnresolvedImport

import six

forwardThread, port = forward(sp['tunHost'],
                              sp['tunPort'],
                              sp['tunUser'],
                              sp['tunPass'],
                              sp['ip'],
                              3389,
                              waitTime=sp['tunWait'])  # @UndefinedVariable

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

tools.addTaskToWait(forwardThread)

try:
    thePass = six.binary_type(sp['password'].encode('UTF-16LE'))
    password = win32crypt.CryptProtectData(thePass, None, None, None, None,
                                           0x01).encode('hex')
except Exception:
    # Cannot encrypt for user, trying for machine
    password = win32crypt.CryptProtectData(thePass, None, None, None, None,
                                           0x05).encode('hex')

# 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(  # @UndefinedVariable
    password=password,
    address='127.0.0.1:{}'.format(port))
Пример #13
0
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index
from PyQt4 import QtCore, QtGui  # @UnusedImport
import subprocess
import os

from uds import tools  # @UnresolvedImport


cmd = "/Applications/OpenNX/OpenNX.app/Contents/MacOS/OpenNXapp"
if os.path.isfile(cmd) is False:
    raise Exception(
        """<p>You need to have installed Open NX Client in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system from <a href="http://www.opennx.net/">here</a>.</p>
"""
    )


filename = tools.saveTempFile("""{r.as_file}""")
tools.addTaskToWait(subprocess.Popen([cmd, "--session={{}}".format(filename), "--autologin", "--killerrors"]))
tools.addFileToUnlink(filename)
Пример #14
0
def execNewXFreeRdp(parent, xfreerdp, port):
    import subprocess  # @Reimport
    params = [xfreerdp] + {m.r.as_new_xfreerdp_params} + ['/v:127.0.0.1:{{}}'.format(port)]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #15
0
def execNewXFreeRdp(xfreerdp, port):
    params = [xfreerdp] + sp['as_new_xfreerdp_params'] + [
        '/v:127.0.0.1:{}'.format(port)
    ]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #16
0
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))
Пример #17
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 _winreg
import subprocess

from uds import tools  # @UnresolvedImport

try:
    k = _winreg.OpenKey(
        _winreg.HKEY_CURRENT_USER,
        'Software\\Classes\\NXClient.session\\shell\\open\\command'
    )  # @UndefinedVariable
    cmd = _winreg.QueryValue(k, '')  # @UndefinedVariable
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}''')
cmd = cmd.replace('%1', filename)
tools.addTaskToWait(subprocess.Popen(cmd))
tools.addFileToUnlink(filename)
Пример #18
0
# This is a template
# Saved as .py for easier editing
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index
import subprocess
import os

from uds import tools  # type: ignore

cmd = '/Applications/OpenNX/OpenNX.app/Contents/MacOS/OpenNXapp'
if os.path.isfile(cmd) is False:
    raise Exception(
        '''<p>You need to have installed Open NX Client in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system from <a href="http://www.opennx.net/">here</a>.</p>
''')

filename = tools.saveTempFile(sp['as_file'])  # type: ignore
tools.addTaskToWait(
    subprocess.Popen([
        cmd, '--session={{}}'.format(filename), '--autologin', '--killerrors'
    ]))  # type: ignore
tools.addFileToUnlink(filename)
Пример #19
0
                              3389,
                              waitTime=sp['tunWait'])  # @UndefinedVariable
address = '127.0.0.1:{}'.format(port)

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

else:
    if executable == msrdc:
        theFile = theFile = sp['as_file'].format(
            address='127.0.0.1:{}'.format(port))

        filename = tools.saveTempFile(theFile)
        # Rename as .rdp, so open recognizes it
        shutil.move(filename, filename + '.rdp')

        tools.addTaskToWait(subprocess.Popen(['open', filename + '.rdp']))
        tools.addFileToUnlink(filename + '.rdp')
    elif executable == xfreerdp:
        # Fix resolution...
        try:
            xfparms = fixResolution()
        except Exception as e:
            xfparms = list(
                map(
                    lambda x: x.replace('#WIDTH#', '1400').replace(
                        '#HEIGHT#', '800'), sp['as_new_xfreerdp_params']))

        params = [executable] + xfparms + ['/v:{}'.format(address)]
        subprocess.Popen(params)
Пример #20
0
def execNewXFreeRdp(parent, xfreerdp):
    import subprocess  # @Reimport
    params = [xfreerdp] + {m.r.as_new_xfreerdp_params} + ['/v:{m.r.address}']  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #21
0
                        </ul>
                    </p>
                </li>
            </ul>
            ''')
elif executable == msrdc:
    theFile = sp['as_file']  # type: ignore
    filename = tools.saveTempFile(theFile)
    # Rename as .rdp, so open recognizes it
    shutil.move(filename, filename + '.rdp')

    #tools.addTaskToWait(subprocess.Popen(['open', filename + '.rdp']))
    # Force MSRDP to be used with -a (thanks to Dani Torregrosa @danitorregrosa (https://github.com/danitorregrosa) )
    tools.addTaskToWait(
        subprocess.Popen([
            'open', '-a', '/Applications/Microsoft Remote Desktop.app',
            filename + '.rdp'
        ]))
    tools.addFileToUnlink(filename + '.rdp')
elif executable == xfreerdp:
    # Fix resolution...
    try:
        xfparms = fixResolution()
    except Exception as e:
        xfparms = list(
            map(
                lambda x: x.replace('#WIDTH#', '1400').replace(
                    '#HEIGHT#', '800'),
                sp['as_new_xfreerdp_params']))  # type: ignore

    params = [
Пример #22
0
def execNewXFreeRdp(parent, xfreerdp):
    import subprocess  # @Reimport
    params = [xfreerdp] + {m.r.as_new_xfreerdp_params} + ['/v:{m.r.address}']  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #23
0
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)

cmd = cmd.replace('%1', filename)
tools.addTaskToWait(subprocess.Popen([cmd, '--session', filename]))
tools.addFileToUnlink(filename)
Пример #24
0
def execUdsRdp(udsrdp, port):
    import subprocess
    params = [udsrdp] + {m.r.as_new_xfreerdp_params} + [
        '/v:127.0.0.1:{{}}'.format(port)
    ]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #25
0
def execNewXFreeRdp(xfreerdp):
    # import subprocess  # @Reimport
    params = [xfreerdp] + sp['as_new_xfreerdp_params'] + ['/v:{}'.format(sp['address'])]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #26
0
import _winreg
import subprocess
from uds.forward import forward  # @UnresolvedImport

from uds import tools  # @UnresolvedImport


try:
    k = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Classes\\NXClient.session\\shell\\open\\command')  # @UndefinedVariable
    cmd = _winreg.QueryValue(k, '')  # @UndefinedVariable
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')


theFile = '''{r.as_file_for_format}'''.format(
    address='127.0.0.1',
    port=port
)

filename = tools.saveTempFile(theFile)

cmd = cmd.replace('%1', filename)
tools.addTaskToWait(subprocess.Popen(cmd))
tools.addFileToUnlink(filename)
Пример #27
0
def execNewXFreeRdp(parent, xfreerdp, port):
    import subprocess  # @Reimport
    params = [xfreerdp] + {m.r.as_new_xfreerdp_params} + [
        '/v:127.0.0.1:{{}}'.format(port)
    ]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #28
0
def execUdsRdp(udsrdp):
    import subprocess
    params = [udsrdp] + {m.r.as_new_xfreerdp_params} + ['/v:{m.r.address}'
                                                        ]  # @UndefinedVariable
    tools.addTaskToWait(subprocess.Popen(params))
Пример #29
0
            subprocess.call([
                'security',
                'add-generic-password',
                '-w',
                '{m.password}',
                '-U',
                '-a',
                '{m.usernameWithDomain}',
                '-s',
                'Remote Desktop Connection 2 Password for {m.ip}',
                '-T',
                '/Applications/Remote Desktop Connection.app',
            ])
            tools.addExecBeforeExit(onExit)
        # Call but do not wait for exit
        tools.addTaskToWait(subprocess.Popen([executable, filename]))

        tools.addFileToUnlink(filename)
    except Exception as e:
        QtGui.QMessageBox.critical(parent, 'Notice', six.text_type(e),
                                   QtGui.QMessageBox.Ok)  # @UndefinedVariable
else:  # CoRD
    url = 'rdp://'

    username, domain = '{m.username}', '{m.domain}'

    if username != '':
        url += username
        if '{m.password}' != '':
            url += ':' + urllib.quote('{m.password}')
        url += '@'
Пример #30
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


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)
Пример #31
0
else:
    if executable == msrdc:
        theFile = sp['as_file'].format(address=address)  # @UndefinedVariable
        filename = tools.saveTempFile(theFile)
        tools.addFileToUnlink(filename)
        
        try:
            if sp['password'] != '':  # @UndefinedVariable
                subprocess.call(
                    [
                        'security',
                        'add-generic-password',
                        '-w', sp['password'],  # @UndefinedVariable
                        '-U',
                        '-a', sp['usernameWithDomain'],  # @UndefinedVariable
                        '-s', 'Remote Desktop Connection 2 Password for 127.0.0.1'.format(port),
                        '-T', '/Applications/Remote Desktop Connection.app',
                    ]
                )
                tools.addExecBeforeExit(onExit)
            # Call but do not wait for exit
            tools.addTaskToWait(subprocess.Popen([executable, filename]))

            tools.addFileToUnlink(filename)
        except Exception as e:
            raise
    else:  # CoRD
        url = sp['as_cord_url'].format(address=address)  # @UndefinedVariable

        tools.addTaskToWait(subprocess.Popen(['open', url]))
Пример #32
0
from __future__ import unicode_literals

# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index
import subprocess
from uds.forward import forward  # @UnresolvedImport
import os

from uds import tools  # @UnresolvedImport


cmd = '/Applications/OpenNX/OpenNX.app/Contents/MacOS/OpenNXapp'
if os.path.isfile(cmd) is False:
    raise Exception('''<p>You need to have installed Open NX Client in order to connect to this UDS service.</p>
<p>Please, install appropriate package for your system from <a href="http://www.opennx.net/">here</a>.</p>
''')

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


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

filename = tools.saveTempFile(theFile)

tools.addTaskToWait(subprocess.Popen([cmd, '--session={}'.format(filename), '--autologin', '--killerrors']))
tools.addFileToUnlink(filename)