ebCTF 2013 | cry100 « Classic » [Write Up]

« We found some crypto ciphers on our attic. Can you decipher all text and put together the flag? »

In this first crypto challenge, we were given six classic ciphertexts to break. Each plaintext gave a part of the final flag ebCTF{md5}.

I. Vigenere

The first ciphertext was a simple vigenere :

W yzrqc az o ghcu ivbe avi Jshkiedhbho. Yzrqcwu ova kvrpr xlsx yzcjw.
Nhwfstwadxrdf 3 amhzwrr cspfw kt yoszhlb ens adhr whql usou. Xuwf ova gcoh gzycycv cxx gzl Bipvsupnfkg. E hofji csyh sb hvh qnjrsx eg trv ggbfmoh gryiwuwvo. Vcziiwy gsis Rxxpz wsslzs, seelpqyhofoc ssyaing, advxwa uenrsqiek hbh cofgiawyg wpwzo arsy hlaa trv rnlfczom xwr. Gbhwers wlr lvivegh lrqmzhvu, yzrqcwu qej ps ishfk pioh wq pbuhz xkcz vlbhz orz uouhrf jsrpsfv.
Xuw afezwhlsass oph-kcrhrf Kixyv qostk ooza pshr bxmwgeozoc nujfizwhhh nk zojahm vlbwz kmpv hki PW tovg obg gnf dwxdghdrq ssasoh oqc cwusxnohlsa auqpqrwqk fzhft kpxhggk hbh ycbfialyoxar ofmqk. Aviu ofh eplbophm gdjrj avej ghhiyuhdtar dusgwjhmrs gksrk pb wkas fmeubawpobfif, sz hla kcrh pjhqoo fowlrj avej rsqxf au sbpfspi nujwhabhv, eydvkmju sdwl jlasroz rj gzl qpku oqh aga qsjhwqyrv wfiogiui bf avi pcsv fl los (izus rj) gzl gxasz qsfw.Zcqa ct wlr Vbhgd ozvs pgugmzsf zinjpbk yzcjw nk ismju vheylom jkf hki jwhfing' thig.
Auhinsgwmay mogp, hvh oygtd mo ozvs ewsoxar hr xuw dcvz goesgsns. Xds Tuiauo ksnr trv xdvat eg gdfbl. Mfijqv zseclfw svc ziew ysthoqhh oq togdwbhw gzycaar o npbew wr pvs pepzpbi pc puinc ph. 
Cki sdvawk msqfghps los jefgw tnja cj pvs ipny: lpGPT{62o

We could decrypt it by some classic cryptanalysis. Kasiski’s method tells us that the key-length was clearly 10. We can easily guess the end of the plaintext : « …the first part of the flag: ebCTF{… ». Vigenere is vulnerable to known-plaintext attacks, so we can recover the key : WOODENSHOE. Here is the deciphered message :

A klomp is a clog from the Netherlands. Klompen are whole feet clogs.
Approximately 3 million pairs of klompen are made each year. They are sold through out the Netherlands. A large part of the market is for tourist souvenirs. However some Dutch people, particularly farmers, market gardeners and gardeners still wear them for everyday use. Outside the tourist industry, klompen can be found best in local tool shops and garden centers.
The traditional all-wooden Dutch clogs have been officially accredited as safety shoes with the CE mark and can withstand almost any penetration including sharp objects and concentrated acids. They are actually safer than steelcapped protective shoes in some circumstances, as the wood cracks rather than dents in extreme accidents, allowing easy removal of the clog and not continued pressure on the toes by the (edge of) the steel nose.Some of the Dutch also consider wearing clogs as being healthy for the wearers' feet.
Interesting fact, the klomp is also related to the word sabotage. The French word for klomp is sabot. French workers who were replaced by machines throwed a klomp in the machine to break it. 
You earned yourself the first part of the flag: ebCTF{62a


We found the following encoded message to protect some 'cargo'. 


We were able to partialy decode the header. Can you decode the rest:

Shipping order

from: bram bloemendaal (Phone: 0123456789)
to: joris verhoven

This one was obviously a ADFGVX cipher. We did not see that the key was clearly given : we brute-forced all the permutations, and for each permutation, checked if the given plaintext would fit as a mono-substitution. Guessing the permutation has a length of 5, this gave us only 5! = 120 possibilities to brute-force. Here is our python script who did the job:

from pycipher import ADFGVX
from itertools import permutations
from string import uppercase as _

def possible(a, b):
    for i in range(len(b)):
        for j in range(len(b)):
            if b[i] == b[j]:
                if a[i] <> a[j]:
                    return False
            if b[i] <> b[j]:
                if a[i] == a[j]:
                    return False
    return True


for p in permutations("ABCDE"):
    # We decipher the ciphertext with a random key - we will solve monosub later
    adfgvx = ADFGVX(key='PH0QG64MEA1YL2NOFDXKR3CVS5ZW7BJ9UTI8', keyword=''.join(p))
    d = adfgvx.decipher(t)
    if(possible(d[:len(crib)], crib)):
        print "Found"
        print keyword
        print d

Permutation found was BAECD ; the deciphered ADFGVX returned was


From now, we just have a simple mono-alphanumeric substitution to break. We already know the beginning of the plaintext, which gives us an almost complete key :


This almost complete key gives us an almost complete plaintext.


The end of the plaintext is « sejond part of the flag bj1j09 » ; we guess that J is actually C. Here is our second part of the flag : bc1c09.


III. Xored JPG

The third part was a base64-encoded file. We guess a classic encryption like XOR was used here (the beginning of the ciphered file contained lots of letters, meaning that there were lots of « low » bytes, certainly a file header). We finally find out that the deciphered file was a JPG image. By XORing the ciphertext with a known-plaintext – for example, the four first bytes of a JPG are always 0xFF 0xD8 0xFF 0xE0, we can recover the key « tulip ». The final deciphered image gives us the third part of the key.



IV. Transposition Cipher

Fourth part was a classic transposition cipher:

thhneu hpeitr eafnw frleo otata uoghb rfirf ttseo



V. Mono Alphabetic Substitution

S fbnnbh niwzsed nstd oj rbqdiuhdqw iw zgsz zgd Hdzgdqyshtw ydusyiadt zgd mwd br fshhsoiw sht bzgdq qdfqdszibhsy wbrz tqmuw. Sffbqtihu zgd ysp shj mwd br tqmuw iw wziyy iyydusy, omz zgdqd iw s zbydqshfj kbyifj fsyydt udtbbuodydit rbq shj wbrz tqmuw. Zgiw iw s wdz br umitdyihdw zdyyihu kmoyif kqbwdfmzbqw mhtdq pgifg fiqfmnwzshfdw brrdhtdqw wgbmyt hbz od kqbwdfmzdt. Sffbqtihu zb fmqqdhz udtbbuodydit zgd kbwwdwwibh br s nslinmn snbmhz br rixd uqsnw fshhsoiw rbq kdqwbhsy mwd iw hbz kqbwdfmzdt. Fmyzixszibh iw zqdszdt ih s winiysq psj. Fmyzixszibh br 5 kyshzw bq ydww iw mwmsyyj hbz kqbwdfmzdt pgdh zgdj sqd qdhbmhfdt oj zgd fmyzixszbq.  Wb ir jbm fbnd zb zgd Hdzgdqyshtw sht pshz zb zqj wbnd qdfqdszibhsy mwd br wbrz tqmuw, odpsqd zgsz iz iw hbz ydusy. Zgd rirzg ksqz rbq zgd rysu iw so1rtd

Like all the other plaintexts, this one has to end with something like « The fifth part for the flag is ». This almost reveals us the whole plaintext. Completing the missing letters, and we recover the original text :

A common mistake made by foreigners is that the netherlands legalized the use of cannabis and other recreational soft drugs. According the law any use of drugs is still illegal, but there is a tolerancy policy called Gedoogbeleid for any soft drugs. This is a set of guidelines telling public prosecutors under which circumstances offenders should not be prosecuted. According to current Gedoogbeleid the possession of a maximum amount of five grams cannabis for personal use is not prosecuted. Cultivation is treated in a similar way. Cultivation of 5 plants or less is usually not prosecuted when they are renounced by the cultivator.  So if you come to the Netherlands and want to try some recreational use of soft drugs beware that it is not legal. The fifth part for the flag is ab1fde


VI. Caesar Cipher

The last one was the easiest one.

Xli Hipxe Asvow mw e wivmiw sj gsrwxvygxmsr tvsnigxw mr xli wsyxlaiwx sj xli Rixlivperhw xs tvsxigx e pevki evie sj perh evsyrh xli Vlmri-Qiywi-Wgliphx hipxe jvsq xli wie. Xli asvow gsrwmwx sj heqw, wpymgiw, psgow, hmoiw, piziiw, erh wxsvq wyvki fevvmivw. Xli emq sj xli heqw, wpymgiw, erh wxsvq wyvki fevvmivw aew xs wlsvxir xli Hyxgl gsewxpmri, xlyw vihygmrk xli ryqfiv sj hmoiw xlex leh xs fi vemwih.
Epsrk amxl xli Dymhivdii Asvow, Hipxe Asvow lezi fiir higpevih sri sj xli Wizir Asrhivw sj xli Qshivr Asvph fc xli Eqivmger Wsgmixc sj Gmzmp Irkmriivw. Xli pewx tevx sj xli jpek mw: sri-jmzi-j-xlvii-jsyv-}

This is a Caesar cipher with a key of 4.

The Delta Works is a series of construction projects in the southwest of the Netherlands to protect a large area of land around the Rhine-Meuse-Scheldt delta from the sea. The works consist of dams, sluices, locks, dikes, levees, and storm surge barriers. The aim of the dams, sluices, and storm surge barriers was to shorten the Dutch coastline, thus reducing the number of dikes that had to be raised.
Along with the Zuiderzee Works, Delta Works have been declared one of the Seven Wonders of the Modern World by the American Society of Civil Engineers. The last part of the flag is: one-five-f-three-four-}


We deciphered the six parts of the flag! This gives us the final flag to submit 🙂


2 réflexions au sujet de « ebCTF 2013 | cry100 « Classic » [Write Up] »


Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l'aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s