示例#1
0
    def masterPairingConfirm(self, pkt):
        pkt.show()
        self.mConfirm = pkt.confirm[::-1]

        self.sRand = ble.BLECrypto.generateRandom()
        io.success("Generating random : " + self.sRand.hex())

        if self.pairingMethod == "JustWorks":
            pinCode = 0
        else:
            if self.args["PIN"] != "" and utils.isNumber(self.args["PIN"]):
                pinCode = int(self.args["PIN"])
            else:
                pinCode = int(io.enterPinCode("Enter the 6 digit PIN code: "))

        self.tk = self.pinToTemporaryKey(pinCode)

        io.success("Generating Temporary Key : " + self.tk.hex())

        self.sConfirm = ble.BLECrypto.c1(self.tk, self.sRand[::-1], self.pReq,
                                         self.pRes, self.initiatorAddressType,
                                         self.initiatorAddress,
                                         self.responderAddressType,
                                         self.responderAddress)

        io.success("Generating SConfirm : " + self.sConfirm.hex())
        confirmPacket = ble.BLEPairingConfirm(confirm=self.sConfirm[::-1])
        confirmPacket.show()
        self.emitter.sendp(confirmPacket)
示例#2
0
文件: ble_mitm.py 项目: RCayre/mirage
	def slavePairingConfirm(self,packet):
		if self.getStage() == BLEMitmStage.ACTIVE_MITM:
			io.info("Pairing Confirm (from slave) : confirm = " + packet.confirm.hex())

			io.info ("Storing sConfirm : "+packet.confirm.hex())
			self.sConfirm = packet.confirm[::-1]

			io.info("Redirecting to master ...")
			self.a2mEmitter.sendp(ble.BLEPairingConfirm(confirm=packet.confirm))
示例#3
0
    def slavePairingResponse(self, pkt):

        self.initiatorAddress = self.emitter.getAddress()
        self.initiatorAddressType = b"\x00" if self.emitter.getAddressMode(
        ) == "public" else b"\x01"
        self.responderAddress = self.emitter.getCurrentConnection()
        self.responderAddressType = b"\x00" if self.emitter.getCurrentConnectionMode(
        ) == "public" else b"\x01"

        pkt.show()
        self.pairingResponse = pkt
        self.pRes = self.pairingResponse.payload[::-1]

        self.responderAuthReq = ble.AuthReqFlag(
            data=bytes([pkt.authentication]))
        self.responderInputOutputCapability = ble.InputOutputCapability(
            data=bytes([pkt.inputOutputCapability]))
        self.responderKeyDistribution = ble.KeyDistributionFlag(
            data=bytes([pkt.responderKeyDistribution]))
        pairingMethod = self.pairingMethodSelection()
        io.success("Pairing Method selected : " + self.pairingMethod)

        self.mRand = ble.BLECrypto.generateRandom()
        io.success("Generating random : " + self.mRand.hex())

        if pairingMethod == "JustWorks":
            pinCode = 0
        else:
            if self.args["PIN"] != "" and utils.isNumber(self.args["PIN"]):
                pinCode = int(self.args["PIN"])
            else:
                pinCode = int(io.enterPinCode("Enter the 6 digit PIN code: "))

        self.tk = self.pinToTemporaryKey(pinCode)
        io.success("Generating Temporary Key : " + self.tk.hex())

        self.mConfirm = ble.BLECrypto.c1(self.tk, self.mRand[::-1], self.pReq,
                                         self.pRes, self.initiatorAddressType,
                                         self.initiatorAddress,
                                         self.responderAddressType,
                                         self.responderAddress)
        io.success("Generating MConfirm : " + self.mConfirm.hex())
        confirmPacket = ble.BLEPairingConfirm(confirm=self.mConfirm[::-1])
        confirmPacket.show()
        self.emitter.sendp(confirmPacket)