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 interesting: State 0: 69420, State N: 999, flag ends at state N, key length: one
- 0 = 69420
- 999 = flag
This is the beginning of the file. We can see HTB{, which is the beginning of the flag. It's just an example to show us how to get the flag. The first number shows us the current state; we have to start at 69420. The second number shows us the current value, the one we need to get the flag. The last value is the state for the next value. For example, if it ends at 45, we have to start at 45 for the next one.
Coding
I will use Bash.
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:
Error: Stuck in a Loop
After a short time, I saw the problem. The 4 93 1 should not be here.
I have to remove this line.
Error: Another Loop
Instead of 404, I should have 40. The issue is with the grep command, which matches 404 instead of 40.
Fix: Adding a Space After $current
I am changing this line to add a space after $current in the grep command:
read -r useless value current <<<$(grep ^"$current " deterministic.txt)
Now I have to add the values into a file and separate the values by a space. Instead of using a list, I use a file to store the result:
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
Result
Now I enter the values inside CyberChef and decode them with the key 69.
You managed to pass through all the correct states of the automata and reach the final state. Many people tried to do this by hand and failed... Only the real ones managed to reach the final state. You also found the secret key to decrypt the message. You are truly worthy!! You should be rewarded with this gift! The passphrase to unlock the door is: HTB{4ut0M4t4_4r3_FuUN_4nD_N0T_DiFF1cuLt!!}