Deterministic

There is a locked door in front of us that can only be opened with the secret passphrase.
There are no keys anywhere in the room, only this .txt.
There is also a writing on the wall.. “State 0: 69420, State N: 999, flag ends at state N, key length: one”..
Can you figure it out and open the door?

deterministic.txt

Hints

We need to code something.
This is very intersting: State 0: 69420, State N: 999, flag ends at state N, key length: one
0=69420
999=flag
Where is the 0 to find it we need to find 69420

key lenght=one
What does it mean?

This is the beginning of the file.
We can see HTB{, it’s the beginning of the flag, it’s just an example to chow us how to get the flag

The first number show us the current state, we have to start at 69420.
The second number show us the current value, the one we need to get the flag.
The last value is the value of the next value, for exemple, if it’s ending at 45, we have to start at 45 for the next one.

Coding

I will use bash.

1
2
3
4
5
6
7
8
9
10
11
last=999
current=69420

ListValue=()
while [[ "$current" != "999" ]];
do
read -r useless value current <<<$(grep ^$current deterministic.txt)
echo "$useless|$value|$current"
ListValue=(${ListValue[@]} "$value")
done
echo $ListValue:

Stuck in a loop

After a short time I saw the problem,
The 4 93 1 should not be here.

I have to remove him
I got an another loop…

Instead of 404 I should have 40
I’m changing this line to add a space after the $current.

Now I have to add the values into a file and separate the value by a space.
Instead of using a list, I use a file to store the result

1
2
3
4
5
6
7
8
9
last=999
current=69420

while [[ "$current" != "999" ]];
do
read -r useless value current <<<$(grep ^"$current " deterministic.txt)
echo "$useless|$value|$current"
echo -n $value >> Value.txt
done

Now I enter the values inside cyberchef and decode it with the key 69.