HackTheBox VHDLock Writeup
Explore the basics of cybersecurity in the VHDLock Challenge on Hack The Box. This easy-level Challenge introduces encryption reversal and file handling concepts in a clear and accessible way, perfect for beginners.
https://app.hackthebox.com/challenges/468
Description
We find ourselves locked in an escape room, with the clock ticking down and only one puzzle to solve. The final challenge involves opening the door, and the clue provided to us by the game master is that the key for the encrypted password is a 4-byte sequence.
Exploitation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python3
def decoder_4x16(signal):
cases = dict()
val = 1
for n in range(16):
cases[n] = val
val = val << 1
if (signal < 0) or (signal > 15):
return 0
else:
return cases[signal]
def encoder_4x16(signal):
cases = dict()
val = 1
for n in range(16):
cases[val] = n
val = val << 1
return cases[signal]
inputs = []
outputs = [35, 307, 17, 33, 33, 53, 183, 2103]
key = []
for c in "HTB{":
inputs.append((ord(c) & 0xf0) >> 4)
inputs.append(ord(c) & 0x0f)
for i in range(len(inputs)):
new_key = decoder_4x16(inputs[i]) ^ outputs[i]
if new_key not in key:
key.append(new_key)
for k in key:
print(f"0x{k:02X}")
key = [ 0x33, 0x31, 0x31, 0x37 ]
lines = None
outputs = []
flag = ""
with open("out.txt") as f:
lines = f.readlines()
for line in lines:
outputs.append([int(x) for x in line.strip().split(" ")])
for i in range( len(outputs) ):
d1 = encoder_4x16( outputs[i][0] ^ (key[i % 4] ))
d2 = encoder_4x16( outputs[i][1] ^ (key[i % 4] ))
c = (d1 << 4) | d2
flag += chr(c)
print(flag)
Summary
The VHDLock Challenge on Hack The Box is an easy-level challenge focusing on encryption reversal. The Python script derives a key from “HTB{“ using XOR with predefined outputs and uses it to decrypt a message in a file, demonstrating basic encryption techniques and reversal.