0%

Story of 1 and 2

Story of 1 and 2 - bugku challenge

Basic Information about the challenge

File

In this challenge, we got a file named ‘1和0的故事.txt’, whose content is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0000000001110010000000000
0000000000011110100000000
0000000001110001000000000
0000000010111100000000000
0000000010101010000000000
0000000001100010100000000
0000000010101010100000000
0000000001000001100000000
1100011101110110100011000
0001000010110010010010100
0100111101000011101110011
0011110100101011001001001
1000001001100001001101000
1111000111111011100101000
1011011111001101111110111
1000110110010010101101100
1000111100111111111110111
0000000010110001100010100
0000000010010100101010001
0000000010101010100011001
0000000000100111111110010
0000000000011001011110111
0000000001001100100100001
0000000011000011011011001
0000000011010000101110101

Solving process

This file looks like a QR code, and the 0 and 1 easily remind us of black and white.

So we wrote python script to recover QR code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import cv2
import numpy as np

with open('1和0的故事.txt', 'r') as f:
data = f.readlines()

data = [[int(m) for m in list(line)] for line in [i.split('\n')[0] for i in data]]
data = np.array(data)

width = height = 125
time = 5 # image in proper scale

img = np.zeros([width, height, 3], dtype=np.uint8)
for i in range(width//time):
for j in range(height//time):
value = 0 if data[i, j] else 1
img[i*time:i*time+time, j*time:j*time+time, :] = [value * 255, value * 255, value * 255]

cv2.imwrite("qrcode.jpg", img)

Ran the script and we got an image like this:

image-20231106234804659

but it seems like we lost the position like shown below.

undefined

source: wikipedia

There were so many methods to add on the position, like PhotoShop etc.

I chose to modify the txt file to this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1111111001110010001111111
1000001000011110101000001
1011101001110001001011101
1011101010111100001011101
1011101010101010001011101
1000001001100010101000001
1111111010101010101111111
0000000001000001100000000
1100011101110110100011000
0001000010110010010010100
0100111101000011101110011
0011110100101011001001001
1000001001100001001101000
1111000111111011100101000
1011011111001101111110111
1000110110010010101101100
1000111100111111111110111
0000000010110001100010100
1111111010010100101010001
1000001010101010100011001
1011101000100111111110010
1011101000011001011110111
1011101001001100100100001
1000001011000011011011001
1111111011010000101110101

then we ran again and got the correct QR code.

image-20231106235557038

Submit it to any QR code recognition website such as this one, and we got the flag.

1
flag{QR_c0de_1s_1nterest1n9}