这杂乱的字符串,到底有什么玄机呢?

提示关键字:杂项、图片

flag格式:SeBaFi{}

flag下载

文本内容(部分):

1
11111101110110010111111110000101110011110011101111011110001101111110110111010100110111111111011100110100101101101101001111100011111110110111011111111001111110101101111001111011001111001001111011011111011011110011111010011101001100110100000101110011110111010100111110001100111111001011010111111011111110111111111111110111101111010111001101111111111111101111100111101111111011101011100011111100111111010000101110011111001011111101110001111010011101001011111011011111100100101001110111001011111111110111000100101101011100110111000111011111001111111110111111111010111111001110100111111111101111110001001111101011100100011101100111100111111111101010011001011110010001001111110101010111110101110101101101011011101011100111111010111100011011011111111010101111101011000010010111011111110000111001111110111111101101111111111111111100111000001101111101011101010110011110101111110001110111000101111111001100111101101100111111110010111110101100010111011010100001111000011011110101111100101100010111111111000010011001111010101111010110010111111010011111100011111010101010111010100001111111110011001111100101100010010111111000000111010111001111001100110110010100001110111111011001111001100111011101110110100111011110111111111001111110110010100111111001111010110111111100011011101011100110010101111011111000110111001011010001000000111100100011010000111101011101101111110001010111001000111011101101111111110110111001110111010111001000001001001110110100110101111101111101111111111101010110111101011100111001111001100110111110100101011110111111111010010111101001110110001111010101100111001111011111111001111110010001101111001111001111111000111010101111110110101011101010110111000111011100001111011111010011001011101111101001100001000111011011111101110110101110110111101110110111000101011111011111111111011111100110001001111110111101101111101110110010111101111111101110110111111011001001111001001111111011111100011110101010111101101010111111100101110001101011111000111111001111010101111100111100110110110111010101001100010010011111101100111100010100111010001110111110111011110110111111000011111111100111011101111110001101000100101111110101111111011111001101010110111100111110101111100010111100010000001111110111110111111110101110111100001100011011111101011111100111010001111001101111011010111100011011011011110110110111111111101111111101101111010110111100011111100110111011101101101101110001111111111101111111111011111111111111110010111001011111011000110111111110111111110001111110101110110111010000110111011101101100101110110101101010001111001111101111110010111111111111111110011111111011011100110111001111100111101111011000100100101101100110011011101010010100101011111001111000111110101010001101000011011011011111011110110110011101111111101011100111100010010111001101110111100101101111111110110001100111111000111111001111111101010011

一、二进制写入文件

想都没想,就直接二进制文本读取,再写入文件。

附上代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
f1 = open("flag.txt", "r")
f2 = open("out.txt", "w")
line = f1.readline()
count = 1
while line:
c = 0
x = 0
for index in line:
x = x*2+int(index)
c = c + 1
s = ''
if (c == 8):
c = 0
s = s + chr(x)
x = 0
f2.write(s)
print(count)
count += 1
line = f1.readline()

于是,输出文件用打开就是一堆乱码。binwalk检测无果。

看来方向错误。。。。

二、01点阵图

然后根据提示我联想到了颜色码。。。但是又没有位深度、图片大小的定义。。(想太复杂了)

最后还是根据提示(+老师的提示)才知道是黑白点阵图。。。

首先需要确定图片的大小

根据字数统计,得知总共有73937个01。

然后将73937分解因子得到110769173937

于是得知图片大小必然为(107*691

至于是横向还是纵向,就得尝试一下了。

生成点阵图

生成方法:

如果生成mbp图片的话,需要手写文件头,代码量比较多(嫌麻烦)

如果用python的图形库,代码量也不少。。。

于是用了一个最偷懒的办法:01分别代表空白和某可见字符,直接打印,不出意外的话,应该勉强能够看到flag。

代码与结果:

根据一波横竖生成测试,得到了下面的代码(比较方便阅读)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#73937 = 107 * 691 (唯一)
#encode:UTF-8
f1 = open("flag.txt","r")
f2 = open("out.txt","w+")
ss = f1.read()
for i in range(0,690):
s = ""
for j in range(0,106):
n = ss[(690-i)*107+j]
if(n == '1'):
s = s + "■"
else:
s = s + " "

s = s + "\n"
f2.write(s)

f1.close
f2.close

可以看到,我用“■”黑色实心方块来表示1的位置。这样更清晰。

i和j(行和列)的循环做了一点点调整,让打印出的结果文字方向便于阅读。

当然,由于我懒得改代码,最终文字显示的方向仍然是竖着的。至少可读了!

附上效果图:

注意:需要用等宽字体才能正常显示!

#EOF