DefCamp CTF Qualification 2019 Writeup

この大会は2019/9/7 18:00(JST)~2019/9/8 18:00(JST)に開催されました。
今回もチームで参戦。結果は548点で304チーム中54位でした。
自分で解けた問題をWriteupとして書いておきます。

Ascii (Warmup)

$ python -c "print '\x44\x2d\x43\x54\x46\x20\x32\x30\x31\x39'"
D-CTF 2019
DCTF{D-CTF 2019}

Binary (Warmup)

10進数を2進数で答える問題。

>>> bin(1337)
'0b10100111001'
DCTF{0b10100111001}

base (Warmup)

$ nc 206.81.24.129 4441
What is the value of <<63982895>> in hex?
Input: 

16進数への変換、16進数からASCII文字への変換、8進数からASCII文字への変換を聞かれるので、答えていくスクリプトを作成し、実行する。

import socket
import re

def recvuntil(s, tail):
    data = ''
    while True:
        if tail in data:
            return data
        data += s.recv(1)

pattern = '<<(.+)>>'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('206.81.24.129', 4441))

data = recvuntil(s, ': ')
m = re.search(pattern, data)
chal = int(m.group(1))
ans = hex(chal)
print data + ans
s.sendall(ans + '\n')

data = recvuntil(s, ':')
m = re.search(pattern, data)
chal = m.group(1)
ans = chal.decode('hex')
print data + ans
s.sendall(ans + '\n')

data = recvuntil(s, ':')
m = re.search(pattern, data)
chal = m.group(1)
codes = chal.split(' ')
ans = ''
for code in codes:
    ans += chr(int(code, 8))
print data + ans
s.sendall(ans + '\n')

data = recvuntil(s, '\n').rstrip()
print data

実行結果は以下の通り。

What is the value of <<27527788>> in hex?
Input: 0x1a40a6c
What is the value of <<6b7771697664646f71666e7963706964737a6e6a>> in ASCII?
Input:kwqivddoqfnycpidsznj
What is the value of <<0152 0164 0164 0170 0160 0160 0151 0170 0156 0163 0164 0153 0142 0167 0153 0171 0163 0164 0172 0162>> in ASCII?
Input:jttxppixnstkbwkystzr
DCTF{1DC93CBD89FF120030210E09EEDFF52FEE06DE5973BF39CC05FA3BB22E075E43}
DCTF{1DC93CBD89FF120030210E09EEDFF52FEE06DE5973BF39CC05FA3BB22E075E43}

Cross or zero (Warmup)

フラグがDCTF{で始まることを前提にXOR鍵を求める。結果的には鍵は1文字のようだったので、それを元に復号する。

import itertools
import base64

def string_xor(s, key):
    key = key * (len(s) / len(key) + 1)
    return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in itertools.izip(s, key))

enc = 'dHNkdktUAFMBA1MIBglWBgkFCFEGBQlUCQRRBAgIBgQAVVRUAwkEBFEAAVRVVVRTBFRWBQdUBlMAB1YJVQYIBwIIBFVSTQ=='

flag_head = 'DCTF{'

enc = base64.b64decode(enc)

key = string_xor(flag_head, enc[:len(flag_head)])
key = key[0]

flag = string_xor(enc, key)
print flag
DCTF{d0c13c869f6958a659d94a488640edd3944a01deedc4df57d6c07f9e687284eb}

Corrupt file (Warmup)

flag.docxを解凍すると、flagファイルの中にフラグが書いてあった。

DCTF{a0bd4e405bc4e1fcf840c7c231181970e2b6fde7c60d4a0a415897bf07f8e17b}

Password (Warmup)

Easy Python Decompilerでデコンパイルする。

# Embedded file name: chall.py
a = 'DCTF{09fa'
c = '4d3142a6a'
b = '7ab70e9aa'
f = '1929d62e0'
g = '805934d86'
d = 'd4b55ea5b'
e = '1a436b536'
h = '59eadd}'
flag = a + b + c + d + e + f + g + h
password = 'Pass999990000!!!))))'
print 'Enter the password: '
buf = raw_input()
if password == buf:
    print flag
else:
    print 'Wrong password!'

a~hまで順に結合したものがフラグ。

DCTF{09fa7ab70e9aa4d3142a6ad4b55ea5b1a436b5361929d62e0805934d8659eadd}

Salad (Warmup)

シーザー暗号。https://www.geocachingtoolbox.com/index.php?lang=en&page=caesarCipherで復号する。

Rotation 11:
DCTF{b3cf67c8a4559247641d321fb60f1be7751b4075dfe72ca351f0072131e6ddb1}
DCTF{b3cf67c8a4559247641d321fb60f1be7751b4075dfe72ca351f0072131e6ddb1}

Get of your sunglasses (Warmup)

pastebinにアクセスすると、以下が書いてある。

DCTF{⠼⠁⠼⠁⠃⠼⠃⠼⠚⠼⠊⠁⠋⠑⠼⠉⠼⠑⠋⠼⠉⠼⠉⠼⠁⠃⠼⠊⠙⠼⠛⠼⠁⠼⠊⠼⠁⠁⠁⠼⠑⠼⠃⠼⠙⠼⠉⠼⠁⠃⠼⠑⠼⠛⠼⠋⠙⠼⠙⠁⠼⠋⠑⠃⠼⠉⠃⠼⠁⠙⠼⠁⠼⠊⠼⠊⠉⠼⠃⠑⠼⠓⠼⠙⠼⠓⠉⠼⠑⠙⠼⠓⠉⠼⠋⠼⠉⠼⠋⠼⠉⠙⠼⠛⠼⠃}

点字のようなので、それぞれ文字に対応していく。

DCTF{11b209afe35f331b9d7191aa52431b576d4a6eb3b1d199c2e848c5d8c6363d72}

Inception (Warmup)

$ binwalk chall.jpeg 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             JPEG image data, JFIF standard 1.01
382           0x17E           Copyright string: "Copyright (c) 1998 Hewlett-Packard Company"
110955        0x1B16B         PNG image, 400 x 400, 1-bit colormap, non-interlaced
111014        0x1B1A6         Zlib compressed data, default compression

PNGを切り出す。
f:id:satou-y:20190915190415p:plain
QRコードになっているので、読み取る。

DCTF{394a6dc71dee0bc7de700d28da66c836a534a72d417b1f25b6776d35a82b07f0}

Good Pasta (Warmup)

問題文はこうなっている。

My pasta recipe is at b7LejBXE. Enjoy

問題タイトルとこの文字を考えると、Pastebinがあやしい。
https://pastebin.com/b7LejBXEにアクセスすると、フラグが書いてあった。

DCTF{85e0e9595c8a98e174e9164035e7e6afaa7735286f2fcd856dec26e9a825c364}
Do not search for flags. This is the flag for warm up.
DCTF{85e0e9595c8a98e174e9164035e7e6afaa7735286f2fcd856dec26e9a825c364}