Ejemplo n.º 1
0
    def pairingResponse(self, packet):
        if self.getStage() == BLEMitmStage.ACTIVE_MITM:
            io.info(
                ("Pairing Response (from slave) : " + "\n=> outOfBand = " +
                 ("yes" if packet.outOfBand else "no") +
                 "\n=> inputOutputCapability = " + str(
                     ble.InputOutputCapability(
                         data=bytes([packet.inputOutputCapability]))) +
                 "\n=> authentication = " +
                 str(ble.AuthReqFlag(data=bytes([packet.authentication]))) +
                 "\n=> maxKeySize = " + str(packet.maxKeySize) +
                 "\n=> initiatorKeyDistribution = " + str(
                     ble.KeyDistributionFlag(
                         data=bytes([packet.initiatorKeyDistribution])))) +
                "\n=> responderKeyDistribution = " + str(
                    ble.KeyDistributionFlag(
                        data=bytes([packet.responderKeyDistribution]))))
            io.info("Storing Pairing Response's payload :" +
                    packet.payload.hex())
            self.pRes = packet.payload[::-1]

            io.info("Redirecting to master ...")
            self.a2mEmitter.sendp(
                ble.BLEPairingResponse(
                    outOfBand=packet.outOfBand,
                    inputOutputCapability=packet.inputOutputCapability,
                    authentication=packet.authentication,
                    maxKeySize=packet.maxKeySize,
                    initiatorKeyDistribution=packet.initiatorKeyDistribution,
                    responderKeyDistribution=packet.responderKeyDistribution))
Ejemplo n.º 2
0
    def masterPairingRequest(self, pkt):
        self.initiatorAddress = self.emitter.getCurrentConnection()
        self.initiatorAddressType = b"\x00" if self.emitter.getCurrentConnectionMode(
        ) == "public" else b"\x01"
        self.responderAddress = self.emitter.getAddress()
        self.responderAddressType = b"\x00" if self.emitter.getAddressMode(
        ) == "public" else b"\x01"

        pkt.show()
        self.pairingRequest = pkt
        self.pReq = self.pairingRequest.payload[::-1]

        self.initiatorAuthReq = ble.AuthReqFlag(
            data=bytes([pkt.authentication]))
        self.initiatorInputOutputCapability = ble.InputOutputCapability(
            data=bytes([pkt.inputOutputCapability]))
        self.initiatorKeyDistribution = ble.KeyDistributionFlag(
            data=bytes([pkt.initiatorKeyDistribution]))

        keyboard = utils.booleanArg(self.args["KEYBOARD"])
        yesno = utils.booleanArg(self.args["YESNO"])
        display = utils.booleanArg(self.args["DISPLAY"])

        ct2 = utils.booleanArg(self.args["CT2"])
        mitm = utils.booleanArg(self.args["MITM"])
        bonding = utils.booleanArg(self.args["BONDING"])
        secureConnections = utils.booleanArg(self.args["SECURE_CONNECTIONS"])
        keyPress = utils.booleanArg(self.args["KEYPRESS"])

        linkKey = False
        encKey = self.args["LTK"] != "" and self.args[
            "EDIV"] != "" and self.args["RAND"] != ""
        idKey = self.args["IRK"] != "" and self.args[
            "ADDR"] != "" and self.args["ADDR_TYPE"]
        signKey = self.args["CSRK"] != ""

        self.responderInputOutputCapability = ble.InputOutputCapability(
            keyboard=keyboard, display=display, yesno=yesno)
        self.responderAuthReq = ble.AuthReqFlag(
            ct2=ct2,
            mitm=mitm,
            bonding=bonding,
            secureConnections=secureConnections,
            keypress=keyPress)
        self.responderKeyDistribution = ble.KeyDistributionFlag(
            linkKey=linkKey, encKey=encKey, idKey=idKey, signKey=signKey)

        self.pairingResponse = ble.BLEPairingResponse(
            authentication=self.responderAuthReq.data[0],
            inputOutputCapability=self.responderInputOutputCapability.data[0],
            initiatorKeyDistribution=self.responderKeyDistribution.data[0],
            responderKeyDistribution=self.responderKeyDistribution.data[0])
        self.pairingResponse.show()
        self.pRes = self.pairingResponse.payload[::-1]
        pairingMethod = self.pairingMethodSelection()
        io.success("Pairing Method selected : " + self.pairingMethod)
        self.emitter.sendp(self.pairingResponse)