Exemple #1
0
    def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci['domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        r = RDPFile(width == -1 or height == -1, width, height, depth, target=os['OS'])
        r.address = '{}:{}'.format(ip, 3389)
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()

        # data
        data = {
            'os': os['OS'],
            'ip': ip,
            'port': 3389,
            'username': username,
            'password': password,
            'hasCredentials': username != '' and password != '',
            'domain': domain,
            'width': width,
            'height': height,
            'depth': depth,
            'printers': self.allowPrinters.isTrue(),
            'smartcards': self.allowSmartcards.isTrue(),
            'drives': self.allowDrives.isTrue(),
            'serials': self.allowSerials.isTrue(),
            'compression': True,
            'wallpaper': self.wallpaper.isTrue(),
            'multimon': self.multimon.isTrue(),
            'fullScreen': width == -1 or height == -1,
            'this_server': request.build_absolute_uri('/'),
            'r': r,
        }

        m = tools.DictAsObj(data)

        if m.domain != '':
            m.usernameWithDomain = '{}\\\\{}'.format(m.domain, m.username)
        else:
            m.usernameWithDomain = m.username

        if m.os == OsDetector.Windows:
            m.r.password = '******'

        os = {
            OsDetector.Windows: 'windows',
            OsDetector.Linux: 'linux',
            OsDetector.Macintosh: 'macosx'

        }.get(m.os)

        if os is None:
            return super(RDPTransport, self).getUDSTransportScript(self, userService, transport, ip, os, user, password, request)

        return self.getScript('scripts/{}/direct.py'.format(os)).format(m=m)
Exemple #2
0
    def getUDSTransportScript(self, userService, transport, ip, os, user,
                              password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci[
            'domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        r = RDPFile(width == -1 or height == -1,
                    width,
                    height,
                    depth,
                    target=os['OS'])
        r.enablecredsspsupport = ci.get('sso', self.credssp.isTrue())
        r.address = '{}:{}'.format(ip, 3389)
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.enableClipboard = self.allowClipboard.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()
        r.desktopComposition = self.aero.isTrue()
        r.smoothFonts = self.smooth.isTrue()
        r.multimedia = self.multimedia.isTrue()
        r.alsa = self.alsa.isTrue()
        r.smartcardString = self.smartcardString.value
        r.printerString = self.printerString.value
        r.linuxCustomParameters = self.customParameters.value

        # data
        #         data = {
        #             'os': os['OS'],
        #             'ip': ip,
        #             'port': 3389,
        #             'username': username,
        #             'password': password,
        #             'hasCredentials': username != '' and password != '',
        #             'domain': domain,
        #             'width': width,
        #             'height': height,
        #             'depth': depth,
        #             'printers': self.allowPrinters.isTrue(),
        #             'smartcards': self.allowSmartcards.isTrue(),
        #             'drives': self.allowDrives.isTrue(),
        #             'serials': self.allowSerials.isTrue(),
        #             'compression': True,
        #             'wallpaper': self.wallpaper.isTrue(),
        #             'multimon': self.multimon.isTrue(),
        #             'fullScreen': width == -1 or height == -1,
        #             'this_server': request.build_absolute_uri('/')
        #         }

        os = {
            OsDetector.Windows: 'windows',
            OsDetector.Linux: 'linux',
            OsDetector.Macintosh: 'macosx'
        }.get(os['OS'])

        if os is None:
            logger.ERROR('Os not detected for RDP Transport: {}'.format(
                request.META.get('HTTP_USER_AGENT', 'Unknown')))
            return super(RDPTransport,
                         self).getUDSTransportScript(userService, transport,
                                                     ip, os, user, password,
                                                     request)

        sp = {
            'password': password,
            'this_server': request.build_absolute_uri('/'),
        }

        if os == 'windows':
            if password != '':
                r.password = '******'
            sp.update({
                'as_file': r.as_file,
            })
        elif os == 'linux':
            sp.update({
                'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
                'as_rdesktop_params': r.as_rdesktop_params,
                'address': r.address,
            })
        else:  # Mac
            sp.update({
                'as_file': r.as_file,
                'ip': ip,
                'as_cord_url': r.as_cord_url,
            })
            if domain != '':
                sp['usernameWithDomain'] = '{}\\\\{}'.format(domain, username)
            else:
                sp['usernameWithDomain'] = username

        return self.getScript('scripts/{}/direct.py', os, sp)
    def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci['domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        tunpass = ''.join(random.choice(string.letters + string.digits) for _i in range(12))
        tunuser = TicketStore.create(tunpass)

        sshHost, sshPort = self.tunnelServer.value.split(':')

        logger.debug('Username generated: {0}, password: {1}'.format(tunuser, tunpass))

        r = RDPFile(width == -1 or height == -1, width, height, depth, target=os['OS'])
        r.address = '{address}'
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()


        # data
        data = {
            'os': os['OS'],
            'ip': ip,
            'tunUser': tunuser,
            'tunPass': tunpass,
            'tunHost': sshHost,
            'tunPort': sshPort,
            'username': username,
            'password': password,
            'hasCredentials': username != '' and password != '',
            'domain': domain,
            'width': width,
            'height': height,
            'depth': depth,
            'printers': self.allowPrinters.isTrue(),
            'smartcards': self.allowSmartcards.isTrue(),
            'drives': self.allowDrives.isTrue(),
            'serials': self.allowSerials.isTrue(),
            'compression': True,
            'wallpaper': self.wallpaper.isTrue(),
            'multimon': self.multimon.isTrue(),
            'fullScreen': width == -1 or height == -1,
            'this_server': request.build_absolute_uri('/'),
            'r': r,
        }

        m = tools.DictAsObj(data)

        if m.domain != '':
            m.usernameWithDomain = '{}\\\\{}'.format(m.domain, m.username)
        else:
            m.usernameWithDomain = m.username

        if m.os == OsDetector.Windows:
            r.password = '******'

        os = {
            OsDetector.Windows: 'windows',
            OsDetector.Linux: 'linux',
            OsDetector.Macintosh: 'macosx'

        }.get(m.os)

        if os is None:
            return super(TSRDPTransport, self).getUDSTransportScript(self, userService, transport, ip, os, user, password, request)

        return self.getScript('scripts/{}/tunnel.py'.format(os)).format(m=m)
Exemple #4
0
    def getUDSTransportScript(self, userService, transport, ip, os, user,
                              password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci[
            'domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        tunpass = ''.join(
            random.choice(string.letters + string.digits) for _i in range(12))
        tunuser = TicketStore.create(tunpass)

        sshHost, sshPort = self.tunnelServer.value.split(':')

        logger.debug('Username generated: {0}, password: {1}'.format(
            tunuser, tunpass))

        r = RDPFile(width == -1 or height == -1,
                    width,
                    height,
                    depth,
                    target=os['OS'])
        r.enablecredsspsupport = ci.get('sso', self.credssp.isTrue())
        r.address = '{address}'
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()
        r.desktopComposition = self.aero.isTrue()
        r.smoothFonts = self.smooth.isTrue()
        r.multimedia = self.multimedia.isTrue()
        r.alsa = self.alsa.isTrue()
        r.smartcardString = self.smartcardString.value
        r.printerString = self.printerString.value
        r.linuxCustomParameters = self.customParameters.value

        # data
        #         data = {
        #             'os': os['OS'],
        #             'ip': ip,
        #             'tunUser': tunuser,
        #             'tunPass': tunpass,
        #             'tunHost': sshHost,
        #             'tunPort': sshPort,
        #             'tunWait': self.tunnelWait.num(),
        #             'username': username,
        #             'password': password,
        #             'hasCredentials': username != '' and password != '',
        #             'domain': domain,
        #             'width': width,
        #             'height': height,
        #             'depth': depth,
        #             'printers': self.allowPrinters.isTrue(),
        #             'smartcards': self.allowSmartcards.isTrue(),
        #             'drives': self.allowDrives.isTrue(),
        #             'serials': self.allowSerials.isTrue(),
        #             'compression': True,
        #             'wallpaper': self.wallpaper.isTrue(),
        #             'multimon': self.multimon.isTrue(),
        #             'fullScreen': width == -1 or height == -1,
        #             'this_server': request.build_absolute_uri('/'),
        #             'r': r,
        #         }

        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)

        sp = {
            'tunUser': tunuser,
            'tunPass': tunpass,
            'tunHost': sshHost,
            'tunPort': sshPort,
            'tunWait': self.tunnelWait.num(),
            'ip': ip,
            'password': password,
            'this_server': request.build_absolute_uri('/'),
        }

        if os == 'windows':
            if password != '':
                r.password = '******'
            sp.update({
                'as_file': r.as_file,
            })
        elif os == 'linux':
            sp.update({
                'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
                'as_rdesktop_params': r.as_rdesktop_params,
            })
        else:  # Mac
            sp.update({
                'as_file': r.as_file,
                'ip': ip,
                'as_cord_url': r.as_cord_url,
            })
            if domain != '':
                sp['usernameWithDomain'] = '{}\\\\{}'.format(domain, username)
            else:
                sp['usernameWithDomain'] = username

        return self.getScript('scripts/{}/tunnel.py', os, sp)
Exemple #5
0
    def getUDSTransportScript(self, userService, transport, ip, os, user,
                              password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci[
            'domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        r = RDPFile(width == -1 or height == -1,
                    width,
                    height,
                    depth,
                    target=os['OS'])
        r.address = '{}:{}'.format(ip, 3389)
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()

        # data
        data = {
            'os': os['OS'],
            'ip': ip,
            'port': 3389,
            'username': username,
            'password': password,
            'hasCredentials': username != '' and password != '',
            'domain': domain,
            'width': width,
            'height': height,
            'depth': depth,
            'printers': self.allowPrinters.isTrue(),
            'smartcards': self.allowSmartcards.isTrue(),
            'drives': self.allowDrives.isTrue(),
            'serials': self.allowSerials.isTrue(),
            'compression': True,
            'wallpaper': self.wallpaper.isTrue(),
            'multimon': self.multimon.isTrue(),
            'fullScreen': width == -1 or height == -1,
            'this_server': request.build_absolute_uri('/'),
            'r': r,
        }

        m = tools.DictAsObj(data)

        if m.domain != '':
            m.usernameWithDomain = '{}\\\\{}'.format(m.domain, m.username)
        else:
            m.usernameWithDomain = m.username

        if m.os == OsDetector.Windows:
            m.r.password = '******'

        os = {
            OsDetector.Windows: 'windows',
            OsDetector.Linux: 'linux',
            OsDetector.Macintosh: 'macosx'
        }.get(m.os)

        if os is None:
            return super(RDPTransport,
                         self).getUDSTransportScript(self, userService,
                                                     transport, ip, os, user,
                                                     password, request)

        return self.getScript('scripts/{}/direct.py'.format(os)).format(m=m)
    def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
        # We use helper to keep this clean
        prefs = user.prefs('rdp')

        ci = self.getConnectionInfo(userService, user, password)
        username, password, domain = ci['username'], ci['password'], ci['domain']

        width, height = CommonPrefs.getWidthHeight(prefs)
        depth = CommonPrefs.getDepth(prefs)

        r = RDPFile(width == -1 or height == -1, width, height, depth, target=os['OS'])
        r.enablecredsspsupport = ci.get('sso', self.credssp.isTrue())
        r.address = '{}:{}'.format(ip, 3389)
        r.username = username
        r.password = password
        r.domain = domain
        r.redirectPrinters = self.allowPrinters.isTrue()
        r.redirectSmartcards = self.allowSmartcards.isTrue()
        r.redirectDrives = self.allowDrives.isTrue()
        r.redirectSerials = self.allowSerials.isTrue()
        r.showWallpaper = self.wallpaper.isTrue()
        r.multimon = self.multimon.isTrue()
        r.desktopComposition = self.aero.isTrue()
        r.smoothFonts = self.smooth.isTrue()
        r.multimedia = self.multimedia.isTrue()
        r.alsa = self.alsa.isTrue()
        r.smartcardString = self.smartcardString.value
        r.printerString = self.printerString.value
        r.linuxCustomParameters = self.customParameters.value

        # data
#         data = {
#             'os': os['OS'],
#             'ip': ip,
#             'port': 3389,
#             'username': username,
#             'password': password,
#             'hasCredentials': username != '' and password != '',
#             'domain': domain,
#             'width': width,
#             'height': height,
#             'depth': depth,
#             'printers': self.allowPrinters.isTrue(),
#             'smartcards': self.allowSmartcards.isTrue(),
#             'drives': self.allowDrives.isTrue(),
#             'serials': self.allowSerials.isTrue(),
#             'compression': True,
#             'wallpaper': self.wallpaper.isTrue(),
#             'multimon': self.multimon.isTrue(),
#             'fullScreen': width == -1 or height == -1,
#             'this_server': request.build_absolute_uri('/')
#         }

        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)

        sp = {
            'password': password,
            'this_server': request.build_absolute_uri('/'),
        }

        if os == 'windows':
            if password != '':
                r.password = '******'
            sp.update({
                'as_file': r.as_file,
            })
        elif os == 'linux':
            sp.update({
                'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
                'as_rdesktop_params': r.as_rdesktop_params,
                'address': r.address,
            })
        else:  # Mac
            sp.update({
                'as_file': r.as_file,
                'ip': ip,
                'as_cord_url': r.as_cord_url,
            })
            if domain != '':
                sp['usernameWithDomain'] = '{}\\\\{}'.format(domain, username)
            else:
                sp['usernameWithDomain'] = username


        return self.getScript('scripts/{}/direct.py', os, sp)