Traffic_Light
打开发现是一个红绿灯的gif图片
看到红绿灯的闪烁 让我们联想到了二进制的0和1,其中绿灯代表0,红灯代表1;
在网上找到了gif在线分离的工具,把gif分离下来
发现每八个红绿灯闪烁之后就会有一个黄灯作为间隔,这也证实了我的猜想
于是就有了思路,首先把红灯、绿灯、黄灯的图片用二进制读取出来,并存在一个列表里面,然后把其他图片也用二进制读取,和列表进行比对。 如果是红灯返回1,绿灯返回0,黄灯就表示换行。
puthon脚本如下 :
解析图片代表的二进制数字:
f = open("./Traffic_Light/0001.png","rb") #0
data = f.read()
f1 = open("./Traffic_Light/0003.png","rb") #1
data1 = f1.read()
f2 = open("./Traffic_Light/0017.png","rb")
data2 = f2.read()
a = data.encode('hex')
b = data1.encode('hex')
c = data2.encode('hex')
list=[a,b,c]
flag = ""
for i in range(9):
i=i+1
tupian = "./Traffic_Light/000"+str(i)+".png"
f = open(tupian,"rb")
data = f.read()
d = data.encode('hex')
if d in list:
number = list.index(d)
flag+=str(number)
print flag
for i in range(10,100):
tupian = "./Traffic_Light/00"+str(i)+".png"
f = open(tupian,"rb")
data = f.read()
d = data.encode('hex')
if d in list:
number = list.index(d)
flag+=str(number)
print flag
for i in range(100,1000):
tupian = "./Traffic_Light/0"+str(i)+".png"
f = open(tupian,"rb")
data = f.read()
d = data.encode('hex')
if d in list:
number = list.index(d)
flag+=str(number)
print flag
for i in range(1000,1169):
tupian = "./Traffic_Light/"+str(i)+".png"
f = open(tupian,"rb")
data = f.read()
d = data.encode('hex')
if d in list:
number = list.index(d)
flag+=str(number)
print flag
fn=flag.replace('2','\n')
s=open('./2.txt','a+')
s=s.write(fn)
将二进制转换为字符:
file=open("./2.txt","r")
flag = ""
while 1:
line = file.readline()
if not line:
break
else:
a = chr(int(line,2))
flag = flag + str(a)
print flag
print flag
得到flag:
flag{Pl34s3_p4y_4tt3nt10n_t0_tr4ff1c_s4f3ty_wh3n_y0u_4r3_0uts1d3}
|