In Cybersecurity: Sniffing Attacks & Defenses, the Share Something Personal - Unencrypted? activity involved testing unencrypted transmission of emoji from one micro:bit to another.
In this activity, the application is a little more versatile, allowing you to scroll through the emoji with the micro:bit module’s A button and send it with the B button.
This application also has a routine for sending a malformed packet. In this activity, you will again study how the malformed packet can cause problems, mitigate them, and then also encrypt the communication.
Parts:
- Two micro:bit modules
- Two USB A to micro-B cables
Script: radio_send_receive_images_w_buttons
You can either connect each micro:bit to a separate computer, or both to separate USB ports on the same computer.
- Connect the two micro:bit modules to two USB ports with two USB cables.
- Open two separate browsers and navigate each one to python.microbit.org.
- If you are part of a class, and have been assigned a channel, make sure to adjust the script’s channel=7 argument to your assigned channel before you save and flash the scripts.
- Enter, name, save, and flash the radio_send_receive_images_w_buttons script into both micro:bit modules.
- Before continuing, find the # Sends malformed packet comment and examine how the packet is changed before transmitting.
# radio_send_receive_images_w_buttons from microbit import * import radio radio.on() radio.config(channel=7) n = 0 emoji = [ 'Image.YES', 'Image.NO', 'Image.HEART', 'Image.SKULL' ] image = eval(emoji[n]) display.show(image) while True: if button_a.was_pressed(): n = n + 1 n = n % len(emoji) image = eval(emoji[n]) display.show(image) if button_b.was_pressed(): packet = emoji[n] print('packet:', packet) if image is Image.SKULL: # Sends malformed packet packet = 'malformed packet' # Sends malformed packet radio.send(packet) packet = radio.receive() if packet: print('packet:', packet) n = emoji.index(packet, 0, len(emoji)) image = eval(packet) display.show(image)