Skip to content

Implementation of hill-climbing attack on the M4 Enigma Machine with a known partial setting.

Notifications You must be signed in to change notification settings

shreyas-sriram/enigma-cryptanalysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enigma Cryptanalysis

Implementation of hillclimbing attack on the M4 Enigma Machine based on Hillclimbing the Enigma Machine.

Initial Setting

Setting Value
Rotor setup (reflector) ? ? IV III
Initial start positions ? ? B Q
Ringstellung 1 1 1 16
Plugboard ?
Reflector C-thin

Answer for given ct.txt

Gamma VI IV III 
D A B Q 
AG BN DI ER FY HJ KU LW MS PQ

For more testcases, see testcases.md

Creating test cases

  1. Generate encrypted text using github.com/emedvedev/enigma or github.com/becgabri/enigma
enigma "EMMAWOODHOUSEXHANDSOMEXCLEVERXANDRICHXWITHACOMFORTABLEHOMEANDHAPPYDISPOSITIONXSEEMEDTOUNITESOMEOFTHEBESTBLESSINGSOFEXISTENCEXANDHADLIVEDNEARLYTWENTYXONEYEARSINTHEWORLDWITHVERYLITTLETODISTRESSORVEXHERXSHEWASTHEYOUNGESTOFTHETWODAUGHTERSOFAMOSTAFFECTIONATEXINDULGENTFATHERXANDHADXINCONSEQUENCEOFHERSISTERXSMARRIAGEXBEENMISTRESSOFHISHOUSEFROMAVERYEARLYPERIODXHERMOTHERHADDIEDTOOLONGAGOFORHERTOHAVEMORETHANANINDISTINCTREMEMBRANCEOFHERCARESSESXANDHERPLACEHADBEENSUPPLIEDBYANEXCELLENTWOMANASGOVERNESSXWHOHADFALLENLITTLESHORTOFAMOTHERINAFFECTIONXSIXTEENYEARSHADMISSTAYLORBEENINMRXWOODHOUSEXSFAMILYXLESSASAGOVERNESSTHANAFRIENDXVERYFONDOFBOTHDAUGHTERSXBUTPARTICULARLYOFEMMAXBETWEENTHEMITWASMORETHEINTIMACYOFSISTERSXEVENBEFOREMISSTAYLORHADCEASEDTOHOLDTHENOMINALOFFICEOFGOVERNESSXTHEMILDNESSOFHERTEMPERHADHARDLYALLOWEDHERTOIMPOSEANYRESTRAINTXANDTHESHADOWOFAUTHORITYBEINGNOWLONGPASSEDAWAYXTHEYHADBEENLIVINGTOGETHERASFRIENDANDFRIENDVERYMUTUALLYATTACHEDXANDEMMADOINGJUSTWHATSHELIKEDXHIGHLYESTEEMINGMISSTAYLORXSJUDGMENTXBUTDIRECTEDCHIEFLYBYHEROWNXTHEREALEVILSINDEEDOFEMMAXSSITUATIONWERETHEPOWEROFHAVINGRATHERTOOMUCHHEROWNWAYXANDADISPOSITIONTOTHINKALITTLETOOWELLOFHERSELFXTHESEWERETHEDISADVANTAGESWHICHTHREATENEDALLOYTOHERMANYENJOYMENTSXTHEDANGERXHOWEVERXWASATPRESENTSOUNPERCEIVEDXTHATTHEYDIDNOTBYANYMEANSRANKASMISFORTUNESWITHHERXSORROWCAMEXXAGENTLESORROWXXBUTNOTATALLINTHESHAPEOFANYDISAGREEABLECONSCIOUSNESSXMISSTAYLORMARRIEDXITWASMISSTAYLORXSLOSS" --rotors "Gamma I IV III" --rings="1 1 1 16" --position "F U B Q" --plugboard "AQ BN DI ER FY HJ KU LW MS PG" --reflector "C-thin"
  1. Store encrypted text in a file
echo -n "QYQXZXEHIGFISNYLHCDBRQAEIQQJLRSCAGABUZIDBUEKIKJZDCTWWQBMEPWDTJXBEUVXXRRGTAALQNUOBRRZKYBBYRAJBOHWHNPTWQNXGSWHTSUHAHDBEXFRMDNVDNUFFCOXCRBQFJGUHSGTQWOJFUUNWXUOODRJWDIHJBWOZXNJWJRZDQEHLBEVDHLKUYNDIRSRNWKFWATAXHZDOFNBOKUEWAHVBAQQXHNPYDEFHRELCVYWWBUDIMDFEVBIZFSKXERZJSSMOSDWUOPOKOYAJSEOIWMXXVUGLZYDVYKVOWKTOZKZESZZMORDYTCZSNKYVTUBAGRJVTXJEDGCLVMGSBQHODCKJIBLCENJJULKSQWQVFGIOWMWAJBBMRQOWPHALSTWIYMASNTCFAARFLOBRCLC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txt

About

Implementation of hill-climbing attack on the M4 Enigma Machine with a known partial setting.

Resources

Stars

Watchers

Forks

Languages