I am a beginner in reverse engineering.

For a challenge I need to reverse a code in python this code use enigma algorithm : To found the good configuration to decode the enigma code received.

The goal is to found the good configuration the bellow :

``````def create_configuration():
number_of_rotors = random.randrange(3, 6)
rotates_amounts = [3, 5, 7, 11, 17, 19, 23]

result = []
for _ in range(number_of_rotors):
rotor = "".join(random.sample(string.ascii_uppercase, 26))
rotates_amount = random.choice(rotates_amounts)
result.append([rotor, rotates_amount])
return result
``````
• After analyse I decided to make a bruteforce because I can see a random.choice and it's "impossible" to found exacly the sames configuration as the server who encoded the message. For That I modify this code :
• number_of_rotors is a number between 3 and 6 logically it's will be a loop [3, 4, 5, 6]
• rotates_amounts is all the possibilities numbers for the originally list ([3, 5, 7, 11, 17, 19, 23])

code :

``````def create_configuration(number_of_rotors, rotates_amounts):
result = []
for i in range(number_of_rotors):
rotor = "".join(random.sample(string.ascii_uppercase, 26))
rotates_amount = rotates_amounts[i]
result.append([rotor, rotates_amount])
return result
``````

I added The generator function to generate all the possibilities as (i am using itertools): [3,3,3,3,3,3,3],[3,3,3,3,3,5],...

``````def generators():
values = []
val = [3, 5, 7, 11, 17, 19, 23]
for _set in product(val, repeat=7):
values.append(_set)
return values
``````

This part of code also generate randomly ascii list :

``````rotor = "".join(random.sample(string.ascii_uppercase, 26))
``````

So my questions is :

• I don't know if it's the good approach for this problem ? If people have ideas.

Thank you very much.

• enigma is symmetric you can use the same encypt algo to decrypt also like enig Hello = VBSEN / enig VBSEN = Hello – blabb May 10 '20 at 21:00
• I’m voting to close this question because it is about cryptanalysis and should be posted on Cryptography Stack Exchange website. – perror May 13 '20 at 8:29