Example #1
0
    def transportDataReceived(self, data):
        logger.debug('Transport data received')
        try:
            self.processError(data)

            params = None

            if self.serverVersion <= OLD_METHOD_VERSION:
                script = bz2.decompress(base64.b64decode(data['result']))
                # This fixes uds 2.2 "write" string on binary streams on some transport
                script = script.replace(b'stdin.write("', b'stdin.write(b"')
                script = script.replace(b'version)',
                                        b'version.decode("utf-8"))')
            else:
                res = data['result']
                # We have three elements on result:
                # * Script
                # * Signature
                # * Script data
                # We test that the Script has correct signature, and them execute it with the parameters
                #script, signature, params = res['script'].decode('base64').decode('bz2'), res['signature'], json.loads(res['params'].decode('base64').decode('bz2'))
                script, signature, params = bz2.decompress(
                    base64.b64decode(
                        res['script'])), res['signature'], json.loads(
                            bz2.decompress(base64.b64decode(res['params'])))
                if tools.verifySignature(script, signature) is False:
                    logger.error('Signature is invalid')

                    raise Exception(
                        'Invalid UDS code signature. Please, report to administrator'
                    )

            self.stopAnim()

            if 'darwin' in sys.platform:
                self.showMinimized()

            QtCore.QTimer.singleShot(3000, self.endScript)
            self.hide()

            six.exec_(script.decode("utf-8"), globals(), {
                'parent': self,
                'sp': params
            })

        except RetryException as e:
            self.ui.info.setText(six.text_type(e) + ', retrying access...')
            # Retry operation in ten seconds
            QtCore.QTimer.singleShot(10000, self.getTransportData)

        except Exception as e:
            #logger.exception('Got exception executing script:')
            self.showError(e)
Example #2
0
    def transportDataReceived(self, data):
        logger.debug('Transport data received')
        try:
            self.processError(data)

            params = None

            if self.serverVersion <= OLD_METHOD_VERSION:
                script = data['result'].decode('base64').decode('bz2')
            else:
                res = data['result']
                # We have three elements on result:
                # * Script
                # * Signature
                # * Script data
                # We test that the Script has correct signature, and them execute it with the parameters
                script, signature, params = res['script'].decode(
                    'base64').decode('bz2'), res['signature'], json.loads(
                        res['params'].decode('base64').decode('bz2'))
                if tools.verifySignature(script, signature) is False:
                    raise Exception(
                        'Invalid UDS code signature. Please, report to administrator'
                    )

            self.stopAnim()

            if 'darwin' in sys.platform:
                self.showMinimized()

            QtCore.QTimer.singleShot(3000, self.endScript)
            self.hide()

            if self.serverVersion <= OLD_METHOD_VERSION:
                errorString = '<p>The server <b>{}</b> runs an old version of UDS:</p>'.format(
                    host)
                errorString += '<p>To avoid security issues, you must approve old UDS Version access.</p>'

                if QtGui.QMessageBox.warning(
                        None, 'ACCESS Warning', errorString,
                        QtGui.QMessageBox.Yes
                        | QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
                    raise Exception('Server not approved. Access denied.')

            six.exec_(script, globals(), {'parent': self, 'sp': params})

        except RetryException as e:
            self.ui.info.setText(six.text_type(e) + ', retrying access...')
            # Retry operation in ten seconds
            QtCore.QTimer.singleShot(10000, self.getTransportData)

        except Exception as e:
            logger.exception('Got exception executing script:')
            self.showError(e)
Example #3
0
    def transportDataReceived(self, data):
        logger.debug('Transport data received')
        try:
            self.processError(data)

            params = None

            if self.serverVersion <= OLD_METHOD_VERSION:
                script = data['result'].decode('base64').decode('bz2')
            else:
                res = data['result']
                # We have three elements on result:
                # * Script
                # * Signature
                # * Script data
                # We test that the Script has correct signature, and them execute it with the parameters
                script, signature, params = res['script'].decode('base64').decode('bz2'), res['signature'], json.loads(res['params'].decode('base64').decode('bz2'))
                if tools.verifySignature(script, signature) is False:
                    logger.error('Signature is invalid')
                    
                    raise Exception('Invalid UDS code signature. Please, report to administrator')

            self.stopAnim()

            if 'darwin' in sys.platform:
                self.showMinimized()

            QtCore.QTimer.singleShot(3000, self.endScript)
            self.hide()

            # if self.serverVersion <= OLD_METHOD_VERSION:
            #     errorString = '<p>The server <b>{}</b> runs an old version of UDS:</p>'.format(host)
            #     errorString += '<p>To avoid security issues, you must approve old UDS Version access.</p>'
            #
            #     if QtGui.QMessageBox.warning(None, 'ACCESS Warning', errorString, QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
            #         raise Exception('Server not approved. Access denied.')

            six.exec_(script, globals(), {'parent': self, 'sp':  params})

        except RetryException as e:
            self.ui.info.setText(six.text_type(e) + ', retrying access...')
            # Retry operation in ten seconds
            QtCore.QTimer.singleShot(10000, self.getTransportData)

        except Exception as e:
            #logger.exception('Got exception executing script:')
            self.showError(e)
Example #4
0
                           })

        params = None

        if requiredVersion <= OLD_METHOD_VERSION:
            script = res.decode('base64').decode('bz2')
        else:
            # We have three elements on result:
            # * Script
            # * Signature
            # * Script data
            # We test that the Script has correct signature, and them execute it with the parameters
            script, signature, params = res['script'].decode('base64').decode(
                'bz2'), res['signature'], json.loads(
                    res['params'].decode('base64').decode('bz2'))
            if tools.verifySignature(script, signature) is False:
                logger.error('Signature is invalid')

                raise Exception(
                    'Invalid UDS code signature. Please, report to administrator'
                )

        logger.debug('Script: %s', script)
        six.exec_(script, globals(), {'parent': None, 'sp': params})
    except Exception as e:
        error = 'ERROR: {}'.format(e)
        logger.error(error)
        ui.message('Error', error)
        sys.exit(2)

    # Finalize