HKCERT CTF 2022 Writeup - Scratch Passcode 2
Mics

Scratch Passcode 2 (125 points)
mics
Description
They have just upgraded the security system - you can’t enter the correct passcode using the keypad this time!
Scratch: https://scratch.mit.edu/projects/755732653/
By opening the scratch website, we can found the decryption logic

Then I convert it into python, and try to brute force the answer
import itertools
memory = [int(line.replace('\n', '')) for line in open('memory.txt').readlines()]
characters = [line.replace('\n', '') for line in open('characters.txt').readlines()]
for inp in itertools.product(range(50), repeat=4):
decrypted = ''
i = 1
j = len(memory)
for m in memory:
j = (j + 2) % 4 + 1
try:
if m // int(inp[j - 1]) - 1 >= 0:
decrypted += characters[m // int(inp[j - 1]) - 1]
i = i + 1
except Exception as e:
pass
print(f"Fail: {inp} {decrypted}")
if "pass" in decrypted:
print(f"Success: {inp} {decrypted}")
break
The memory.txt and characters.txt can be extracted by clicking the “extract” button on the list
Click to view the memory.txt and characters.txt
memory.txt
6
126
330
225
6
77
297
230
28
49
440
80
2
329
528
245
100
133
209
15
72
28
55
195
102
7
22
5
28
364
583
20
72
98
55
20
108
280
121
25
50
112
330
20
110
392
characters.txt
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
1
2
3
4
5
6
7
8
9
0
{
}
-
_
Click to view the flag
hkcert22{cr4ck1ng_passc0de-aband0ned_keyp4d}