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: Brute Force Attacks & Defenses

Cybersecurity: Brute Force Attacks & Defenses

Decimal Bank Vault Crack

The brute force attack for the decimal vault is almost ready.  All you have to do is add ’2’, ’3’, ’4’, and ’5’ to the digits list.  The nested loops automatically go through all the items in the digits list regardless of how many items it contains.  So, instead of eight combinations, the updated list will cause the script to try up to 216 combinations.

Example script: decimal_bank_vault_crack.py

  • Open the bank_vault_crack script with the micro:bit Python Editor.
  • Change the project name to decimal_bank_vault_crack.
  • Make the changes shown in the decimal_bank_vault_crack script shown below.
  • Save and then click Send to micro:bit to flash the script into the PIN Pad micro:bit.
  • Press the A button to start the decimal brute force attack on the decimal bank vault.
# decimal_bank_vault_crack.py                 # <- change

from microbit import *
import radio

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

# digits = ['0','1']                          # <- comment (before change)
digits = ['0','1','2','3','4','5']            # <- change

display.show(Image.ARROW_W)

while True:
    if button_a.was_pressed():
        
        display.clear()

        for a in digits:
            for b in digits:
                for c in digits:
                    pin = ''.join([a, b, c])
                    
                    print("pin =", pin)
                    
                    for x in range(3):
                        for y in range(int(pin[x])):
                            display.set_pixel(x, y, 9)

                    response = None
                    while response is None:
                        radio.send(pin)
                        sleep(100)
                        response = radio.receive()
                            
                    print(response)
                    if response == "Access granted.":
                        while True:
                            display.scroll(pin)

                    sleep(4000)
                    display.clear()
  • Verify that the decimal_bank_vault_crack script is trying the various combinations.

 

 

The Math

While you are waiting for the crack script to succeed, let’s calculate how long it will take.

Since each digit counts from 0 to 5, that’s 6 possible digits: 0, 1, 2, 3, 4, and 5.  After the right digit has counted through its 6 possibilities, the middle digit increases by 1, and the right digit has to start over.  All told, the two right digits have 6 x 6 = 36 combinations.  The third digit also has 6 possibilities, and for each of those, the right two digits must go through all their combinations.  So, that’s 6 x 36 = 216.

More generally, if p = number of possible values for each digit, d = the number of digits, and c = the number of combinations, you can calculate the possible values like this:

c = pd

Let’s try it with p = 6 and d = 3.  That’s:

c = 63= 216.

Now, remember that there’s a 4 second delay between each try.  So the number of seconds for all combinations would be:

216 x 4 seconds = 864 seconds.  

846 seconds x ( 1 minute / 60 seconds ) = 14.4 minutes.  

Also, to reach 324, the decimal bank vault crack will have to go through this many combinations:

Digit-left : 3 repetitions x 36 = 108

…because the middle and right digits have to go through their cycles for each time the left digit increases by 1.

When digit-left = 3, that’s the fourth repetition, and the right digits still have some cycles.

Digit-middle needs to go through  2 more cycles, x 6 for the right digit = 12

On the middle digit’s 3rd cycle, the right digit has to count 0, 1, 2, 3, 4, which is 5 repetitions.

Total: 108 + 12 + 5 combinations = 125 combinations.  

In terms of minutes, that’s:

125 combinations x 4 seconds/combination x (1 minute / 60 seconds) = 8.33 minutes.

What happens if you increase the number of digits to 4?  

Answer: _______ (216 x 6 = 1296)

What’s the longest a brute force attack would take in that case?

Answer: _______ (1296 combinations x 4 seconds/combination = 5184 seconds.   5184 seconds x 1 minute / 60 seconds = 86.4 minutes.  That’s over 1 hour and 26 minutes.)

 


Printer-friendly version
How the Decimal Code Works
Prev
Your Turn: Strategies to Strengthen PINs
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress