The original Sender script terminal_bot_controller_wireless.py is explained here: How the Wireless Controller Script Works [1].
The exception handling added to the Sender script is explained here: Your Turn: Handle Transmitter Exceptions [2].
The cyber:bot Receiver script terminal_controlled_bot_wireless is explained here: How the Wireless Controlled Bot Script Works [3].
With that aside, let’s look at how the Receiver script terminal_controlled_bot_wireless was modified to send a malformed packet in response to a negative value.
At this point in the Sender script, the maneuver values have all been collected, and before the statements below, the dictionary looks like this: { 'vL': 25, 'vR': 25, 'ms': -1 }. If the ms variable receives -1 from ms = int(input("Enter ms to run: ")) earlier in the script, the if ms < 0: statement detects it, and changes the dictionary to dictionary = { 'vL': -20, 'vR': 20, 'ms': "Not a number!" }.
# Sends malformed packet attack if ms to run is negative. if ms < 0: dictionary = { 'vL': -20, 'vR': 20, 'ms': "Not a number!" }
If you guessed that the receiver script also needs protection with a try-except statement, you were right!
Links
[1] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-navigation-control-keyboard/terminal-control-%E2%80%94-go-wireless-3
[2] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-navigation-control-keyboard/terminal-control-%E2%80%94-go-wireless-6
[3] https://learn.parallax.com/tutorials/robot/cyberbot/cybersecurity-navigation-control-keyboard/terminal-control-%E2%80%94-go-wireless-4