示例#1
0
 def notification(self, packet):
     if self.getStage() == BLEMitmStage.ACTIVE_MITM:
         io.info("Handle Value Notification (from slave) : handle = " +
                 hex(packet.handle) + " / value = " + packet.value.hex())
         io.info("Redirecting to master ...")
         self.a2mEmitter.sendp(
             ble.BLEHandleValueNotification(handle=packet.handle,
                                            value=packet.value))
示例#2
0
	def notification(self,handle,value):
		try:
			handle = int(handle,16)
			if utils.isHexadecimal(value):
				value = bytes.fromhex(value)
			else:
				value = bytes(value,"ascii")

			self.emitter.sendp(ble.BLEHandleValueNotification(handle=handle, value=value))
		except:
			io.fail("An error happened during notification emission !")
示例#3
0
 def addHIDoverGATTKeystroke(self,
                             locale="fr",
                             key="a",
                             ctrl=False,
                             alt=False,
                             gui=False,
                             shift=False):
     keystrokes = []
     keystrokePressed = ble.HIDoverGATTKeystroke(locale=locale,
                                                 key=key,
                                                 ctrl=ctrl,
                                                 alt=alt,
                                                 gui=gui,
                                                 shift=shift)
     keystrokeReleased = bytes([0, 0, 0, 0, 0, 0, 0, 0])
     keystrokes.append(
         ble.BLEHandleValueNotification(handle=0x000d,
                                        value=keystrokePressed.data))
     keystrokes.append(
         ble.BLEHandleValueNotification(handle=0x000d,
                                        value=keystrokeReleased))
     return keystrokes
示例#4
0
    def onSlaveHandleValueNotification(self, packet):
        # If the packet has a handle of 0x2b and a packet value of 0x00
        if packet.handle == 0x2b and 0x00 in packet.value:
            packet.show()

            # The indexes of the data
            index_sys = 1
            index_dia = 3
            index_hr = 14

            # Create a new packet by modifying the systolic value to 0
            newValue = packet.value[:index_sys] + bytes(0x01)
            newValue2 = packet.value[2:]
            io.info("Value modified to: " +newValue.hex()+ newValue2.hex())

            # Emit the new packet to the slave
            self.a2mEmitter.sendp(ble.BLEHandleValueNotification(handle=packet.handle, value = bytes(newValue) + bytes(newValue2)))

            return False

        else:
            return True