其他分享
首页 > 其他分享> > BugKuCTF 加密 easy_crypto

BugKuCTF 加密 easy_crypto

作者:互联网

0010 0100 01 110 1111011 11 11111 010 000 0 001101 1010 111 100 0 001101 01111 000 001101 00 10 1 0 010 0 000 1 01111 10 11110 101011 1111101

题解:

长度不一的01字符串 考虑是不是摩斯密码 

C#版本

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string oldstr;
            oldstr = Console.ReadLine();
            string []str = oldstr.Split(' ');
            for (int i = 0; i < str.Length; i++)
            {
                switch (str[i])
                {
                    case "01":
                        Console.Write("A"); break;
                    case "1000":
                        Console.Write("B"); break;
                    case "1010":
                        Console.Write("C"); break;
                    case "100":
                        Console.Write("D"); break;
                    case "0":
                        Console.Write("E"); break;
                    case "0010":
                        Console.Write("F"); break;
                    case "110":
                        Console.Write("G"); break;
                    case "0000":
                        Console.Write("H"); break;
                    case "00":
                        Console.Write("I"); break;
                    case "0111":
                        Console.Write("J"); break;
                    case "101":
                        Console.Write("K"); break;
                    case "0100":
                        Console.Write("L"); break;
                    case "11":
                        Console.Write("M"); break;
                    case "10":
                        Console.Write("N"); break;
                    case "111":
                        Console.Write("O"); break;
                    case "0110":
                        Console.Write("P"); break;
                    case "1101":
                        Console.Write("Q"); break;
                    case "010":
                        Console.Write("R"); break;
                    case "000":
                        Console.Write("S"); break;
                    case "1":
                        Console.Write("T"); break;
                    case "001":
                        Console.Write("U"); break;
                    case "0001":
                        Console.Write("V"); break;
                    case "011":
                        Console.Write("W"); break;
                    case "1001":
                        Console.Write("X"); break;
                    case "1011":
                        Console.Write("Y"); break;
                    case "1100":
                        Console.Write("Z"); break;

                    case "01111":
                        Console.Write("1"); break;
                    case "00111":
                        Console.Write("2"); break;
                    case "00011":
                        Console.Write("3"); break;
                    case "00001":
                        Console.Write("4"); break;
                    case "00000":
                        Console.Write("5"); break;
                    case "10000":
                        Console.Write("6"); break;
                    case "11000":
                        Console.Write("7"); break;
                    case "11100":
                        Console.Write("8"); break;
                    case "11110":
                        Console.Write("9"); break;
                    case "11111":
                        Console.Write("0"); break;

                    case "001100":
                        Console.Write("?"); break;
                    case "10010":
                        Console.Write("/"); break;
                    case "100001":
                        Console.Write("-"); break;
                    case "010101":
                        Console.Write("."); break;
                    case "110011":
                        Console.Write(","); break;
                    case "011010":
                        Console.Write("@"); break;
                    case "111000":
                        Console.Write(":"); break;
                    case "101010":
                        Console.Write(";"); break;
                    case "10001":
                        Console.Write("="); break;
                    case "011110":
                        Console.Write("'"); break;
                    case "101011":
                        Console.Write("!"); break;
                    case "001101":
                        Console.Write("_"); break;
                    case "010010":
                        Console.Write("\""); break;
                    case "10110":
                        Console.Write("("); break;
                    case "101101":
                        Console.Write(")"); break;
                    case "0001001":
                        Console.Write("$"); break;
                    case "01000":
                        Console.Write("&"); break;
                }
            }
        }
    }
}

运行结果:

得到:

FLAGM0RSE_CODE_1S_INTEREST1N9!

但是问题来了,提交flag为  FLAG{M0RSE_CODE_1S_INTEREST1N9!}  时不正确,可能是因为要求答案为小写吧,于是修改flag为小写,注意其中有字符“1”、“0”、“9”,不要与字母弄混了哟

flag:

flag{m0rse_code_1s_interest1n9!}

 

Python版本

from __future__ import print_function
a = input("input the string:")
s = a.split(" ")
dict = {'01': 'A',
        '1000': 'B',
        '1010': 'C',
        '100':'D',
        '0':'E',
        '0010':'F',
        '110': 'G',
        '0000': 'H',
        '00': 'I',
        '0111':'J',
        '101': 'K',
        '0100': 'L',
        '11': 'M',
        '10': 'N',
        '111': 'O',
        '0110': 'P',
        '1101': 'Q',
        '010': 'R',
        '000': 'S',
        '1': 'T',
        '001': 'U',
        '0001': 'V',
        '011': 'W',
        '1001': 'X',
        '1011': 'Y',
        '1100': 'Z',
        '01111': '1',
        '00111': '2',
        '00011': '3',
        '00001': '4',
        '00000': '5',
        '10000': '6',
        '11000': '7',
        '11100': '8',
        '11110': '9',
        '11111': '0',
        '001100': '?',
        '10010': '/',
        '101101': '()',
        '100001': '-',
        '010101': '.',
        '110011':',',
        '011010':'@',
        '111000':':',
        '101010':':',
        '10001':'=',
        '011110':"'",
        '101011':'!',
        '001101':'_',
        '010010':'"',
        '10110':'(',
        '1111011':'{',
        '1111101':'}'
        };
for item in s:
    print (dict[item],end='')

得到:

FLAG{M0RSE_CODE_1S_INTEREST1N9!}

提交错误 全改成小写就对了:

flag{m0rse_code_1s_interest1n9!}

 

记事本替换版本

..-. .-.. .- --. ----.-- -- ----- .-. ... . ..--.- -.-. --- -.. . ..--.- .---- ... ..--.- .. -. - . .-. . ... - .---- -. ----. -.-.-- -----.-

flag----.--m0rse code 1s interest1n9!-----.- 

 空格改下划线_,两端无法解密摩斯电码改为大括号

flag{m0rse_code_1s_interest1n9!}

标签:case,Write,Console,..,crypto,break,flag,easy,BugKuCTF
来源: https://blog.csdn.net/weixin_43272781/article/details/101173068