NSSCTF Crypto 探索
常用编码
前两个题ID303,287在入门时做过了,详见另一篇wp链接
[AFCTF 2018]BASE ID:463
打开文件直接麻了,如果人工解码,估计黄花菜都要凉了,这就需要用到拥有强大数据处理能力的python了,下面是我借鉴得几个大佬的脚本。
首先是大佬xenny的,NSSCTF这个题的wp也有
import re, base64
s = open('/Users/x3nny/Downloads/flag_encode.txt', 'rb').read()
base16_dic = r'^[A-F0-9=]*$'
base32_dic = r'^[A-Z2-7=]*$'
base64_dic = r'^[A-Za-z0-9/+=]*$'
n= 0
while True:
n += 1
t = s.decode()
if '{' in t:
print(t)
break
elif re.match(base16_dic, t):
s = base64.b16decode(s)
print(str(n) + ' base16')
elif re.match(base32_dic, t):
s = base64.b32decode(s)
print(str(n) + ' base32')
elif re.match(base64_dic, t):
s = base64.b64decode(s)
print(str(n) + ' base64')
然后是看到另一个博主的脚本