Esempio n. 1
0
    def onConnectionRequest(self, pdu):
        # X224 Request
        self.log.debug("Connection Request received")

        # We need to save the original negotiation PDU because Windows will cut the connection if it
        # sees that the requested protocols have changed.
        parser = NegotiationRequestParser()
        self.originalNegotiationPDU = parser.parse(pdu.payload)

        if self.originalNegotiationPDU.cookie:
            self.log.info(
                "%(cookie)s",
                {"cookie": self.originalNegotiationPDU.cookie.decode()})
        else:
            self.log.info("No cookie for this connection %(cookie)s",
                          {"cookie": ""})

        # Only SSL is implemented, so remove other protocol flags
        chosenProtocols = self.originalNegotiationPDU.requestedProtocols & NegotiationProtocols.SSL \
            if self.originalNegotiationPDU.requestedProtocols is not None else None
        self.targetNegotiationPDU = NegotiationRequestPDU(
            self.originalNegotiationPDU.cookie,
            self.originalNegotiationPDU.flags,
            chosenProtocols,
            self.originalNegotiationPDU.correlationFlags,
            self.originalNegotiationPDU.correlationID,
        )

        self.connectClient()
Esempio n. 2
0
    def onConnectionRequest(self, pdu: X224ConnectionRequestPDU):
        """
        Log the connection cookie and handle connection protocols.
        :param pdu: the connection request
        """

        parser = NegotiationRequestParser()
        self.originalRequest = parser.parse(pdu.payload)
        self.state.requestedProtocols = self.originalRequest.requestedProtocols

        if self.originalRequest.cookie:
            self.log.info("%(cookie)s",
                          {"cookie": self.originalRequest.cookie.decode()})
        else:
            self.log.info("No cookie for this connection")

        chosenProtocols = self.originalRequest.requestedProtocols

        if chosenProtocols is not None:
            # Only SSL is implemented, so remove other protocol flags
            chosenProtocols &= NegotiationProtocols.SSL

        modifiedRequest = NegotiationRequestPDU(
            self.originalRequest.cookie,
            self.originalRequest.flags,
            chosenProtocols,
            self.originalRequest.correlationFlags,
            self.originalRequest.correlationID,
        )

        payload = parser.write(modifiedRequest)
        defer(self.connectToServer(payload))
Esempio n. 3
0
    def onConnectionRequest(self, pdu: X224ConnectionRequestPDU):
        """
        Log the connection cookie and handle connection protocols.
        :param pdu: the connection request
        """

        parser = NegotiationRequestParser()
        self.originalRequest = parser.parse(pdu.payload)
        self.state.requestedProtocols = self.originalRequest.requestedProtocols

        if self.originalRequest.flags & NegotiationRequestFlags.RESTRICTED_ADMIN_MODE_REQUIRED:
            self.log.warning("Client has enabled Restricted Admin Mode, which forces Network-Level Authentication (NLA)."
                             " Connection will fail.", {"restrictedAdminActivated": True})

        if self.originalRequest.cookie:
            self.log.info("%(cookie)s", {"cookie": self.originalRequest.cookie.decode()})
        else:
            self.log.info("No cookie for this connection")

        chosenProtocols = self.originalRequest.requestedProtocols

        if chosenProtocols is not None:
            # Tell the server we only support the allowed authentication methods.
            chosenProtocols &= self.state.config.authMethods

        modifiedRequest = NegotiationRequestPDU(
            self.originalRequest.cookie,
            self.originalRequest.flags,
            chosenProtocols,
            self.originalRequest.correlationFlags,
            self.originalRequest.correlationID,
        )

        payload = parser.write(modifiedRequest)
        defer(self.connectToServer(payload))
Esempio n. 4
0
 def startConnection(self):
     """
     Start the connection sequence to the target machine.
     """
     self.log.debug("TCP connected")
     negotiation = self.server.getNegotiationPDU()
     parser = NegotiationRequestParser()
     self.x224.sendConnectionRequest(parser.write(negotiation))