美文网首页
实验吧CTF密码学Writeup-我喜欢培根Writeup

实验吧CTF密码学Writeup-我喜欢培根Writeup

作者: syxvip | 来源:发表于2018-06-02 18:18 被阅读0次

    我喜欢培根分值:20

    • 来源: Ph0enix
    • 难度:中
    • 参与人数:5331人
    • Get Flag:2533人
    • 答题人数:2876人
    • 解题通过率:88%

    key: CTF{}

    解题链接: http://ctf5.shiyanbar.com/crypto/enc1.txt


    肯定摩斯密码
    解码后:
    m o r s e _ i s _ c o o l _ b u t _ b a c o n _ i s _ c o o l e r _ d c c d c c c d d d c d c c c d d c c c c c c c c c d d c d c c c c d c c c c c c d c c c d c c d c c c c d c c d d d c c d d d c c d c d d

    转化为:
    baabaaabbbabaaabbaaaaaaaaabbabaaaabaaaaa/abaaabaaba/aaabaabbbaabbbaababb

    image.png

    实在没想到,真的是败给了实验吧的格式。
    CTF{SHIYANBA IS COOL}

    附上python解密培根:

    #!/usr/bin/python  
    # -*- coding: utf-8 -*-  
    import re  
    alphabet=['a','b','c','d','e','f','g','h','i','j','k',  
    'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']  
      
    one_biao=["aaaaa","aaaab","aaaba","aaabb","aabaa","aabab",  
    "aabba","aabbb","abaaa","abaab","ababa","ababb","abbaa",  
    "abbab","abbba","abbbb","baaaa","baaab","baaba","baabb",  
    "babaa","babab","babba","babbb","bbaaa","bbaab"]  
      
    def encode():  
    #python3.0版本后用input替换了raw_input  
        string=input('请输入字符串加密')#明文  
        e_string=""  
        for index in string:  
            for i in range(0,26):  
                if(index==alphabet[i]):#字母匹配  
                    e_string+=one_biao  
                    break  
        print('编码'+e_string)  
        return  
          
    def decode():  
        e_string=input('请输入暗文解密')  
        e_array=re.findall(".{5}",e_string)  
        d_string=""  
        for index in e_array:  
            for i in range(0,26):  
                if index==one_biao[i]:  
                    d_string+=alphabet[i]  
        print("解码为:"+d_string)  
        return  
      
    if __name__=="__main__":  
        number=input('输入数1或2,1加密,2解密: ')  
        if number=="1":  
            encode()  
        elif number=='2':  
            decode()  
    

    相关文章

      网友评论

          本文标题:实验吧CTF密码学Writeup-我喜欢培根Writeup

          本文链接:https://www.haomeiwen.com/subject/hiursftx.html