Skip to content

Instantly share code, notes, and snippets.

@rayepeng
Last active May 19, 2021 01:41
Show Gist options
  • Save rayepeng/0bd697d2d2a8a115842bf283ff89a46a to your computer and use it in GitHub Desktop.
Save rayepeng/0bd697d2d2a8a115842bf283ff89a46a to your computer and use it in GitHub Desktop.
mistery_picture.py #CTF
import cv2
import re
img_ = cv2.imread('./mistery_picture.bmp')
mi_ = ''.join([str(x) for x in (img_ % 2).reshape(-1)])
for off_ in range(8):
mi_1 = mi_[off_:]
xxx = (''.join([chr(int(mi_1[8*i:8*(i+1)][::-1], 2)) for i in range(len(mi_1) // 8)]))
print(re.findall('(Iron[\s\S]{,66})', xxx))
# 修改了下代码
import cv2
import re
img_ = cv2.imread('./mistery_picture.bmp')
img_1 = (img_ % 2).reshape(-1) # 模2是提取最后一个bit reshpe(-1) 就是从左到右,从上到下去拼接像素
mi_ = ''
for x in img_1:
mi_ = mi_ + ''.join(str(x))
# mi_ = ''.join([str(x) for x in (img_ % 2).reshape(-1)])
for off_ in range(8):
mi_1 = mi_[off_:]
xxx = ''
for i in range(len(mi_1)//8):
a = chr(int(mi_1[8*i:8*(i+1)][::-1],2)) # [::-1] 逆序组合
xxx = xxx + a
# xxx = (''.join([chr(int(mi_1[8*i:8*(i+1)][::-1], 2)) for i in range(len(mi_1) // 8)]))
print(re.findall('(Iron[\s\S]{,66})', xxx))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment