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: Sniffing Attacks and Defenses

Cybersecurity: Sniffing Attacks and Defenses

Share Something Personal – Encrypted!

In this activity, you will examine the effects of encrypting your messages on a sniffing cyberattack.  You will leave the sniffer micro:bit’s script the same receiver script, but add Caesar cipher encryption to the transmitter and intended receiver scripts.

Cybersecurity: Encryption Intro has activities introducing the Caesar cipher if you want to learn more about it.

  • Repeat the setup from the previous activity, Share Something Personal -Unencrypted.
  • Enter, name, save, and flash the radio_send_images_caesar transmitter script into the micro:bit you chose as the transmitter—the one sending the HAPPY/SAD/ANGRY images.  
  • The micro:bit you chose to be the sniffer should still be running the radio_receive_images  receiver script from the previous activity.
  • Enter, name, save, and flash the radio_receive_images_caesar receiver script into the micro:bit you chose to be the intended receiver.  The receiver script is below the transmitter script.
  • Remember, if you only have two micro:bit modules, you can enter flash, save and test the intended receiver script after testing the sniffer.

Transmitter Script: radio_send_images_caesar

# radio_send_images_caesar.py

from microbit import *
import radio

''' Function converts plaintext to ciphertext using key '''

def caesar(key, word):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    result = "

    for letter in word:
        
        letter = letter.upper()
        index = ( alpha.find(letter) + key ) % 26
        result = result + alpha[index]
    
    return result

''' Script starts from here... '''

radio.on()
radio.config(channel=7)

sleep(1000)

string_list = ["HAPPY", "SAD", "ANGRY"]

while True:
    
    for packet in string_list:
        print("packet:", packet)
        display.show(getattr(Image, packet))
        packet = caesar(3, packet)
        print("Send encrypted:", packet)
        radio.send(packet)
        sleep(2500)

Receiver Script: radio_receive_images_caesar

# radio_receive_images_caesar.py

from microbit import *
import radio

''' Function converts plaintext to ciphertext using key '''

def caesar(key, word):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    result = "

    for letter in word:
        
        letter = letter.upper()
        index = ( alpha.find(letter) + key ) % 26
        result = result + alpha[index]
    
    return result

''' Script starts from here... '''

radio.on()
radio.config(channel=7)

sleep(1000)

while True:
    
    packet = radio.receive()

    if packet:
        print("Receive encrypted:", packet)
        packet = caesar(-3, packet)
        print("packet:", packet)
        display.show(getattr(Image, packet))

Test Sniffer and Intended Receiver Responses

  • Click the Show serial button in any of the browsers where the serial monitor is not already open.  
  • Compare the intended receiver micro:bit’s terminal to the sniffer’s terminal.  
  • In this case, the KDSSB instead of HAPPY should cause an exception.  You will correct this in the upcoming activities.
  • Compare the intended receiver micro:bit’s LED display to the sniffers as well.
  • Reminder: If you are only using two micro:bit modules, test the sniffer first while it’s running the previous activity’s receiver script.  Then, load this activity’s receiver script and compare the difference.

 


Printer-friendly version
Try This: Improve the Script
Prev
Try This: Sniffing without Errors
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress