Tuesday, November 25, 2014

金盾 2014 Game 9 - You know who.

At the first glance, I guessed the encryption might be some sorts of Caesar cipher, just used ipython to figure it out.

#!/usr/bin/env python3
 
"""
game9.txt:
 
jbnh ybce t owxh xtsix rod d hqoi edheoi swie rvz zee zfozr mb ihsirjbp zla zfhfso dx tsi, uph xrwf cw tgz mb lqf xkvbopsfvvk, vbo wlqfv pvg yrxtwez ovlw wts nhpzo qsf vroz utyiz hf mcs nkmxr. fgxs dki somx csc d puhkez ftgmzu yhjr zi vqr mxgjpw, atwta nitwip vvk nc hhpx hyto gsh aaicw isghv isrk vbjwlubx xggp; vs evv pvg loammj vvzwhh 'xwkmgs chh dwubiu srsp.'vkmk://zlrhm.oqnmshhfewkxn.bpw/wqgrfz.xaj
"""
 
"""
In [25]: [ord('oqnmshhfewkxn.bpw'[i]) - ord('azurewebsites.net'[i])  for i in range(len('oqnmshhfewkxn.bpw'))]
Out[25]: [14, -9, -7, -5, 14, -15, 3, 4, -14, 14, -9, 19, -5, 0, -12, 11, 3]
 
In [26]: [ord(c) for c in "voldemort"]
Out[26]: [118, 111, 108, 100, 101, 109, 111, 114, 116]
 
In [27]: [ord(c)-ord('a') for c in "voldemort"]
Out[27]: [21, 14, 11, 3, 4, 12, 14, 17, 19]
 
In [28]: [ord(c)-ord('a')-26 for c in "voldemort"]
Out[28]: [-5, -12, -15, -23, -22, -14, -12, -9, -7]
 
In [29]: [ord('vkmk'[i]) - ord('http'[i])  for i in range(len('http'))]
Out[29]: [14, -9, -7, -5]
 
In [30]: [26 + ord('oqnmshhfewkxn.bpw'[i]) - ord('azurewebsites.net'[i])  for i in range(len('oqnmshhfewkxn.bpw'))]
Out[30]: [40, 17, 19, 21, 40, 11, 29, 30, 12, 40, 17, 45, 21, 26, 14, 37, 29]
 
In [33]: [(26 + ord('oqnmshhfewkxn.bpw'[i]) - ord('azurewebsites.net'[i]))  for i in range(len('oqnmshhfewkxn.bpw'))]
Out[33]: [40, 17, 19, 21, 40, 11, 29, 30, 12, 40, 17, 45, 21, 26, 14, 37, 29]
 
In [34]: [(26 + ord('oqnmshhfewkxn.bpw'[i]) - ord('azurewebsites.net'[i]))%26  for i in range(len('oqnmshhfewkxn.bpw'))]
Out[34]: [14, 17, 19, 21, 14, 11, 3, 4, 12, 14, 17, 19, 21, 0, 14, 11, 3]
"""
f = open('game9.txt', 'r')
 
idx = 0
perm = [21, 14, 11, 3, 4, 12, 14, 17, 19]
 
 
for line in f:
    for c in line:
        if ord('a') <= ord(c) <= ord('z'):
            print(chr((ord(c) - ord('a') + 52 - perm[idx]) % 26 + ord('a')), end='')
            idx += 1
            idx %= 9
        else:
            print(c, end='')
 
 
"""
output:
 
once upon a time there was a dear little girl who was loved by everyone who looked at her, but most of all by her grandmother, and there was nothing that she would not have given to the child. once she gave her a little riding hood of red velvet, which suited her so well that she would never wear anything else; so she was always called 'little red riding hood.'http://laoda.azurewebsites.net/sesame.jpg
"""

After decoded the secret text, we got a picture and found some info in its exif info

http://laoda.azurewebsites.net/sesame.jpg

http://metapicz.com/#landing?imgsrc=http%3A%2F%2Flaoda.azurewebsites.net%2Fsesame.jpg


ImageDescription    928iSfNYUQdaN6lM4nS080BI++VUy7n8wQZ+P89Z5O0kdWYmbuaN6VAq/Ulokd6a/QBll6fg0ml7WWTKcUK5ANW4wUPRZyZbdZWbTAHLkHFd3rvnUzP0SIswfV83PwW+
Make    nokia
Model   3310
XResolution 1
YResolution 1
ResolutionUnit  None
Artist  aes
YCbCrPositioning    Centered
Copyright   256bit


But we failed to find the decryption key for the AES-256 encryption.

After the game, our problem setter told us the AES key is just very simple little red riding hood without spaces.

Monday, November 3, 2014

Archlinux: Taiwan is NOT a Province of China anymore

An annoying bug in Archlinux for a long time is that the official guys always take the ISO standard for names of countries and regions which is totally wrong.

Taiwan is NOT a Province of China!

https://bugs.archlinux.org/task/30444



Recently, they changed it back to Taiwan. :)


https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/pacman-mirrorlist&id=63c4be053cb9964376565e412afc7d9b264be71a


Sunday, November 2, 2014

Converting Markdown to reStructuredText

I hate reStructuredText, it is not readable for me. But still, in some cases I have to hand on some stuffs in RST.

pandoc is a markup language converter written in Haskell (WTF?)/

https://github.com/jgm/pandoc

Usage:

pandoc -f markdown -t rst -o README.rst README.md

pandoc --from=markdown --to=rst --output=README.rst README.md



pandoc [OPTIONS] [FILES]
Input formats:  docbook, docx, epub, haddock, html, json, latex, markdown,
                markdown_github, markdown_mmd, markdown_phpextra,
                markdown_strict, mediawiki, native, opml, org, rst, t2t,
                textile
Output formats: asciidoc, beamer, context, docbook, docx, dokuwiki, dzslides,
                epub, epub3, fb2, haddock, html, html5, icml, json, latex, man,
                markdown, markdown_github, markdown_mmd, markdown_phpextra,
                markdown_strict, mediawiki, native, odt, opendocument, opml,
                org, pdf*, plain, revealjs, rst, rtf, s5, slideous, slidy,
                texinfo, textile
                [*for pdf output, use latex or beamer and -o FILENAME.pdf]