Many robots and other manufacturing machines have their work orchestrated by computers on a factory network. If there is any kind of connection to the outside world, a malformed packet might provide a cyberattack entry and then cause malfunctions.
Similarly, in a remote-controlled navigation contest, your cyber:bot robot might also be vulnerable to malformed packets in addition to sniffing attacks. So, we'll now enhance the application from Cybersecurity: Navigation Control from a Keyboard.
In Your Turn: Handle Transmitter Exceptions, you already hardened the sender against accidentally entering malformed packet data, but the receiver is not yet hardened against intentional attacks. So, in this activity, you will harden the Terminal Control — Go Wireless! app against both kinds of attacks.
Parts
- One micro:bit module with USB cable (this can be a short cable that comes with a micro:bit GO kit).
- One built and tested cyber:bot robot (which also has a micro:bit) and the longer USB cable that came with the robot
Scripts
- Connect a micro:bit and a cyber:bot robot to two USB ports with two USB cables.
- Open two separate browsers and navigate each one to python.microbit.org/v/2.
- If you are part of a class, and have been assigned a channel, make sure to adjust the script’s channel=7 to your assigned channel before you save and flash the scripts.
- Enter, Save, and Flash the Sender Script terminal_bot_controller_wireless_malfomred_packet_attack into the Sender micro:bit.
- Enter, save, and flash the script terminal_controlled_bot_wireless script into cyber:bot robot’s receiver micro:bit. The Receiver Script is below the Sender Script.
- Before continuing, find the # Sends malformed packet… comment and examine how the dictionary is changed before transmitting.
Sender Script: terminal_bot_controller_wireless_malfomred_packet_attack
# terminal_bot_controller_wireless_malfomred_packet_attack from microbit import * import radio radio.on() radio.config(channel=7,length=64) sleep(1000) print("\nSpeeds are -100 to 100\n") while True: try: vL = int(input("Enter left speed: ")) vR = int(input("Enter right speed: ")) ms = int(input("Enter ms to run: ")) dictionary = { } dictionary['vL'] = vL dictionary['vR'] = vR dictionary['ms'] = ms # Sends malformed packet attack if ms to run is negative. if ms < 0: dictionary = { 'vL': -20, 'vR': 20, 'ms': "Not a number!" } packet = str(dictionary) print("Send: ", packet) radio.send(packet) print() except: print("Error in value entered.") print("Please try again. \n")
Receiver Script for cyber:bot: terminal_controlled_bot_wireless
# terminal_controlled_bot_wireless from cyberbot import * import radio radio.on() radio.config(channel=7,length=64) sleep(1000) print("Ready...\n") while True: packet = radio.receive() if packet is not None: print("Receive: ", packet) dictionary = eval(packet) vL = dictionary['vL'] vR = dictionary['vR'] ms = dictionary['ms'] bot(18).servo_speed(vL) bot(19).servo_speed(-vR) sleep(ms) bot(18).servo_speed(None) bot(19).servo_speed(None)