I used ChatGPT for creating a first draft of the decoder script to save time.
We have a dll file that we have to analyze. The program that comes with it seems to be a game where you have to enter the correct ingredients for a potion.
Opening the dll file in ILSpy, I could immediately see the correct ingredients and how they are processed. I will try to write a Python decoder:
The decoder is based on the information I gained from ILSpy, but I must admit I used ChatGPT to create the script. I learned that you can create an indexmap to do a string search on an array in Python, which is super useful.
import os
list1 = open("allflags.txt","r")
list2 = open("correctflags.txt","r")
indexmap = {item: index for index, item in enumerate(list1)}
result = []
for string in list2:
if string in indexmap:
index = indexmap[string] + 32
result.append(chr(index))
concatenatedresult = ''.join(result)
print(concatenatedresult)
HTB{y0ur3_4_tru3_p0t10n_m45st3r_n0w}
Flag Decoder:
byte[] bytes = recipe.Select((Ingredient ing) => (byte)(Array.IndexOf(IngredientNames, ing.ToString()) + 32)).ToArray();
Console.WriteLine("The spell is complete - your flag is: " + Encoding.ASCII.GetString(bytes));