拿到题目用cat命令看一下,发现全是’ZERO’, ‘ONE’
于是转成01串,再转成16进制串,再转成字符串,变成了这样:
Li0gLi0uLiAuIC0uLi0gLS4tLiAtIC4uLS4gLSAuLi4uIC4tLS0tIC4uLi4uIC0tLSAuLS0tLSAuLi4gLS0tIC4uLi4uIC4uLSAuLS0uIC4uLi0tIC4tLiAtLS0gLi4uLi4gLiAtLi0uIC4tLiAuLi4tLSAtIC0tLSAtIC0uLi0gLQ==
用 base64 解码一下得到了这个玩意
.- .-… . -…- -.-. - …-. - … .---- … — .---- … — … …- .–. …-- .-. — … . -.-. .-. …-- - — - -…- -
一看就是morse密码,中间有空格,用’/'代替空格得到
.-/.-…/./-…-/-.-./-/…-./-/…/.----/…/—/.----/…/—/…/…-/.–./…–/.-./—/…/./-.-./.-./…–/-/—/-/-…-/-
在线解密解一下得到:
ALEXCTFTH15O1SO5UP3RO5ECR3TOTXT
加花括号,用 ‘_’ 代替 ‘O’ 得到:
ALEXCTF{TH15_1S_5UP3R_5ECR3T_TXT}
至于为什么用 ‘_’ 代替 ‘O’,有这样一个解释:
Because Morse code does not handle special characters we have to fiddle with the flag a bit more可是我寻思着摩斯密码里面是可以翻译 ‘_’ 的呀,唉!!!
import base64
def load_data(filename):
with open(filename, 'r') as fp:
data = fp.read().split()
content = ''
for c in data:
content += '0' if c == 'ZERO' else '1'
return content
def int_str(data):
s = ''
while data:
s += chr(data & 0xff); data >>= 8
return s[::-1]
if __name__ == "__main__":
data = load_data('../enc/cca1ce4b15ba4ac7950f6d03f8fa6ad1')
data = int_str(int(data, 2))
message = base64.b64decode(data.encode('utf8')).decode()
print(message.replace(' ', '/'))