2020 “柏鹭杯” | Magic (MISC)

Magic

下载附件,是一个经过uucode编码的文本

UUCode和MIME64产生的原因是这样的:在Email中,传输的必须是ASCII中的可见的文字(即英文、数字、标点等),这样的话,如果想在Email中传输一个二进制文件的话,就必须要先进行一种变换,把二进制文件变换成ASCII文件,然后才可以进行传输,然后再在收信人处进行反变换,解出原来的二进制文件,这一机制在Email的附件中广泛地被使用。而UUCode和MIME64分别是两种不同的编码方法,UUCode是最早的Email中的编码方法,使用的最多,但是后来随着网络传输多媒体文件的需要,MIME64编码方法被提出并被很多协议支持,成了目前此类编码方法的主导。

更多信息请参考维基百科:http://zh.wikipedia.org/wiki/Uuencode

在 ubuntu 中安装 uucode 工具命令:sudo apt-get install sharutils

给密文补充好格式,前缀 begin 664 <out_file>,后缀 end

使用命令 uudecode <in_file> 解密,输出文件为

两个字符为一位作为 ASCALL 解码,得到:

TheNextisFenceCode 告诉我们接下来的字符串是用栅栏密码加密,解密后:

i'm glad that you have broken through the previous level, but one more question: do you known pigsty cipher? it's a weird looking code that has been passed on for hundreds of years.no one knows for sure when it was invented, but the code was used by a group called free masons and by the allies during the american civil war.ocjp{rwnl-enzni_xff_fcm_xf_cnjie@lewbuqjsb}as early as the 1700s, masons often used this code to protect some private records or to communicate, so it was also called masonic code. it was mentioned in dan brown's "lost secret talisman", but the cihper is of infant level and very easy to crack.

这段话是介绍猪圈密码的,提取出 ocjp{rwnl-enzni_xff_fcm_xf_cnjie@lewbuqjsb}

考虑变种猪圈密码加密字符串,参考下图:

左边的相同位置的字母对应右边的,进行一一替换

用以下脚本进行解密

a='abcdefghistuv'
s='jklmnopqrwxyz'
t='ocjp{rwnl-enzni_xff_fcm_xf_cnjie@lewbuqjsb}'
f=[]
len=len(t)
for i in range(0,len):
    n=a.find(t[i])
    m=s.find(t[i])
    if n==-1 and m==-1:
        f.append(t[i])
    if n==-1 and m!=-1:
      f.append(a[m])
    elif m==-1 and n!=-1:
        f.append(s[n])
for i in range(0,len):
  print(f[i],end="")

把相应字母改成大写,得到正确 flag{ISEC-Never_Too_Old_To_Learn@cnSkyHawk}

原文地址:https://www.cnblogs.com/zhwer/p/13615619.html