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 Sharing Something

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)

 

 


Printer-friendly version
Your Turn: Add a Vulnerability
Prev
Test the Script
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress