the-lambda-way / bruteforce-enigma

A tool for cracking and bruteforcing Enigma ciphers.
MIT License
19 stars 3 forks source link

Rotor and ring positions #3

Closed Dreamoochy closed 1 year ago

Dreamoochy commented 1 year ago

E.g. there is encrypted text and plugboard. I have successfully decrypted the text:

#    Score         Refl     Rotor Order         Ring Pos   Rotor Pos  Text
 1   -130.689911   UKWB     V     II    III      3  1  0   25  4 21   SOMEDECRYPTEDTEXT

But I'm unable to decrypt that same text in online enigma simulators using listed settings.

  1. Are rotors and rings ordered left to right or right to left?
  2. What does Ring pos 0 mean? All ring pos in simulators start with 1. Are ring and rotor pos have 0-based indexes?
the-lambda-way commented 1 year ago

There is no standard rotor order among the online simulators, so you'll have to experiment. I designed this to read left-to-right with 0-based indexes.

I'll update the readme to be more user friendly. I'll add some popular enigma sites with their rotor orders for a quick reference.

the-lambda-way commented 1 year ago

After reviewing 7 other Enigma tools, it appears the majority of online tools follow the historical Engima practice of reading the rotors right to left and using 1-based indexing. So I'll have to update my tool to match the norm. I don't know where I got the wrong idea from.

Dreamoochy commented 1 year ago

After reviewing 7 other Enigma tools, it appears the majority of online tools follow the historical Engima practice of reading the rotors right to left and using 1-based indexing. So I'll have to update my tool to match the norm. I don't know where I got the wrong idea from.

The rotors ordering and rings indexing is not a problem once documented. The main problem for me is that I can't reproduce the result using other tools. E.g. with the following data

Ciphertext ct = "RNBNJQIQNQJIAVLVKPJDDUFNKEG";
Plugboard plug = "GT YC EJ UA RX PN IS WB MH ZV";

I get

#    Score         Refl     Rotor Order         Ring Pos   Rotor Pos  Text
 1   -130.689911   UKWB     V     II    III      3  1  0   25  4 21   NOTHINGISSTOLENWITHOUTHANGS

But with e.g. DenCode Enigma simulator I'm unable to decode that text using the found settings in different combinations. Maybe I'm doing something wrong.

the-lambda-way commented 1 year ago

I believe there is a bug in DenCode. Here is the decryption using Practical Cryptography

image

I did some testing on DenCode and narrowed it down to using rotor V in the rightmost position. You may want to report this bug on DenCode's issue page.

You can reproduce this bug using Practical Cryptography. Put the correct settings into Practical Cryptography and into DenCode. Then if you put NOTHINGISSTOLENWITHOUTHANGS into the Plaintext box on Practical Cryptography you can get the ciphertext encryption to put into DenCode. Now if you change the rotor order to 323 and put the ciphertext into DenCode you will see it decrypts correctly. Try with 523 and 353 and DenCode also works correctly. Try with 325 and DenCode fails.

Dreamoochy commented 1 year ago

You can reproduce this bug using Practical Cryptography.

Thank you. It indeed looks like a bug. I've tried rotors 5..8 and another online tool CacheSleuth. CacheSleuth produces the same results as Practical Cryptography. I've also found another tool (Cryptii) that behaves as DenCode with rotors 5..8. Probably they use the same code.

UPD. It seems that the middle rotor II causes the issue, because with other values (I didn't test all) the rightmost rotors 5..8 give correct results.