Done challenge 8
[cipher-tools.git] / 2019 / 2019-challenge8.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {},
7 "outputs": [],
8 "source": [
9 "import os,sys,inspect\n",
10 "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n",
11 "parentdir = os.path.dirname(currentdir)\n",
12 "sys.path.insert(0,parentdir) "
13 ]
14 },
15 {
16 "cell_type": "code",
17 "execution_count": 2,
18 "metadata": {},
19 "outputs": [],
20 "source": [
21 "from cipher.caesar import *\n",
22 "from cipher.affine import *\n",
23 "from cipher.keyword_cipher import *\n",
24 "from cipher.column_transposition import *\n",
25 "from cipher.vigenere import *\n",
26 "from support.text_prettify import *\n",
27 "from support.utilities import *\n",
28 "from support.plot_frequency_histogram import *\n",
29 "import re"
30 ]
31 },
32 {
33 "cell_type": "code",
34 "execution_count": 3,
35 "metadata": {},
36 "outputs": [],
37 "source": [
38 "challenge_number = 8\n",
39 "plaintext_a_filename = f'{challenge_number}a.plaintext'\n",
40 "plaintext_b_filename = f'{challenge_number}b.plaintext'\n",
41 "ciphertext_a_filename = f'{challenge_number}a.ciphertext'\n",
42 "ciphertext_b_filename = f'{challenge_number}b.ciphertext'"
43 ]
44 },
45 {
46 "cell_type": "code",
47 "execution_count": 4,
48 "metadata": {},
49 "outputs": [],
50 "source": [
51 "ca = open(ciphertext_a_filename).read()\n",
52 "cb = open(ciphertext_b_filename).read()\n",
53 "\n",
54 "rwa = wcat(cat(reversed(w)) for w in ca.split())\n",
55 "ra = cat(reversed(ca))\n",
56 "sca = sanitise(ca)\n",
57 "rsca = cat(reversed(sca))\n",
58 "pca = letters(ca)\n",
59 "pta = depunctuate(ca)\n",
60 "\n",
61 "scb = sanitise(cb)\n",
62 "pcb = letters(cb)\n",
63 "rscb = cat(reversed(scb))"
64 ]
65 },
66 {
67 "cell_type": "code",
68 "execution_count": 5,
69 "metadata": {},
70 "outputs": [
71 {
72 "name": "stderr",
73 "output_type": "stream",
74 "text": [
75 "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.\n",
76 " % get_backend())\n"
77 ]
78 },
79 {
80 "data": {
81 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFWNJREFUeJzt3X+wZGV95/H3JwyoYCLCXAky6GDEZNGsCw4sLnELQRNUzLC1xIVoAJfUrFmMJsYYiJvFskIVRmtdtzYxmQgLbliEEBU2apQdUPwFOAwgM4AyKyAzBcxFlAhU+PndP/qw1cwP+tzuvsw8c9+vqlvT5+nn6fPtvt396efpc8+kqpAkqTU/s70LkCRpHAaYJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSYu2dwEAixcvrqVLl27vMiRJO4DrrrvuvqqaGdVvhwiwpUuXsnr16u1dhiRpB5Dkzj79XEKUJDXJAJMkNckAkyQ1yQCTJDXJAJMkNckAkyQ1yQCTJDXJAJMkNckAkyQ1aWSAJTk3yaYkazdr/90ktyZZl+TPhtrPSLI+yfeS/Np8FC1JUp9TSZ0H/Hfg0081JHk9sBx4dVU9kuRFXftBwAnAK4EXA/8nySuq6olpFy5Jmn9LT/9C7753nP2WeaxkSyNnYFV1FXD/Zs2/A5xdVY90fTZ17cuBz1TVI1V1O7AeOGyK9UqSBIz/HdgrgNcluSbJ15Ic2rXvB9w11G9D1yZJ0lSNezb6RcBewOHAocDFSV42lxtIsgJYAfCSl7xkzDIkSQvVuDOwDcBna+Ba4ElgMbAR2H+o35KubQtVtbKqllXVspmZkf/tiyRJTzNugH0eeD1AklcAuwH3AZcBJy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ynPxNH9wl0TVX1/UQuPaMkS4G/r6q+R3o1qTva8cGq+tj2rmVYkudX1YPdkZ9XASuqas32rmsaug9ga4DfqKrbtnc9O7qdegmxW9b7NoOjcyTtHFZ2B+usAf5uJwqvgxgc5bjK8Opnp5+BSZJ2Tjv1DEyStPMywCRJTTLAJElNMsAkSU0ywCRJTTLAJElN+n8yzCjn0bwVXwAAAABJRU5ErkJggg==\n",
82 "text/plain": [
83 "<Figure size 432x288 with 1 Axes>"
84 ]
85 },
86 "metadata": {
87 "needs_background": "light"
88 },
89 "output_type": "display_data"
90 }
91 ],
92 "source": [
93 "fc = collections.Counter(sca)\n",
94 "plot_frequency_histogram(fc, sort_key=fc.get)"
95 ]
96 },
97 {
98 "cell_type": "code",
99 "execution_count": 6,
100 "metadata": {},
101 "outputs": [
102 {
103 "name": "stdout",
104 "output_type": "stream",
105 "text": [
106 "abcdefghijklmnopqrstuvwxyz \n",
107 "\n"
108 ]
109 },
110 {
111 "data": {
112 "text/plain": [
113 "'harryiputtogetherateamofwomenfromthecomputingdivisionhereatkennedyandwehavespentmostofthelasteighteenmonthscombingthroughmissionfilesandcomputerprintoutslookingformorecluestothesourceoftheoxygentankexplosiononboardapolloxiiiandithinkwehavefinallyworkedoutwhathappenedthetankcontainingthesourceoftheexplosionwasoriginallyinstalledinapolloxbutremovedformodificationduringthatprocessitgotdroppedsoitwasheldbackforfurthertestsandareplacementfittedforthatflightonceithadpassedinspectionthetankwasreturnedtoserviceandearmarkedforodysseyfurtherupgradeswerecarriedouttoallowittorunoffgroundpowerduringfitoutattwicethespaceshipvoltageandthehigherpowerwasusedtoboiloffexcessoxygenduringgroundtestsunfortunatelyitlookslikethethermostaticswitchesinthetankwereoverlookedduringthevoltageupgradeandourbestguessisthattheyfusedclosedduringtheboiloffallowingthetemperaturetorisetooverathousanddegreesyoumightthinkthetestengineerswouldhavenoticedthatbutsincethetankoperatingtemperaturewassupposedtobesomewherewellbelowzerothedialonlywentasfaraspluseightysonoonewouldhavenoticedoperatingthatfaroutofnormalrangeitisamiraclethetanklastedaslongasitdidandthataddstotheimpressionthatthiswasasimpleaccidentachainofeventsthatcouldnothavebeenforeseenbutthecomputerfilestelladifferentstorywefoundtwoversionsoftheupgradereportwhichwaswrittentodetailtheproceduresformodifyingtheelectricalsystemonthetankthefirstgivesacomprehensivelistofthecablingswitchgearandcontrolsystemsthatneededtobehardenedforthegroundbasedvoltageitlistseverycriticalcomponentexceptthethermostaticvalvesthisdocumentwasfiledintheservicerecordsoweknowitwastheofficialrecordbutthechiefsystemsengineerwhosigneditoffsaysthesignatureonitisabadcopyofhisownwefoundidenticalcopiesinseveralmissionfilesbothinthemanufacturersrecordsandatkennedywheresomeofthetestswerecarriedoutsoitisclearthatthiswastheofficialversionusedintheupgradethesecondversionappearedtobethesamedocumentbutitincludedthethermostaticvalvesonthelistofcomponentstobechangedandthetemperaturegaugelimitswerecircledseveraltimeswithanexclamationmarknexttotheeightydegreeceilingitlookslikeoursaboteurdeliberatelyarrangedforthetanktobemisconfiguredinanefforttocausetroubleforthemissionalthoughwecantbesuretheyrealisedhowdangerousthiswaswhenweputittogetherwithalltheotheraccidentsitisprettyclearthiswasanotherdeliberateattackontheprogramwefoundthesecondversionofthereportinaboxunderthefloorboardsinmikesplaceisupposeitispossiblethatmikehadstumbledacrossthedocumenthimselfandwasinvestigatingitaspartofhiscampaigntoprovethattherussianswerebehindthisstringofproblemsbutattheveryleastheisguiltyofamajormisjudgementandiftheastronautshaddiedhewouldhavebeentriedformanslaughterasitistogetherwiththeleakchargeshewillbegoingtoprisonforaverylongtimeofcoursetheevidenceisstilllargelycircumstantialwecandefinitelytiehimtotheleaktothenewspaperforensicsmatchedthetypewriterribbonandtypecharacteristicsonhistypewriterwiththeinkandimpressionsonthelettertotheeditorbutwestillcannotshowconclusivelythathedirectedorcarriedoutanyofthesabotageattemptsandwehavenotbeenabletofindanyoneelsewhohadbothmotiveandopportunitysoheisourbestsuspectiamnotsurewecanentirelyrelaxbutwithnosignificantincidentsonapolloxivtoxviandwithmikeincustodyifeelslightlylessworriedabouttheremainingapolloflightwearestilltryingtocrackthatotherenciphereddocumentwefoundinmikesplaceithasaverystrangealphabetwhichithinkmustbesignificantbuticantquiteseehowtobreakityetnowthatthenasacomputingexpertshavemoretimeiamhopingthatweshouldbeabletodecipheritandthatitwillshedsomemorelightonmikesthinkingmoreimportantlyitmighttelluswhatelseifanythinghehadplannedmeg'"
114 ]
115 },
116 "execution_count": 6,
117 "metadata": {},
118 "output_type": "execute_result"
119 }
120 ],
121 "source": [
122 "k_a, score_b = vigenere_frequency_break(sca, fitness=Ptrigrams, max_key_length=26)\n",
123 "print(k_a, '\\n')\n",
124 "pa = vigenere_decipher(sca, k_a)\n",
125 "pa"
126 ]
127 },
128 {
129 "cell_type": "code",
130 "execution_count": 7,
131 "metadata": {},
132 "outputs": [
133 {
134 "name": "stdout",
135 "output_type": "stream",
136 "text": [
137 "harry i put together a team of women from the computing division here at kennedy and we have spent\n",
138 "most of the last eighteen months combing through mission files and computer printouts looking for\n",
139 "more clues to the source of the oxygen tank explosion onboard apollo xiii and i think we have\n",
140 "finally worked out what happened the tank containing the source of the explosion was originally\n",
141 "installed in apollo x but removed for modification during that process it got dropped so it was held\n",
142 "back for further tests and a replacement fitted for that flight once it had passed inspection the\n",
143 "tank was returned to service and earmarked for odyssey further upgrades were carried out to allow it\n",
144 "to runoff ground power during fit out at twice the spaceship voltage and the higher power was used\n",
145 "to boil off excess oxygen during ground tests unfortunately it looks like the thermostatic switches\n",
146 "in the tank were overlooked during the voltage upgrade and our best guess is that they fused closed\n",
147 "during the boil off allowing the temperature to rise to over a thousand degrees you might think the\n",
148 "test engineers would have noticed that but since the tank operating temperature was supposed to be\n",
149 "somewhere well below zero the dial only went as far as plus eighty sono one would have noticed\n",
150 "operating that far out of normal range it is a miracle the tank lasted as long as it did and that\n",
151 "adds to the impression that this was a simple accident a chain of events that could not have been\n",
152 "foreseen but the computer file stella different story we found two versions of the upgrade report\n",
153 "which was written to detail the procedures for modifying the electrical system on the tank the first\n",
154 "gives a comprehensive list of the cabling switchgear and control systems that needed to be hardened\n",
155 "for the ground based voltage it lists every critical component except the thermostatic valves this\n",
156 "document was filed in the service records owe know it was the official record but the chief systems\n",
157 "engineer who signed it off says the signature on it is a badcopy of his own we found identical\n",
158 "copies in several mission files both in the manufacturers records and at kennedy where some of the\n",
159 "tests were carried out so it is clear that this was the official version used in the upgrade the\n",
160 "second version appeared to be the same document but it included the thermostatic valves on the list\n",
161 "of components to be changed and the temperature gauge limits were circled several times with an\n",
162 "exclamation mark next to the eighty degree ceiling it looks like our saboteur deliberately arranged\n",
163 "for the tank to be misconfigured in an effort to cause trouble for the mission although we cant be\n",
164 "sure they realised how dangerous this was when we put it together with all the other accidents it is\n",
165 "pretty clear this was another deliberate attack on the program we found the second version of the\n",
166 "report in a box under the floorboards in mikes place i suppose it is possible that mike had stumbled\n",
167 "across the document himself and was investigating it as part of his campaign to prove that the\n",
168 "russians were behind this string of problems but at the very least he is guilty of a major\n",
169 "misjudgement and if the astronauts had died he would have been tried for manslaughter as it is\n",
170 "together with the leak charges he will be going to prison for a very longtime of course the evidence\n",
171 "is still largely circumstantial we can definitely tie him to the leak to the newspaper forensics\n",
172 "matched the typewriter ribbon and type characteristics on his typewriter with the ink and\n",
173 "impressions on the letter to the editor but we still can not show conclusively that he directed or\n",
174 "carried out any of the sabotage attempts and we have not be enable to find anyone else who had both\n",
175 "motive and opportunity so he is our best suspect i am not sure we can entirely relax but with no\n",
176 "significant incidents on apollo xiv to xvi and with mike in custody i feel slightly less worried\n",
177 "about the remaining apollo flight we are still trying to crack that other enciphered document we\n",
178 "found in mikes place it has a very strange alphabet which i think must be significant but icant\n",
179 "quite see how to break it yet now that the nasa computing experts have more time i am hoping that we\n",
180 "should be able to decipher it and that it will shed some more light on mikes thinking more\n",
181 "importantly it might tell us what elseif anything he had planned meg\n"
182 ]
183 }
184 ],
185 "source": [
186 "print(lcat(tpack(segment(pa))))"
187 ]
188 },
189 {
190 "cell_type": "code",
191 "execution_count": 8,
192 "metadata": {},
193 "outputs": [
194 {
195 "data": {
196 "text/plain": [
197 "4375"
198 ]
199 },
200 "execution_count": 8,
201 "metadata": {},
202 "output_type": "execute_result"
203 }
204 ],
205 "source": [
206 "open(plaintext_a_filename, 'w').write(lcat(tpack(segment(pa))))"
207 ]
208 },
209 {
210 "cell_type": "code",
211 "execution_count": null,
212 "metadata": {},
213 "outputs": [],
214 "source": []
215 }
216 ],
217 "metadata": {
218 "kernelspec": {
219 "display_name": "Python 3",
220 "language": "python",
221 "name": "python3"
222 },
223 "language_info": {
224 "codemirror_mode": {
225 "name": "ipython",
226 "version": 3
227 },
228 "file_extension": ".py",
229 "mimetype": "text/x-python",
230 "name": "python",
231 "nbconvert_exporter": "python",
232 "pygments_lexer": "ipython3",
233 "version": "3.6.9"
234 }
235 },
236 "nbformat": 4,
237 "nbformat_minor": 4
238 }