Code Monkey home page Code Monkey logo

websockify's Introduction

websockify: WebSockets support for any application/server

See: novnc/websockify

Added by Shellrent

Added support for Tokens in Cookies in websocketproxy.py on get_target

    def get_target(self, target_plugin, path):
        """
        Parses the path, extracts a token, and looks up a target
        for that token using the token plugin. Sets
        target_host and target_port if successful
        """
        # The files in targets contain the lines
        # in the form of token: host:port
		
        token = ''
		
		# Extract the token parameter from cookie
        if 'Cookie' in self.headers:
            cookiestr = self.headers['Cookie']
            cookiestr.replace( 'Cookie: ', '', 1 )
            cookies = cookiestr.split('; ')

            for cookie in cookies:
                cookie = cookie.split('=')
                if 'token' in cookie[0]:
                    token = cookie[1]
                    break

        # Extract the token parameter from url
        if token == '':
            args = parse_qs(urlparse(path)[4]) # 4 is the query from url

            if not 'token' in args or not len(args['token']):
                raise self.server.EClose("Token not present")

            token = args['token'][0].rstrip('\n')

        if token == '':
            raise self.server.EClose( "Empty Token defined" )

        # Search for the token
        result_pair = target_plugin.lookup( token )

        if result_pair is not None:
            return result_pair
        else:
            raise self.server.EClose( "Token '%s' not found" % token )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.