Beispiel #1
0
    </li>
</ul>
<p>If both apps are installed, Remote Desktop Connection will be used as first option</p>
'''.format(sp['this_server']))  # @UndefinedVariable

forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 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 = 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)
Beispiel #2
0
    # 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

subprocess.Popen([executable, filename])
tools.addFileToUnlink(filename)
Beispiel #3
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)