Пример #1
0
 def notify(self, channel, frame):
     if is_transport_key(frame):
         if get_extended_source(frame) is not None:
             extended_source_bytes = extended_address_bytes(get_extended_source(frame))
             decrypted, valid = crypto_utils.zigbee_packet_decrypt(crypto_utils.zigbee_trans_key(crypto_utils.DEFAULT_ZLL_COMMISSION_KEY), frame, extended_source_bytes)
             if valid:
                 print_notify("Network key acquired for PAN 0x%04x" % get_pan_id(frame))
                 network_key = bytes(decrypted)[2:18]
                 print_info("Extracted key is 0x%s" % network_key.hex())
    def extractKeyOnChannel(self, channel):
        self.radio.set_channel(channel)

        print_notify("Listening to channel %d" % self.radio.get_channel())

        while True:
            frame = self.radio.receive()
            if is_transport_key(frame):
                print_notify("Got transport key packet")
                if get_extended_source(frame) is not None:
                    print("Got extended source")
                    extended_source_bytes = extended_address_bytes(
                        get_extended_source(frame))
                    decrypted, valid = crypto_utils.zigbee_packet_decrypt(
                        crypto_utils.DEFAULT_ZLL_COMMISSION_KEY, frame,
                        extended_source_bytes)
                    if valid:
                        print_notify("Network key acquired for PAN 0x%04x" %
                                     get_pan_id(frame))
                        network_key = bytes(decrypted)[2:18]
                        print_info("Extracted key is 0x%s" % network_key.hex())
Пример #3
0
def wait_for_extended_address(radio, panid, addr):

    print_info("Waiting to observe the extended source for pan_id:0x%04x, src_addr:0x%04x" % (panid, addr))

    timer = Timer(OBSERVATION_TIME)
    while not timer.has_expired():
        frame = radio.receive()
        if panid==get_pan_id(frame) and addr==get_source(frame):
            extended_source = get_extended_source(frame)
            if extended_source is not None:
                print_notify("Extended source observed: 0x%016x" % extended_source)
                return extended_source
    
    print_error("Could not find extended source")
    return None