Leetmore CTF 2012: Crypto 200 (XOROWblu Wbl(I)P)

This entry was posted on Oct 18 2012

What all we had was an encrypted file.

The “XOR” part of the challenge title suggests that we need to do some xorring.

XORing with “XOROWbIu WbI(|)P” or parts of it, don’t give any
interesting results.

Lets do some frequency based analysis.

We used xortool to do this for us.

xortool can:
  –  guess the key length (based on count of equal chars)
  –  guess the key (base on knowledge of most frequent char)

Because the cry200 file is 194 bytes, it is probably a xored sentence,
so a space (= 0×20) should be a frequent character.

$ ./ -c 20 cry200
The most probable key lengths:
3: 15.7%
6: 20.4%
9: 11.4%
12: 13.8%
15: 7.2%
18: 9.3%
21: 4.6%
24: 7.8%
26: 5.6%
30: 4.3%

Key-length can be 3*n
1 possible key(s) of length 6:
Found 1 plaintexts with 95.0%+ printable characters
See files filename-key.csv, filename-char_used-perc_printable.csv

The output file ‘xortool_out/0.out’ contains the dexored text when
xoring the input file with “\x96\xa4*\xc3\xc4″

>>> open('xortool_out/0.out','r').read()
'Cong (tula& ons!r\x1ehiler=he q\' ck b &wn f=1 jum": ove ithe >(zy
d=., th7iplai sho =er t:(n th7imess3.e. Y=nd'

Though the key was not completely guessed correctly by xortools, nut we can read most of the text now:
  – “Congratuations!”
  – “The quick brown fox jumps over the lazy dog.” ==> standard font
display sentence.

So now we can find the correct xor key, by xoring the input data with ”Congratuations!

>>> from itertools import izip, cycle
... def xor_crypt_string(data, key):
... return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
>>> data=open('cry200','r').read()
>>> data
>>> xor_crypt_string(data, 'Congratuations!')

The correct key is: "\x96\xa4*\xc3\x96s

>>> xor_crypt_string(data, '\x96\xa4*\xc3\x96s')
'Congratulations! While the quick brown fox jumps over the lazy dog,
the plain xor cipher is still very unsecure when the key is much
shorter than the message. Your flag: Foxie Dogzie Crypto Pwnd'

Solution: Foxie Dogzie Crypto Pwnd

Post a Comment