From: Neil Smith Date: Mon, 14 Nov 2016 17:47:43 +0000 (+0000) Subject: 2016 challenge 4 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=dae3e5832d59dfee328555b4af58e080ab64dd23;p=cipher-training.git 2016 challenge 4 --- diff --git a/2016/2016-challenge4.ipynb b/2016/2016-challenge4.ipynb new file mode 100644 index 0000000..c8bb5a4 --- /dev/null +++ b/2016/2016-challenge4.ipynb @@ -0,0 +1,372 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import os,sys,inspect\n", + "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n", + "parentdir = os.path.dirname(currentdir)\n", + "sys.path.insert(0,parentdir) \n", + "\n", + "import matplotlib.pyplot as plt\n", + "%matplotlib inline\n", + "\n", + "from cipherbreak import *\n", + "\n", + "c4a = open('4a.ciphertext').read()\n", + "c4b = open('4b.ciphertext').read()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'MWJJT WDEVM WJBXF XWCDG VBGKF JLGLM FHEKK TDEXV WLFAN LXLMX DZXMW PFAFR NDLGN DJWPF BQMTL MFTCX RMLAF XDLFJ FKLFE XDYWC FBXWW DECWJ LXDWK KMFLG BENKX DLMFM XEEFD CFKKW RFXKF DLBWK LQFFZ YWCFB XWMWE AFFDQ GJZXD RGDKX RDWBJ FVGRD XLXGD WLETD WCXSW LOXJK LXQWK HNUUB FEATL MXKWK XVGNB EDLKF FMGQX LJFBW LFELG QFWHG DXKFE RJWPX LTQWP FKANL LMFDX LGGZW BGGZW LMFJA GGZKM FBOWD EXLAF RWDLG CWZFK FDKFX LQWKO NBBGO AGGZK GDRFD FJWBJ FBWLX PXLTA BWVZM GBFKW DEDFN LJGDK LWJKY WCFBX WQWKD GLQGJ ZXDRG DRJWP XLTQW PFKAN LGDRJ WPXLW LXGDW BQWPF KXVWD KFFMG QLMFO XFBEW RFDLK QGNBE MWPFR GLVGD ONKFE XDLMF NKLMF TKGCF LXCFK NKFAG LMDWC FKOGJ LMFKW CFLMX DRANL LMFTJ FWBBT WJFEX OOFJF DLRJW PXLTQ WPFKW JFWKF XKCGB GRXVW BHMFD GCFDG DWKTG NWBJF WETOX RNJFE GNLRJ WPXLW LXGDW BQWPF KWJFF DLXJF BTEXO OFJFD LFXDK LFXDH JFEXV LFELM FCWMN DEJFE TFWJK WRGWD ELMFT QFJFE FLFVL FEATL MFBXR GLFWC BWKLT FWJLM FKXRD WBKWJ FRXPF DGOOA TLMXD RKBXZ FAXDW JTABW VZMGB FKTKL FCKWD EWJFX DVJFE XABTO WXDLL MFTFW KXBTR FLKQW CHFEA TBGVW BDGXK FXLQW KWDWC WUXDR OFWLE FLFVL XDRLM FCWDE YWCFB XWQWK HWJLG OLMWL LGWEE LGGNJ VGDON KXGDK MFQWK XDLMF LFWCJ FKHGD KXABF OGJEF KXRDX DRLMF KFWJV MWBRG JXLMC KWDEL MFDGX KFOXB LFJKN KFELG KHGLL MFKXR DWBGO WRWBW VLXVF PFDLW RWXDK LLMFD GXKFG OKFXK CGBGR XVWBW VLXPX LTKGK MFEXE ZDGQK GCFLM XDRWA GNLRJ WPXLT QWPFK LGGXK LXBBE GDLZD GQFSW VLBTM GQETD WCXSQ FJFNK XDRMF JFSHF JLXKF GJQMW LLMFH EKKTD EXVWL FWJFG JEGXO TGNVW DRFLW DTXDL FBGDL MWLXL CXRML MFBHR NXEFC TFDIN XJXFK LMFDG XKFKX WCMFW JXDRK NRRFK LLMWL HEKWJ FKFJX GNKBG LKGOV WKMBG LKGOX DOBNF DVFKG XKNRR FKLQF XDVJF WKFLM FKFVN JXLTO GJONL NJFCF KKWRF KQMFD TGNJF HBTLJ TNKXD RWEGN ABFFD VJTHL XGDJF PFJKX DRLMX DRKAF OGJFW HHBTX DRWZF TQGJE VXHMF JLGLM FCFKK WRFXQ XBBAF GNLGO VGDLW VLOGJ LMFJF KLGOL MFQFF ZXWCL WZXDR WVJWK MVGNJ KFXDD FNLJG DKLWJ ETDWC XVKXD LMFMG HFLMW LXVWD OXLXD AFLLF JQXLM LMFBG VWBKX MWPFW LFKLW LETDW CXSGD LMNJK EWTOG JWDXD LFJDK MXHXD LMFXJ HJGRJ WCCXD RKFVL XGDXO XVWDR FLWVV FKKLG LMFXJ DFLQG JZLMF DCWTA FQFVW DKLWJ LLGND JWPFB LMXKX DLMFC FWDLX CFXOG NDELM FWLLW VMFEC FCGKB XHOGB EFENH NDEFJ GDFBF RGOYW CFBXW KEFKZ WLOXJ KLXLM GNRML XLQWK YNKLW OXSOG JWQGA ABTEF KZANL XLLNJ DFEGN LLGAF WOWDL WKLXV HBWVF LGMXE FWKFV JFLXL JFCXD EFECF GOLMF HNJBG XDFEB FLLFJ QMXVM RXPFD LMFZF TQGJE XKHJG AWABT DGVGX DVXEF DVFXL BGGZK BXZFY WCFBX WWDEC WJLXD KMWJF EWBGP FGOGB EEFLF VLXPF KLGJX FKLJX DXLT\\n'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c4a" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(('waveform', ), -2536.7576625007914)" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key_a, score = keyword_break_mp(c4a)\n", + "key_a, score" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "harry and charlie i am no closer to the pds syndicate but i think i have begun to unravel why they might be interested in jamelia and martin as she told us in the hidden message i sent last week jamelia had been working on signal recognition at dynamix at first i was puzzled by this as i couldnt see how it related to weapon is ed gravity waves but then i took a look at her bookshelf and it began to make sense it was full of books on general relativity blackholes and neutron stars jamelia was not working on gravity waves but on gravitational waves i can see how the field agents would have got confused in the us they sometimes use both names for the same thing but they really are different gravity waves area seismological phenomenon as you already figured out gravitational waves are entirely different einstein predicted them a hundred years ago and they were detected by the ligo team last year the signals are given off by things like binary blackhole systems and are incredibly faint they easily get swamped by local noise it was an amazing feat detecting them and jamelia was part of that to add to our confusion she was in the team responsible for designing the search algorithms and the noise filters used to spot the signal of a galactic event against the noise of seismological activity so she did know something about gravity waves too i still dont know exactly how dynamix were using her expertise or what the pds syndicate are or do if you can get any intel on that it might help guide my enquiries the noise siam hearing suggest that pds are serious lots of cash lots of influence so i suggest we increase the security for future messages when you reply try using a double encryption reversing things before applying a keyword cipher to the message i will be out of contact for the rest of the week i am taking a crash course in neutron star dynamics in the hope that i can fit in better with the locals i have a test at dynamix on thursday for an internship in their programming section if i can get access to their network then maybe we can start to unravel this in the meantime i found the attached memo slip folded up under one leg of jamelia s desk at first i thought it was just a fix for a wobbly desk but it turned out to be a fantastic place to hide a secret it reminded me of the purloined letter which given the keyword is probably no coincidence it looks like jamelia and martin shared a love of old detective stories trinity\n" + ] + } + ], + "source": [ + "print(wcat(segment(sanitise(keyword_decipher(c4a, key_a[0], key_a[1])))))" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'tetheabmpnpskirytetfalulnhtdiiewnkhaeavrcleahecanoiufblgndiatssyeahmttlucodutacapyllrneevtemsooehftacattkehstksieytraohvtteshgierhtntiegilleaenctrethittghinamedgaflirotfaoictnofberiteislotoatitehwkinerncaeylalhtpelhegeansecicdloubawesmwdpeiafthllaseessrtofrouireltilanggtiorhsamhtreobeylalstrmabhtuteahntthwisaaetwrooegdiratghthtetstedpaatdorspvdeidiamsazlginyatdeiadlenkadmemtsiuaechstrieotesehtaeptsneritndokhwnooehwtylucodevhagosotmihucnmrfoanotiatuboplpeoetearhtseyognrieyrvetgnhiplpeoenodolieinnreevtguhohehtwnteisonoutaidphnhtmaeitmachpalyscsitithatlucoddaletmoosenithghtwisihucmidmeamitepitacslltilceovolosmoubgytretheraiseubalzppzalgnyiwwthaeralenuoedterheanytdaaxminacdinletbiheevocuwlkmayitvaohesithoroppttiunytemeiiwngtmohsefeonricomtleadlihetsetafrnonoillwityleloroumeetlarkoloiofngrdrwateeosioynguiaagnnosomitarn'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c4br = cat(reversed(sanitise(c4b)))\n", + "c4br" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "transpositions[transpositions_of('edgarallenpoe')] += ['edgarallenpoe']" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(((3, 2, 0, 1, 4), False, False), -1959.882702003483)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "column_transposition_break_mp(c4br)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'the temp bank is pretty full and i think we have a real chance of building a system that could actually prevent some of the attacks the key is to harvest the right intelligence at the right time and flag it for action before it is too late i think we can really help the agencies could be swamped with false alerts so our filtering algorithm has to be really smart but then that is what we are good at right the test data pds provided is amazingly detailed and makes it much easier to see the patterns i dont know how they could have got so much information about people are they storing everything people do online in ever thought when i set out on a phd in mathematical physics that it could lead to something with such immediate impact i still love cosmology but there is a real buzz applying what we learned out here at dynamix and icant believe how lucky i am to have this opportunity meeting with someone from citadelle this afternoon i will tell you more later looking forward to seeing you again soon martin'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wcat(segment(column_transposition_decipher(c4br, (3, 2, 0, 1, 4), False, False)))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['debar',\n", + " 'decaf',\n", + " 'decal',\n", + " 'decay',\n", + " 'ficas',\n", + " 'fleas',\n", + " 'freds',\n", + " 'gleam',\n", + " 'glean',\n", + " 'gofer',\n", + " 'great',\n", + " 'ikeas',\n", + " 'incas',\n", + " 'infer',\n", + " 'juicy',\n", + " 'krebs',\n", + " 'lobar',\n", + " 'loges',\n", + " 'lokis',\n", + " 'molar',\n", + " 'molds',\n", + " 'moldy',\n", + " 'moles',\n", + " 'nolas',\n", + " 'opecs',\n", + " 'pricy',\n", + " 'pries',\n", + " 'prigs',\n", + " 'prods',\n", + " 'profs',\n", + " 'proms',\n", + " 'pshaw',\n", + " 'punky',\n", + " 'rugby',\n", + " 'stony',\n", + " 'straw',\n", + " 'stray',\n", + " 'strew',\n", + " 'sulky',\n", + " 'surly',\n", + " 'debase',\n", + " 'debate',\n", + " 'deccan',\n", + " 'deccas',\n", + " 'encase',\n", + " 'endear',\n", + " 'fleecy',\n", + " 'freddy',\n", + " 'giddap',\n", + " 'goodby',\n", + " 'grease',\n", + " 'grebes',\n", + " 'greeds',\n", + " 'greedy',\n", + " 'guffaw',\n", + " 'higher',\n", + " 'hoffas',\n", + " 'incant',\n", + " 'indias',\n", + " 'indict',\n", + " 'infant',\n", + " 'inhere',\n", + " 'jogger',\n", + " 'kojaks',\n", + " 'locals',\n", + " 'logger',\n", + " 'looker',\n", + " 'nolans',\n", + " 'nonfat',\n", + " 'ormolu',\n", + " 'ornery',\n", + " 'oshawa',\n", + " 'osmium',\n", + " 'ossify',\n", + " 'prepay',\n", + " 'promos',\n", + " 'prompt',\n", + " 'pronto',\n", + " 'proofs',\n", + " 'pshaws',\n", + " 'pulley',\n", + " 'straws',\n", + " 'strays',\n", + " 'strews',\n", + " 'sulkys',\n", + " 'supply',\n", + " 'surrey',\n", + " 'swishy',\n", + " 'tunney',\n", + " 'tweedy',\n", + " 'twiggy',\n", + " 'debased',\n", + " 'debases',\n", + " 'debated',\n", + " 'decades',\n", + " 'decayed',\n", + " 'decease',\n", + " 'encases',\n", + " 'fleeces',\n", + " 'goddard',\n", + " 'greases',\n", + " 'greater',\n", + " 'greeces',\n", + " 'indians',\n", + " 'inhibit',\n", + " 'kookier',\n", + " 'locally',\n", + " 'mombasa',\n", + " 'mommies',\n", + " 'mummify',\n", + " 'noonday',\n", + " 'precept',\n", + " 'precess',\n", + " 'proctor',\n", + " 'pronoun',\n", + " 'propers',\n", + " 'strauss',\n", + " 'supplys',\n", + " 'surreys',\n", + " 'debarred',\n", + " 'deceased',\n", + " 'deceases',\n", + " 'endeared',\n", + " 'freebees',\n", + " 'indianas',\n", + " 'mombasas',\n", + " 'opponent',\n", + " 'prepares',\n", + " 'decadence',\n", + " 'deceaseds',\n", + " 'indianans']" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "transpositions[(3, 2, 0, 1, 4)]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 1, 0, 2, 4)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "transpositions_of('edgar')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/2016/4a.ciphertext b/2016/4a.ciphertext new file mode 100644 index 0000000..a6f1a54 --- /dev/null +++ b/2016/4a.ciphertext @@ -0,0 +1 @@ +MWJJT WDEVM WJBXF XWCDG VBGKF JLGLM FHEKK TDEXV WLFAN LXLMX DZXMW PFAFR NDLGN DJWPF BQMTL MFTCX RMLAF XDLFJ FKLFE XDYWC FBXWW DECWJ LXDWK KMFLG BENKX DLMFM XEEFD CFKKW RFXKF DLBWK LQFFZ YWCFB XWMWE AFFDQ GJZXD RGDKX RDWBJ FVGRD XLXGD WLETD WCXSW LOXJK LXQWK HNUUB FEATL MXKWK XVGNB EDLKF FMGQX LJFBW LFELG QFWHG DXKFE RJWPX LTQWP FKANL LMFDX LGGZW BGGZW LMFJA GGZKM FBOWD EXLAF RWDLG CWZFK FDKFX LQWKO NBBGO AGGZK GDRFD FJWBJ FBWLX PXLTA BWVZM GBFKW DEDFN LJGDK LWJKY WCFBX WQWKD GLQGJ ZXDRG DRJWP XLTQW PFKAN LGDRJ WPXLW LXGDW BQWPF KXVWD KFFMG QLMFO XFBEW RFDLK QGNBE MWPFR GLVGD ONKFE XDLMF NKLMF TKGCF LXCFK NKFAG LMDWC FKOGJ LMFKW CFLMX DRANL LMFTJ FWBBT WJFEX OOFJF DLRJW PXLTQ WPFKW JFWKF XKCGB GRXVW BHMFD GCFDG DWKTG NWBJF WETOX RNJFE GNLRJ WPXLW LXGDW BQWPF KWJFF DLXJF BTEXO OFJFD LFXDK LFXDH JFEXV LFELM FCWMN DEJFE TFWJK WRGWD ELMFT QFJFE FLFVL FEATL MFBXR GLFWC BWKLT FWJLM FKXRD WBKWJ FRXPF DGOOA TLMXD RKBXZ FAXDW JTABW VZMGB FKTKL FCKWD EWJFX DVJFE XABTO WXDLL MFTFW KXBTR FLKQW CHFEA TBGVW BDGXK FXLQW KWDWC WUXDR OFWLE FLFVL XDRLM FCWDE YWCFB XWQWK HWJLG OLMWL LGWEE LGGNJ VGDON KXGDK MFQWK XDLMF LFWCJ FKHGD KXABF OGJEF KXRDX DRLMF KFWJV MWBRG JXLMC KWDEL MFDGX KFOXB LFJKN KFELG KHGLL MFKXR DWBGO WRWBW VLXVF PFDLW RWXDK LLMFD GXKFG OKFXK CGBGR XVWBW VLXPX LTKGK MFEXE ZDGQK GCFLM XDRWA GNLRJ WPXLT QWPFK LGGXK LXBBE GDLZD GQFSW VLBTM GQETD WCXSQ FJFNK XDRMF JFSHF JLXKF GJQMW LLMFH EKKTD EXVWL FWJFG JEGXO TGNVW DRFLW DTXDL FBGDL MWLXL CXRML MFBHR NXEFC TFDIN XJXFK LMFDG XKFKX WCMFW JXDRK NRRFK LLMWL HEKWJ FKFJX GNKBG LKGOV WKMBG LKGOX DOBNF DVFKG XKNRR FKLQF XDVJF WKFLM FKFVN JXLTO GJONL NJFCF KKWRF KQMFD TGNJF HBTLJ TNKXD RWEGN ABFFD VJTHL XGDJF PFJKX DRLMX DRKAF OGJFW HHBTX DRWZF TQGJE VXHMF JLGLM FCFKK WRFXQ XBBAF GNLGO VGDLW VLOGJ LMFJF KLGOL MFQFF ZXWCL WZXDR WVJWK MVGNJ KFXDD FNLJG DKLWJ ETDWC XVKXD LMFMG HFLMW LXVWD OXLXD AFLLF JQXLM LMFBG VWBKX MWPFW LFKLW LETDW CXSGD LMNJK EWTOG JWDXD LFJDK MXHXD LMFXJ HJGRJ WCCXD RKFVL XGDXO XVWDR FLWVV FKKLG LMFXJ DFLQG JZLMF DCWTA FQFVW DKLWJ LLGND JWPFB LMXKX DLMFC FWDLX CFXOG NDELM FWLLW VMFEC FCGKB XHOGB EFENH NDEFJ GDFBF RGOYW CFBXW KEFKZ WLOXJ KLXLM GNRML XLQWK YNKLW OXSOG JWQGA ABTEF KZANL XLLNJ DFEGN LLGAF WOWDL WKLXV HBWVF LGMXE FWKFV JFLXL JFCXD EFECF GOLMF HNJBG XDFEB FLLFJ QMXVM RXPFD LMFZF TQGJE XKHJG AWABT DGVGX DVXEF DVFXL BGGZK BXZFY WCFBX WWDEC WJLXD KMWJF EWBGP FGOGB EEFLF VLXPF KLGJX FKLJX DXLT diff --git a/2016/4b.ciphertext b/2016/4b.ciphertext new file mode 100644 index 0000000..7188233 --- /dev/null +++ b/2016/4b.ciphertext @@ -0,0 +1 @@ +NRAT IMOS ONNG AAIU GNYO ISOE ETAW RDRG NFOI OLOK RALT EEMU OROL ELYT IWLL IONO NRFA TEST EHIL DAEL TMOC IRNO EFES HOMT GNWI IEME TYNU ITTP PORO HTIS EHOA VTIY AMKL WUCO VEEH IBTE LNID CANI MXAA DTYN AEHR ETDE OUNE LARE AHTW WIYN GLAZ PPZL ABUE SIAR EHTE RTYG BUOM SOLO VOEC LITL LSCA TIPE TIMA EMDI MCUH ISIW THGH TINE SOOM TELA DDOC ULTA HTIT ISCS YLAP HCAM TIEA MTHN HPDI ATUO NOSI ETNW THEH OHUG TVEE RNNI EILO DONE OEPL PIHN GTEV RYEI RNGO YEST HRAE TEOE PLPO BUTA ITON AOFR MNCU HIMT OSOG AHVE DOCU LYTW HEOO NWHK ODNT IREN STPE ATHE SETO EIRT SHCE AUIS TMEM DAKN ELDA IEDT AYNI GLZA SMAI DIED VPSR ODTA APDE TSTE THTH GTAR IDGE OORW TEAA SIWH TTNH AETU THBA MRTS LALY EBOE RTHM ASHR OITG GNAL ITLE RIUO RFOT RSSE ESAL LHTF AIEP DWMS EWAB UOLD CICE SNAE GEHL EPTH LALY EACN RENI KWHE TITA OTOL SIET IREB FONT CIOA FTOR ILFA GDEM ANIH GTTI HTER TCNE AELL IGEI TNTH REIG HSET TVHO ARTY EISK TSHE KTTA CATF HEOO SMET VEEN RLLY PACA TUDO CULT TMHA EYSS TAID NGLB FUIO NACE HAEL CRVA EAHK NWEI IDTH NLUL AFTE TYRI KSPN PMBA EHTE T