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

Try This: Improve the Script

Try This – Prove it Works

If you’re skeptical that packet = “HAPPY” followed by getattr(Image, packet) is equivalent to Image.HAPPY, try this:

  • Add this routine between sleep(1000) and while True: in the transmitter script radio_send_images.py.
  • Flash the modified script with the Send to micro:bit button.
print("Image.HAPPY =", Image.HAPPY)
sleep(500)
packet = "HAPPY"
print( "getattr(Image, packet) =", getattr(Image, packet) )    
sleep(500)
  • If the serial monitor isn’t already open, click Show serial.
  • Verify that the results resemble what’s shown here.

Image(…) has brightness data for each LED in the display.  In this case it only uses 0 (LED off), and 9 (LED brightest).  Values between 0 and 9 for each LED can be used to control the brightness.
 

 

Your Turn – Compact your Code

This code takes up unnecessary program space in the micro:bit module’s memory.  

    packet = "HAPPY"
    print("Send:", packet)
    radio.send(packet)
    sleep(2500)
    
    packet = "SAD"
    print("Send:", packet)
    radio.send(packet)
    sleep(2500)

    packet = "ANGRY"
    print("Send:", packet)
    radio.send(packet)
    sleep(2500)

Your program can instead create a list like string_list = [“HAPPY”, “SAD”, “ANGRY”].  Then, inside the while True loop, the for packet in string_list can index through each string in string_list.

  • Use that hint to modify the radio_send_images transmitter script.  
  • Test and verify your solution.  

 


Printer-friendly version
How the Sender, Receiver, and Sniffer Work
Prev
Share Something Personal – Encrypted!
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress