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

2018-06-02  本文已影响0人  syxvip

我喜欢培根分值:20

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()  
上一篇下一篇

猜你喜欢

热点阅读