Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Malformed Packet Attacks & Defenses

Cybersecurity: Malformed Packet Attacks & Defenses

Malformed Packets and Keyboard cyber:bot Control

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.
  • 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 them.
  • Enter, Name, Save, and Flash the Sender Script terminal_bot_controller_wireless_malfomred_packet_attack into the Sender micro:bit.
  • Enter, name, 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)

 


Printer-friendly version
Your Turn: Exception Handling plus Encryption
Prev
Test the Radio Connection to the cyber:bot
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress