the-lambda-way / bruteforce-enigma

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

what should be the method used to decipher a ciphertext only (no plug,rotor,ring known) #12

Closed AbdelilahMeddahi closed 6 months ago

AbdelilahMeddahi commented 7 months ago

what should be the method used to decipher a ciphertext only (no plug,rotor,ring known) + I tried some of the functions got the rotos I, IV, III while i used a python script to bruteforce rotors using IOC and got III,IV,I, what is the order of the rotor output by the tool ?

the-lambda-way commented 7 months ago

This tool does not crack plugboards yet. If you have any clues you can try to guess the plugoard, or write a loop testing a list of suspected plugboards. If I understand correctly, when you start an attack with no plugboard you will still decrypt a significant portion of a ciphertext (using IOC scoring instead of quadgram scoring), and can use this to determine the rotor settings. With the correct rotor settings, you can then attack the plugboard using a hill climbing or similar algorithm.

The way to crack ciphertext only if you know the plugboard is to do something like this:

Ciphertext ct = "NPNKANVHWKPXORCDDTRJRXSJFLCIUAIIBUNQIUQFTHLOZOIMENDNGPCB";
Plugboard plug = "";

HighScores scores = smart_decipher(m3_model, plug, ct);
scores.print();

Repeat this with every model in model.h except m4_model in a loop. The whole thing only takes 1 minute on my machine. The m4_model takes 15 minutes by itself on my machine, so I always test it separately.

When I designed the interface I chose the standard English programming convention of inputting rotor parameters from left to right and starting indices from 0. It turns out most other enigma programs follow the physical Engima machine practice of reading rotors from right to left and starting wheel indices from 1. I plan to change the interface at some time to match this convention.