st98 の日記帳


[ctf] Boston Key Party CTF 2015 の write-up

ぼっチーム omakase で参加した。最終的に獲得できたポイントは 320 点でチーム順位は 191 位 (参加 828 チーム中) だった。

の 10 問を解いた。

BU Central (School Bus 10)

flag: party

Prudential (School Bus 25)

flag: I_think_that_I_just_broke_sha1

Symphony (School Bus 25)

flag: B4SE10_IS_F0R_LOSERS

Northeastern Univ (School Bus 25)

flag: Still_better_than_the_d0uble_equals

Brigham Circle (School Bus 25)

flag: OK_Maybe_using_rexpexp_wasnt_a_clever_move

Longwood Medical (School Bus 25)

flag: Did_you_know_that_in_french_a_chiken_makes_the_sound_quotquotquotquot?

Museum of Fine Arts (School Bus 25)

flag: It_s33ms_that_PRNG_are_hard_too_after_all

Haymarket (Reversing 150)

from PIL import Image

def f(im, x=15, y=20):
  s = ''
  for a in range(12):
    for b in range(80):
      c = im.getpixel((x + 7 * b, y + 20 * a))
      s += 'X' if c == (20, 20, 20, 255) else ' '
    s += '\n'
  return s

if __name__ == '__main__':
  for x in range(1, 33):
    s = f(Image.open('L{}.png'.format(x)))
    open('result/{}.txt'.format(x), 'w').write(s)
def _invert(d):
  r = {}
  for k, v in d.items():
    r[v] = k
  return r

_Y = 0x800
_X = 0x400
_0 = 0x200
_t = {
  ' ': 0, '&': _Y, '-': _X,
  '#': 0x42, ',': 0x242, '$': 0x442, '.': 0x842,
  '@': 0x22, '%': 0x222, '*': 0x422, '<': 0x822,
  '/': 0x300, '+': 0x80a, '_': 0x212, ')': 0x412,
  '>': 0x20a, ':': 0x82, ';': 0x40a, "'": 0x12,
  '?': 0x206, '"': 0x6, '=': 0xa, '!': 0x482, '(': 0x812
}
for x in range(10):
  _t[chr(0x30 + x)] = 1 << (9 - x)
for x in range(9):
  _t[chr(0x41 + x)] = _Y | 1 << (8 - x)
for x in range(9):
  _t[chr(0x4a + x)] = _X | 1 << (8 - x)
for x in range(1, 9):
  _t[chr(0x52 + x)] = _0 | 1 << (8 - x)

_u = _invert(_t)

'''
decode[int(YX0123456789, 2)]
'''
def encode(c):
  return _t[c]
def decode(n):
  return _u.get(n, '?')
if __name__ == '__main__':
  r = ''
  for a in range(1, 33):
    s = open('result/{}.txt'.format(a)).read().splitlines()
    for x in range(80):
      t = ''
      for y in range(12):
        t += str(int(s[y][x] == 'X'))
      r += decode(int(t, 2))
    r += '\n'
  print(r)
flag: ALEXTREBEKISASOCIALENGINEER

Park Street (School Bus 10)

flag: OFPFC_ADD
このエントリーをはてなブックマークに追加
st98.github.io / st98 の日記帳