Frosty Keypad was a fun challenge designed to simulate breaking through physical security by brute-forcing a keypad.

Accessing the Challenge

This was the first challenge that I attempted for this year's Holiday Hack.  The challenge can be found in the eastern end of the quad.  Speak to Tangle Coalbox and you'll receive some hints for the challenge.

Hey kid, it's me, Tangle Coalbox.
I'm sleuthing again, and I could use your help.

Ya see, this here number lock's been popped by someone.

I think I know who, but it'd sure be great if you could open this up for me.
I've got a few clues for you.

1. One digit is repeated once.

2. The code is a prime number.

3. You can probably tell by looking at the keypad which buttons are used.

Yep, that's it. Thanks for the assist, gumshoe.

Hey, if you think you can help with another problem, Prof. Banas could use a hand too.

Head west to the other side of the quad into Hermey Hall and find him in the Laboratory.

The goal is to figure out a valid code on the keypad to gain entry through the locked door.

Clicking on the Frosty Keypad challenge will display the keypad.  You'll notice some numbers show a higher degree of wear than others.  This simulates real-world keypads where commonly pressed numbers will show more degradation than less used numbers.

Frosty Keypad

Check Worn Keys

Looking at the keypad, there's definitely more wear on the 1, 3, and 7 keys.

Create List of Permutations

With the provided information, I decided the best approach would be to write a Python script to return all of the 4-digit permutations of 1, 3, and 7.

Forgive my Python; I wrote the code quickly so it might not be the most efficiently written code.  Since I assumed the code was four digits and I knew one digit was repeated, I created a permutation list with two of each number (i.e. [1, 1, 3, 3, 7, 7]).

The hint given by Tangle Coalbox also says that the key is a prime number.  So, I created a function to check if a given number was prime (special thanks to GeekforGeeks' Shivam_k for the prime number function code).

from itertools import permutations as p

perm = p([1, 1, 3, 3, 7, 7], 4)
perm_list = list(perm)


def check_prime(num):
    if num <= 1:
        return False
    elif num <= 3:
        return True

    if num % 2 == 0 or num % 3 == 0:
        return False

    i = 5
    while i * i <= num:
        if num % i == 0 or num % (i + 2) == 0:
            return False
        i += 6

    return True


def create_list(a):
    set_list = set()
    num_list = []
    for i in a:
        if 1 in i and 3 in i and 7 in i:
            set_list.add(i)

    new_list = list(set_list)
    new_list.sort()

    for i in new_list:
        num_list.append(f'{i[0]}{i[1]}{i[2]}{i[3]}')

    return num_list


for i in create_list(perm_list):
    if check_prime(int(i)):
        print(i)

Results

After crafting the script and running it, I found that there were 5 possible prime numbers that could be the code.

1373
1733
3137
3371
7331

After trying each number, I found the answer to be 7331.


Conclusion

This challenge wasn't too difficult and I really enjoyed brushing up on my Python skills.  This challenge demonstrates how individuals can "hack" a keypad just by observing which keys are worn out.  I use a smart lock for my home and now and then I can see which numbers have fingerprints and which are clean.  With smart home devices like smart locks on the rise, it's important to make sure you rotate your pass codes and keep the device clean of smudges or anything that could potentially give unwanted access.