Trend Micro CTF 2017 - Raimund Genes Cup - Online Qualifier [Reversing 200]

観察

revですがバイナリではなく何かのログのようなtxtファイルが渡されます。

Using Clock:64, Invert:0, Bits Found:625
ASK/Manchester - Clock: 64 - Decoded bitstream:
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101
1110111110111000
1010011110111010
1100111111111111
1011101111011101

なにやら周期性がありそうです。しかし、それだけだと何もわからないので"Using Clock:64,“を引用符付きで検索してみました。 すると次のページがひっかかりました。

Help identifying Erone Mini Series passive tag / 125 kHz Low Frequency / Proxmark developers community

どうやらRFIDに関する何かのようです。

次にRFIDとManchesterについて検索をしたところ次のページが出ました。

Decoding an EM4100 Manchester Encoded RFID Tag |

RFIDは連続した9つの1がデータのヘッダーを示すようですが、上のtxtにも連続した9つ以上の1がありました。

今回の問題はRFIDデータのタグに関する問題のようです。

Exploit

Exploitといってもただ先程のページに示したとおりにbit列を解釈するだけです。幸い同じbitが繰り返されてるようなので、paritycheckはいりませんでした。

$> python converter.py | python show_info.py
0xfeeddecafe6
#converter.py
header_count = 0
end_header = False
parity_bit = False
row_count = 0
data_count = 0
data_str = ''
for bit in '11101111101110001010011110111010110011111111111110111011110111011110111110111000101001111011101011001111111111111011101111011101111011111011100010100111101110101100111111111111101110111101110111101111101110001010011110111010110011111111111110111011110111011110111110111000101001111011101011001111111111111011101111011101111011111011100010100111101110101100111111111111101110111101110111101111101110001010011110111010110011111111111110111011110111011110111110111000101001111011101011001111111111111011101111011101':
    if not end_header:
        if bit == '1':
            header_count += 1
        else:
            header_count = 0
        if header_count == 9:
            end_header = True
    else:
        data_count += 1
        data_str += bit
        if data_count % 5 == 0:
            print(data_str)
            data_str = ''
            row_count += 1
        if row_count == 11:
            break
#show_info.py
import sys

bit_stream = ''
for line in iter(sys.stdin.readline, ""):
    line = line.strip()
    bit_stream += line[:-1]
print(hex(int(bit_stream,2)))

フラグは大文字を指定されているので TMCTF{FEEDDECAFE} を提出して終わりです。(最後の6はparitycheckの一部です)